-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
mypy 0.990 shows no errors when passing source directory as absolute path #14042
Comments
I can also reproduce this when I comment out mypy plugins in |
Also reproduced this in another project of mine. |
Does it reproduce with |
Yes. Adding |
Also do you have |
This issue does not occur with 0.982
PYTHONPATH is unset in the shell I'm testing this from. The |
Hm, probably the easiest way is to bisect mypy commits. Since the problem looks really bizzare. |
Adding Are you unable to reproduce this in any of your own projects? I can give bisecting a try. |
No, but I also don't have many.
That would be great, since I will not have much time today/tomorrow. |
@JukkaL could you please take a look? |
I was wrong before.
|
The behavior of |
Just to confirm I'm experiencing the same issue with the latest mypy. But the issue is not reproducible in every environment it seems. I run into the same issue as described by @intgr on my local machine, but our CI script can report errors correctly using the same version of mypy. |
I will investigate. This might be caused by absolute paths treated differently from relative paths, but we'll see. |
In case it is useful, |
I think this is the cause to microsoft/vscode-python#20182 EDIT: see my next comment, this issue here does not seem to cause the linting problem. The issue is about mypy not find any error when run by the linter but finding errors when the exact same command is running in a terminal. Notice the relative paths.
same code in terminal:
See the linked issue for a more detailed description. |
EDIT: through some experimentation i found that the vs-code linting issue is definitely caused by #14054 and not by this issue here. Some package managers automatically add the current working directory to the path, e.g. running |
that were under a directory in `sys.path`, which sometimes includes the current working directory, resulting in no errors reported at all. Fixes #14042.
#13768 had a bug so that errors were sometimes silenced in files that were under a directory in `sys.path`. `sys.path` sometimes includes the current working directory, resulting in no errors reported at all. Fix it by always reporting errors if a file was passed on the command line (unless *explicitly* silenced). When using import following errors can still be ignored, which is questionable, but this didn't change recently so I'm not addressing it here. Fixes #14042.
The issue should be fixed on master. It would be great if somebody can validate that it works. We'll have a 0.99x poinrt release (probably next week) that will include the fix. |
Thanks! I can confirm that this fixes my original use case. |
#13768 had a bug so that errors were sometimes silenced in files that were under a directory in `sys.path`. `sys.path` sometimes includes the current working directory, resulting in no errors reported at all. Fix it by always reporting errors if a file was passed on the command line (unless *explicitly* silenced). When using import following errors can still be ignored, which is questionable, but this didn't change recently so I'm not addressing it here. Fixes #14042.
0.10.1 * Work around python/mypy#14042. * Add support for Python 3.11.
Bug Report
I noticed that after upgrading to 0.990, mypy in djangorestframework-stubs CI no longer finds any errors.
It seems this happens when the source folder is passed as a full path, instead of relative path.
$PWD
is the full path of the current working directory:Maybe, just maybe, this is related to #13768?EDIT: seems not to be, various--follow-imports=
options have no effect.To Reproduce
update-to-mypy-0.990
requirements.txt
in a virtualenvpython scripts/typecheck_tests.py
, which populates thedrf_source
directoryYour Environment
mypy.ini
(and other config files): https://github.com/typeddjango/djangorestframework-stubs/blob/06a2f2f9f6c05a07f03bc1bd7f1b54ecfd7a3c43/mypy.iniThe text was updated successfully, but these errors were encountered: