-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CI/TYP: run stubtest #47817
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
CI/TYP: run stubtest #47817
Conversation
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.
Awesome, this looks pretty good to me.
I took a second look at the output of python -m mypy.stubtest pandas --mypy-config-file pyproject.toml --concise
(i.e. don't just run on the pyi files), since ideally that should work. It looks like there are three problems:
a) First, the mypy build doesn't work out of the box. I'll look into why this differs from regular mypy invocation. But once you fix that:
b) There are a lot of overloads where things are typed as keyword only because of deprecate_nonkeyword_arguments
, but aren't "actually" keyword only. I assume at some point the deprecations will turn into removals.
c) A lot of repeated errors from the way stubtest currently handles aliases. This will be improved in the next release of mypy.
What would be the added benefit of doing this? Shouldn't mypy find all those issues already?
The idea is that the type annotation is a kind of an added "deprecation" warning when people use a type checker while using deprecated behavior (and probably more importantly it let's us move a bit more quickly with the annotation process). I expect that the implementation will be keyword-only after the 1.5 release (running subtest on all files will be helpful to make all of those changes). |
Yes, sorry. My post was more notes to myself than anything immediately helpful for this PR. I was just thinking through things that would make stubtest more user friendly, so fewer people have to write wrapper scripts around it :-) |
I assume this PR doesn't need to wait for mypy 0.971 (seems to already work) |
Two suggestions:
|
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.
LGTM just a merge conflict
Could go before or after #47806. In either case, the other PR should be rebased before merging. |
stubtest is not intended as a "mypy++". Made this clearer in the documentation here: python/mypy#13293 Seeing if we can skip some work / ignore errors that block the actual stubtest logic from running is a good suggestion, I will see what improvements can be made there :-) |
Thanks @twoertwein |
Stubtest enforces that pyi files do not get out of sync with the implementation.
stubtest and mypy seems to have a slight discrepancy (had to change annotations so that they both error in the same cases).
stubtest needs pandas dev to be installed. This might not be something people want to do locally: if pandas dev is not installed:
scripts/run_stubtest.py
will 'succeed' but print a warning (the CI has pandas dev installed).Might want to wait for the CI using mypy 0.971 (#47806 waiting for conda).
@hauntsaninja: The allow list acts more or less like ignore comments, is there an option to error on unused allow list entries?
Closes #47760