Skip to content

refactor: Python Inspector Overhaul Part 1 - Buildsystem migration #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

heliocastro
Copy link
Contributor

@heliocastro heliocastro commented Mar 27, 2025

  • Migration to Astral Uv to modernize projcet buildsystem
  • Use Ruff and Mypy as sole unique linters. This allows to replace old code style checkers and centralize configuration only on pyproject.toml
  • Add pre-commit capability
  • Update README to Github markdown and reflect buildsystem changes
  • Add new CI testing and publishing

@heliocastro heliocastro force-pushed the refactor/cariad_uv branch 5 times, most recently from fadbe3b to 42e0bb7 Compare March 27, 2025 22:21
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heliocastro Thanks for the push, but there are way too many changes at once mixed in one PR here. This is too hard to review and impossible to merge as it is. We would need to have smaller PRs focused on one major change at a time, like introducing one tool at a time not many at once.

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why drop the supported Python 3.9 version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this one, i expected that we will not be able to fully release in a month or so, and Python 3.9 is EOL soon.
But i reverted to use 3.9 as well.

@@ -0,0 +1,30 @@
default_language_version:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introducing pre-commit should be its own PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not mandatory and is not turned on by default, so no harm.
I really appreciate if we keep it to follow the README.

@@ -0,0 +1,27 @@
name: Run Pytest with Astral Uv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We run tests using a common azure pipelines and we are not using GH workflows for running tests. The base script would need to be updated in the https://github.com/aboutcode-org/skeleton first and ensure that this works fine.
At this stage all tests are failing also. See https://dev.azure.com/nexB/python-inspector/_build/results?buildId=15693&view=results

And there we run on linux, windows and mac in all cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, i know.
But now i'm on chicken and egg problem. I can't change skeleton without be approved and not break other projects, and at same time i need to see tests working.

Having the tests on Github cause no harm, so we can keep it.
If i have an easy way to update the skeleton without break the rest of the projects and i can effective use on the PR, would be fine.

@@ -30,7 +30,7 @@

import pytest

import utils_pip_compatibility_tags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not modify the code in etc/script, this is not code that is part of python-inspector but utility code from the skeleton. Furthermore, this is not a python module so do not add an __init__.py Note that these tests are not running in this repo with our pytest config, by design.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but without that, tests fail.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed init files and used pythonpath direct on pytest

@@ -6,7 +6,7 @@
"options": [
"--json <file>",
"--operating-system linux",
"--python-version 38",
"--python-version 39",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not change the Python default version in this PR, this should happen elsewhere, in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, as i dropped support for 3.8, this is actually correct

uv.lock Outdated
[[package]]
name = "aboutcode-toolkit"
version = "11.0.0"
source = { registry = "https://jfrog.hub.vwgroup.com/artifactory/api/pypi/optima-pypi-virtual/simple" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unlikely something anyone can use publicly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, was wrong registry on lock generation. Fixed already

pyproject.toml Outdated
@@ -1,52 +1,227 @@
[build-system]
requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 6"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not change the build backend mixed with other things. Make it its own PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved back to setuptools.

pyproject.toml Outdated
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"aiofiles>=24.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why introduce new dependencies in this PR? I cannot see where they would be used. I'd like to see something simple like a basic conversion from setup to pyproject with no other unrelated changes, otherwise this is hard to review

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came from the different branch, i removed all unnecessary extra deps


[tool.pytest.ini_options]
norecursedirs = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are needed. Why remove these?

Copy link
Contributor Author

@heliocastro heliocastro Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing huge multiple exclusions, used only testpath for the two required directories

python_classes = "Test"
python_functions = "test"

addopts = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These options are needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added back some opts, the python_classed and python_functions are not needed as default from pytest

@heliocastro heliocastro force-pushed the refactor/cariad_uv branch 4 times, most recently from 1101214 to a4ed493 Compare March 28, 2025 08:17
@heliocastro
Copy link
Contributor Author

@heliocastro Thanks for the push, but there are way too many changes at once mixed in one PR here. This is too hard to review and impossible to merge as it is. We would need to have smaller PRs focused on one major change at a time, like introducing one tool at a time not many at once.

This one is already minimal.

We will need to do some compromise here, we're talking in substantial changes. This is the minimal required to get the base changed and then we can do simple changes.

But please, bear with me on this one.

@heliocastro heliocastro force-pushed the refactor/cariad_uv branch 7 times, most recently from 3cb7e5c to c8c83ea Compare March 28, 2025 12:09
Replace setup tools and configure to unified Uv with pyproject based
setup.

Set minimum default python to 3.9 as python 3.8 is EOL.

Project file pyproject.toml now replaced all linters for a unified
solution using ruff and mypy and integrated pytest configurations.

Signed-off-by: Helio Chissini de Castro <helio.chissini.de.castro@cariad.technology>
- Regenerated tests with REGEN_TEST_FIXTURES
- Updated tests to proper import internal code
- Added testing Ci check for Github

Signed-off-by: Helio Chissini de Castro <helio.chissini.de.castro@cariad.technology>
Signed-off-by: Helio Chissini de Castro <helio.chissini.de.castro@cariad.technology>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants