-
-
Notifications
You must be signed in to change notification settings - Fork 3k
problem finding data_dir on Windows when run using "python -m mypy" #1225
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
Comments
On Windows using CPython 3.5.1 in a venv I'm also running into the |
Maybe a fix similar to #1253 is needed, or a generalization thereof. I can't test on Windows but I'm happy to take PRs from people who are in a position to test them. |
Starting to dig into this for CPython 3.5.1 on Windows 10 in a venv, it looks like Line 767 in d4a555b
builtins module can't be typed. OK, so that's a stdlib module, so I guess typeshed should be handling this? Anyway, when I print out Line 1028 in d4a555b
builtins I get ('builtins', ('C:\\Users\\brcan\\Documents\\Repositories\\knights-who-say-ni', '.', '.', '.', '.', '. ', '.', '.', '.', '.', '.', '.')) which obviously contains no path to typeshed as installed in the venv.
Now looking at my venv, the location of |
Correct! The PR that I linked to actually shows the code where this determination is made. Sorry, I should have been more explicit. Here's the logic: Line 215 in d4a555b
|
Here's my proposed fix: master...allthedata:master. I tested it on Windows and Ubuntu and it seems to work. Side note: despite the comment in the function that says |
Can you submit that as a PR? Also, you can fix that comment about |
Are you willing to take a dependency on |
Honestly I'd prefer not to have those dependencies. And not everyone
uses setuptools.
|
I ran into issues with mypy on a simple example. Running Windows 8.1, Python 3.5 using Anaconda. Installed mypy using
pip install git+https://github.com/python/mypy.git
Saved the following as
a.py
:Ran the following in the command prompt:
python -m mypy a.py
and got the following:I found that the files were installed in the following locations:
.py
files are inC:/Users/MyUserName/Anaconda3/Lib/site-packages/mypy
typeshed
andxml
directories are inC:/Users/MyUserName/Anaconda3/Lib/mypy
C:/Users/MyUserName/Anaconda3/Scripts/mypy
(Running mypy in the command prompt doesn't work in Windows, which is why I had to run it as a module.)I ran pdb and found that when I call mypy as a module:
__init__.py
calls mypy.main.main(None)build.build
is called withbin_dir=None
build.default_data_dir
is called withbin_dir=None
build.default_data_dir
returnsC:/Users/MyUserName/Anaconda3/Lib/site-packages
when it should returnC:/Users/MyUserName/Anaconda3/Lib/mypy
In
build.default_data_dir
, for the case ofnot bin_dir
I changed the linelib = os.path.dirname(os.path.dirname(parent))
tolib = os.path.dirname(parent)
and now I can run mypy as a module. Not sure if it's the best solution but it works.Possibly related issue: #653. Later realized that I can run the mypy script within git bash if I change
#!/usr/bin/env python3
to#!/usr/bin/env python
, and then I don't have to worry about the module stuff. But Windows users installing from pip may not have a bash shell.The text was updated successfully, but these errors were encountered: