Skip to content
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

sys.path change breaks editable installs of cwd #12956

Closed
hauntsaninja opened this issue Jun 8, 2022 · 1 comment · Fixed by #13161
Closed

sys.path change breaks editable installs of cwd #12956

hauntsaninja opened this issue Jun 8, 2022 · 1 comment · Fixed by #13161
Labels
bug mypy got something wrong

Comments

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jun 8, 2022

The new sys.path logic introduced in #11143 carefully avoids putting cwd onto sys.path, which is probably generally a good thing. However, the logic incorrectly removes cwd from sys.path in cases where the current directory has been editably installed (i.e. is on sys.path for reasons unrelated to being the current directory).

I'm not the most familiar with the code, but my understanding is this often doesn't really matter, since cwd should be on search_paths.python_path. However, it looks like we only look for stub packages on search_paths.package_path (which is where cwd is now removed from).

My concern here isn't theoretical. It came up in #12931 where when trying to reproduce, stubtest was unable to find the django stubs.

Depending on how serious we feel this concern is / how strictly backward compatible we want to be, there are several options for working around this. Curious for your opinions!

cc @AWhetter @ethanhs

@hauntsaninja hauntsaninja added the bug mypy got something wrong label Jun 8, 2022
@ethanhs
Copy link
Collaborator

ethanhs commented Jun 8, 2022

I think the best thing to do is search for stub packages in the python path as well. We've had requests for this in the past, and with #8545 any extra packages can be disabled if need be.

(Also from a consistency standpoint this would be simpler)

hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Jul 17, 2022
This fixes a recent regression introduced by the change to
use sys.path

Fixes python#12956
hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Jul 17, 2022
This fixes a recent regression introduced by the change to
use sys.path

Fixes python#12956
hauntsaninja added a commit that referenced this issue Jul 17, 2022
This fixes a recent regression introduced by the change to
use sys.path

Fixes #12956
hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Jul 17, 2022
This fixes a recent regression introduced by the change to
use sys.path

Fixes python#12956
ilevkivskyi pushed a commit that referenced this issue Jul 17, 2022
This fixes a recent regression introduced by the change to
use sys.path

Fixes #12956
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants