-
-
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
Cannot get type hints from python 2 packages #5620
Comments
Disclaimer: I haven't really been following this issue, so I may be missing some context, but I wonder if this is solvable by just having the people's whose config files broke with #5578 set the |
I believe in that case they would have to set `python_version` to 2.7 to check the Python 2 syntax and `python_executable` to a Python 3 interpreter to use its site-packages. There is something that ensures the versions here match and raises an exception otherwise. But maybe this should be allowed? I can't say for sure if mypy would behave as they'd like if it were allowed. That is interesting.
…On September 14, 2018 9:29:41 AM PDT, Michael Lee ***@***.***> wrote:
Disclaimer: I haven't really been following this issue, so I may be
missing some context, but I wonder if this is solvable by just having
the people's whose config files broke with #5578 set the
`python_executable` option in addition to the `python_version` option?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#5620 (comment)
|
I think I will be fine with this solution (assuming it doesn't break anything else). I just want to have a clear solution for the scenario where PEP 561 stub packages are installed in an interpreter different from the one used to run the code that is being checked (for example in the CI server situation I mention in PR #5578). @ethanhs I will be very grateful for your advice on this. |
I think @Michael0x2a's solution is likely optimal here. I will work on a fix for this later. |
* Remove check that python_[version/executable] agree * Allow setting python_version/executable from config file This fixes #5620
In mypy 0.620, there appears to be inconsistent type checking behaviour depending on how you specify the python version. This exists for handling
-2
and--python-version 2
arguments and is explained well in issue #5576 and addressed by pull request #5619. However, this inconsistency also occurs with specifying the python version in the a mypy.ini configuration file.That above is expected, but when specifying the version in a config file.
For good measure, I included a python 2 print statement in the test package to ensure it is actually is running under python 2 mode ... The example is included here. Extract the archive; in a Python 2 virtualenv, install the package in the
a
directory withpip -e a
; run mypy onpkgb
.The behaviour seems to come from looking for typing information in different site-packages between the two cases. With
--python-version 2.7
, a Python 2 interpreter's site-packages are used. With the configuration file, the current interpreter's site-packages are used.The pull request #5578 was an attempt to resolve this inconsistency by using the Python 2 site-packages in both configurations, but it seems like this broke some things for some folks.
The text was updated successfully, but these errors were encountered: