-
Notifications
You must be signed in to change notification settings - Fork 129
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
Run type-annotation linters in CI environment #2841
base: main
Are you sure you want to change the base?
Conversation
c24cfd1
to
4278abb
Compare
a7c67ac
to
466b5c9
Compare
ed705d9
to
11a2dcc
Compare
rlRun "mypy_version=$(yq -r '.repos | .[] | select(.repo | test("^.*/mirrors-mypy$")) | .rev' ../../.pre-commit-config.yaml | tr -d 'v')" | ||
rlRun "pyright_version=$(yq -r '.repos | .[] | select(.repo | test("^.*/pyright-python$")) | .rev' ../../.pre-commit-config.yaml | tr -d 'v')" | ||
|
||
rlRun "rm -f requirements.txt && touch requirements.txt" | ||
rlRun "echo 'mypy==v${mypy_version}' >> requirements.txt" | ||
rlRun "echo 'pyright==v${pyright_version}' >> requirements.txt" | ||
rlRun "yq -r '.repos | .[] | select(.repo | test(\"^.*/mirrors-mypy$\")) | .hooks[0].additional_dependencies | .[] | select(test(\"^types-.*\"))' ../../.pre-commit-config.yaml >> requirements.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just be using dnf install python3-mypy
so that we are actually using the systems packages here? I see in the test logs that it is still downloading from pypi the packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're only filtering types-*
there. I was looking at urllib3-2.2.1
still being downloaded.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
requests 2.28.2 requires urllib3<1.27,>=1.21.1, but you have urllib3 2.2.1 which is incompatible.
Looking more on the issue of urllib3
, that seems to be quite a complicated can of worms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just be using
dnf install python3-mypy
so that we are actually using the systems packages here? I see in the test logs that it is still downloading from pypi the packages.
I wouldn't think so, because mypy (and pyright) are not tmt requirements, but linters. The idea is to use system dependencies, but defined linters looking at the project from outside. With system mypy, we might be using older versions often, which may not recognize issues newer versions were taught to report.
Oh, you're only filtering
types-*
there. I was looking aturllib3-2.2.1
still being downloaded.ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. requests 2.28.2 requires urllib3<1.27,>=1.21.1, but you have urllib3 2.2.1 which is incompatible.
Looking more on the issue of
urllib3
, that seems to be quite a complicated can of worms.
Yeah, it seems to be pulled in because of types-requests
. TBH, I did not even check the log of pip install
, and yeah, this is something I'd like to avoid. No idea why types-requests feels the need to pull in a genuine package, maybe because urllib3
does not ship type stubs separately, but an action like this would ruing the idea of "testing against system packages" :/
I think we'll get there, but it is indeed a bigger can of worms than it seemed last week :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't think so, because mypy (and pyright) are not tmt requirements, but linters. The idea is to use system dependencies, but defined linters looking at the project from outside. With system mypy, we might be using older versions often, which may not recognize issues newer versions were taught to report.
Yeah, fully agree. Was more concerned about the actual packages, but then I saw that you are only using types-*
, which seems a-ok. But I think the version of the types-*
needs to be matched with the version found in the system's pip
, i.e. search the pre-commit-config.yaml
(or maybe other approach later) for the types-*
packages, search pip list
or such for the actual package version, and then write the version constrain to match the actual package
No idea why types-requests feels the need to pull in a genuine package, maybe because urllib3 does not ship type stubs separately, but an action like this would ruing the idea of "testing against system packages" :/
Found out. It's because urllib3 >= 2.0
already includes typing, and the types-request
constraint used, does not apply in F40 case, thus getting the latest version types-request
which uses the latest urllib3
version. The workflow above should take care of that though, WDYT?
How about bumping some of the minimum requirements?
But does |
As long as they can be satisfied with RPMs available to us, I don't see a problem in general. I'm not sure what would happen if we bump a package version too much, rpmbuild would fail?
Maybe something related to
It does download missing types, with |
Good to keep this option in mind. If we end up decommissioning the pre-commit in favor of this workflow, that might be necessary to get the typeshed. At the very least it is worth making a temp commit running it with Edit: Did a bit of navigation around Footnotes |
11a2dcc
to
54ad9f3
Compare
/packit test |
tier: 0 | ||
|
||
adjust+: | ||
- when: distro == centos-stream-9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fixed on rhel-9 btw. Do we need to keep compatibility with older releases, or can we get rid of the workaround completely?
EDIT: actually, not fixed yet. "Release pending" :)
tests/type-annotations/main.fmf
Outdated
environment+: | ||
HATCH_ENVIRONMENT: dev-not-editable | ||
|
||
require+: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can use a single source of truth for the list of the packages. Maybe something similar to the existing make develop
perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could use make develop
directly. However, it's a bit unsatisfactory solution, instead of a declaration of packages required by a test, we'd instead take action and run make
. I'm going to switch to this make develop
command for now, but maybe we need to save these requirements somewhere from which both test and make could read it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in dcd0402
The goal si to verify the code and its annotations are compatible with Python packages shipped as system packages.
41a3b58
to
dcd0402
Compare
The goal si to verify the code and its annotations are compatible with Python packages shipped as system packages.
Pull Request Checklist