-
-
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
Let -2 argument dest match --python-version's #5619
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for splitting these changes out, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too.
I'm not sure what's unclear about the desired behavior? I'd think that it should make no difference whether you pass |
I was about to say in #5620 essentially that the behavior of these probably should not be different. |
@gvanrossum -- I might be misunderstanding, but I think the issue was that we were accidentally relying on the old, inconsistent behavior. For example, in CI, we install only Python 3 but type-check Python 2 code. If we were to make the config file behave in exactly the same way as Or to put it another way, this inconsistency is apparently the only available mechanism for type-checking Python 2 code using Python 3 site-packages currently available. One possible idea that's being floated around in #5620 is to relax some of our checks so that I guess the main open question here is whether or not setting |
Interesting. I had assumed that the way to skip looking for a Python 2 installation would be to set I see it as a pretty fundamental contract that every flag or option can be specified either on the command line or in the config file with exactly the same semantics. (Apart from that the command line can override global config file flags, and the config file also supports per-module flags.) @ethanhs Is there something I am missing here? Is there a deeper reason some of the PEP 561 behavior can only be done through the command line? In the meantime I'll merge this tiny change. |
@gvanrossum I believe that was merely an oversight on my part. |
OK, I filed #5630 to track this. |
@gvanrossum I had created issue #5620 for that earlier. So you may probably want to close it in favour of your new issue. Sorry for the confusion. |
This will not solve all problems, because we actually do need to search Python 3 site packages, where PEP 561 packages are installed. So we can't set this flag. A solution proposed by @Michael0x2a is to allow |
I guess I am not familiar with the constraints in the CI job we're talking about. Apparently:
This sounds really wrong. I'm not familiar with where in our (?) CI this is happening -- can someone show me the code where this is happening? (Not the code that searches for the stubs, but the part of the CI that relies on this behavior.)
TBH I'm not against that if it's the only solution, but I'm not convinced it is yet. |
I think that this happens with internal Dropbox mypy run scripts. We install SQLAlchemy stubs in the Python 3 virtualenv that we use to run mypy. We don't use a Python 2 virtualenv (neither locally nor in CI). We process the stubs in Python 2 mode even if they are installed in a Python 3 virtualenv, and there aren't separate stubs for Python 2 and 3. I'm not sure if this is a good way to set things up, but I believe that this is how things currently work. |
I see. We should really fix this by also creating a Py2 venv and installing the stubs there, then pointing mypy to that Py2. |
Hi. This addresses issue #5576. The pull request #5578 had stuff in it that broke things so this is a smaller change.
Currently,
mypy -2
behaves differently frommypy --python-version 2.7
in that only the latter will look for typing information in the Python 2 site packages. When-2
only is passed it ends up setting a value on a different namespace. With this change, the value is set up the same namespace and attribute that--python-version
sets. (See also #5576 (comment))There is still this inconsistency when loading the python version from the ini file, this will have to be addressed in another issue and pull request since the desired behaviour is unclear.