-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
TYP: Use stubtest to ensure consistency with pyi files #47760
Comments
Assuming a setup and activated virtualenv, the following basically works (might need to double check configuration to make sure there aren't problematic false negatives):
|
Output of the above on main:
|
When I run
|
You're a commit too early, it's "fixed" on latest mypy by python/mypy#13161 (aka runs without errors), but I'm not sure I understand the exact connection. The first two errors actually looked plausible to me, since |
@hauntsaninja changed some type annotations locally (and added some new ignore comments) so that mypy and stubtest happen to agree :) (not great but it works for now). I would like to call stubtest from within python but the following seems to exit without running stubtest: import os
from pathlib import Path
import sys
from mypy import stubtest
if __name__ == "__main__":
# find pyi files
root = Path.cwd()
pyi_modules = [
str(pyi.relative_to(root)).replace(os.sep, ".")
for pyi in root.glob("pandas/**/*.pyi")
]
args = pyi_modules + [
"--ignore-missing-stub",
"--concise",
"--mypy-config-file",
"pyproject.toml",
]
sys.exit(stubtest.test_stubs(stubtest.parse_options(args))) |
I wasn't able to repro on a baby test case (using mypy 0.971).
I'll try again later with my laptop that had a pandas dev env |
Feel free to checkout this branch https://github.com/twoertwein/pandas/tree/stubtest and run |
I found my (stupid) mistake: I wasn't removing the pyi suffix! I would have received errors, if I had not added |
Problem Description
Currently it's possible for stub files (pyi) to become out of date with the implementation (pyx, py)
pandas-dev/pandas-stubs#33 (comment)
Feature Description
stubtest is a tool that is shipped with mypy that can help compare the runtime implementation with what it finds in the stubs. For example, it found these issues (along with several others):
#47756
#47758
Alternative Solutions
I'm not aware of other tools that would work for this use case.
Additional Context
cc @twoertwein
The text was updated successfully, but these errors were encountered: