You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#13768 results in no errors when running on obviously incorrect code when run from a parent of the file being processed, as sys.path sometimes includes this directory even when not included in PATH, PYTHONPATH, or MYPYPATH. As far as I can tell, this is expected behavior on the part of the interpreter, though I haven't been able to locate the code that adds it:
The first entry in the module search path is the directory that contains the input script, if there is one. Otherwise, the first entry is the current directory, which is the case when executing the interactive shell, a -c command, or -m module.
As initialized upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter.
adebrecht661
changed the title
Mypy ignores all files when run in directory below target
Mypy ignores all files when run in directory above target
Nov 9, 2022
I have the same issue. Poetry acts different if packages are added with poetry add or by specifying them in the pyproject.toml and running poetry install. The later seems to add the project to path, which breaks linting in vs-code and probably some automated setups as well. Here is a detailed version on how to reproduce the issue microsoft/vscode-python#20182 (comment)
Fixed in at least one of my cases (Eclipse environment is harder to test). I saw #14042, but it wasn't clear that this was the same root cause, as I'm running on packages with -p rather than files (which I see was addressed in that thread shortly after I created this issue). Will close.
Bug Report
#13768 results in no errors when running on obviously incorrect code when run from a parent of the file being processed, as
sys.path
sometimes includes this directory even when not included in PATH, PYTHONPATH, or MYPYPATH. As far as I can tell, this is expected behavior on the part of the interpreter, though I haven't been able to locate the code that adds it:https://docs.python.org/3/library/sys_path_init.html
Python 3.10 docs actually seem clearer:
https://docs.python.org/3.10/library/sys.html#sys.path
To Reproduce
Run on the following snippet any time the sys.path includes a parent of the snippet's location.
Expected Behavior
mypy should detect incompatible assignment types.
Actual Behavior
No errors detected.
Your Environment
Ubuntu 22.04 on WSL1 and Eclipse PyDev on Windows 10. Note that a plain Windows 10 environment does not reproduce.
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: