-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Update -2 argument dest to match --python-version. #5578
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
Conversation
And check config for python_version when looking for a python executable.
I will take a closer look later today on the contents. As for testing, I think the best place to add it is here: https://github.com/python/mypy/blob/master/mypy/test/testargs.py#L26. |
@ethanhs Yeah I had looked at that earlier, for some reason I thought I'd need to test where And if you decide that |
Testing that infer_python_version_and_executable uses options.python_python.
@sqwishy ah, you probably want to use https://github.com/python/mypy/blob/master/mypy/util.py#L101 which will return |
Instead of giving infer_python_version_and_executable() a silly value and checking for an exception, set options.python_executable to None and make sure it's not None after the call.
@ethanhs I could. it might simplify the test a bit. But then it wouldn't run if someone didn't have a Python 2. Let me know if you'd prefer that over one of the previous revisions I made for tests. |
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.
Okay, I think this looks good to me, thank you for fixing this!
If there are no objections I will merge this later today (or someone else can go ahead). |
This reverts commit 9b9e7e1.
It looks like this PR broke PEP 561 packages because previously when checking Python 2 code, mypy looked for stub packages installed in the place where mypy is installed. But after this PR it only looks for PEP 561 packages in Python 2 site packages when type-checking Python 2 code. I am not sure what PEP 561 says about this, but the previous behavior was intuitive an useful. |
@ilevkivskyi I'm probably misunderstanding but it sounds like you're saying you have mypy stub python packages installed in the system's python 3 site-packages but you want them available in a python 2 virtualenv? I'd imagine you would want to install those typing stubs along side the package they're for in the virtualenv, right? |
Reverts #5578. It looks like the original PR caused breakages. We can re-apply later when we will have a fix. In particular PEP 561 packages are now not available in virtual environments, for example three of mypy tests fail when running then in a venv.
A (very) common scenario is where you have a CI server that type-checks some Python 2 repository with mypy. This server might not even have Python 2 available (some containers in Travis CI for example). The only reliable way to install PEP 561 stub packages in such scenario is to install them in the same place where mypy is installed. Before this PR this worked perfectly, but with the PR it doesn't. In addition to this problem, typeshed CI is currently broken, so they can't merge any PRs (the root cause may however be the same). I don't want to say the PR is bad, I just want to say we need to carefully discuss what do here. We can re-apply when we will have a clear way forward. @ethanhs What do you think about this? |
Any changes that break a common use case should be discussed in an issue, not only in a PR. Also, I don't think that the PR title and description quite describe what's changed. It looks to me like there are two separate changes in this PR, and if that's the case, there should also be two PRs (and two issues). |
Yeah that's kind of true. a. Running b. The other thing is that the site-packages used is different if you set the python version 2.7 in a mypy.ini file compared to specifying it on the command line, because IIRC So the confusion seems to be that this second behaviour (b) is a bug to me but a feature to @ilevkivskyi and anybody else who might enjoy getting type information from PEP 561 packages in Python 3/the current interpreter's site-packages when type checking a Python 2 project (if I understand correctly?) @JukkaL If you'd like. I be glad to open a new PR for just the change to argument parsing (a) to address #5576. And create a new issue here for behaviour (b). |
Sounds good! (b) clearly is a somewhat tricky issue and worth some more thought. |
And check config for python_version when looking for a python
executable.
See issue #5576.
I didn't add any automated tests because I wasn't sure what you guys would have wanted for that. This stuff makes use of subprocess so either that'd be mocked out or it would depend on python2.7 being installed? I'm not sure.
And I'm uncertain that changing
infer_python_version_and_executable()
as I did is a good idea. Or if you'd prefer thatpython_executable
on thespecial_opts
namespace be set, if it'sNone
, to the value of that attribute on theOptions
instance somewhere inprocess_options()
before callinginfer_python_version_and_executable()
?