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

Fix search paths for -p #9387

Merged
merged 1 commit into from
Sep 8, 2020
Merged

Fix search paths for -p #9387

merged 1 commit into from
Sep 8, 2020

Conversation

huguesb
Copy link
Contributor

@huguesb huguesb commented Aug 31, 2020

-p is similar to -m except that it will recursively typecheck submodules.

Unfortunately the early module walk was being done with search paths that
did not benefit from site_packages for the selected python executable,
which resulted in some packages being typechecked fine with -m, but
rejected as not found by -p.

Fixes #9386

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it should work, but I'd like a small refactoring to reduce the code duplication.

Also, please add a test. Instructions in test-data/unit/README.md. You could add a test to cmdline.test.

mypy/main.py Outdated Show resolved Hide resolved
mypy/main.py Outdated Show resolved Hide resolved
@gvanrossum
Copy link
Member

(In the future, please don't amend or squash commits. Code reviewers prefer to see changes resulting from code review separate from the original changes. We'll squash when we land.)

@huguesb
Copy link
Contributor Author

huguesb commented Sep 8, 2020

(In the future, please don't amend or squash commits. Code reviewers prefer to see changes resulting from code review separate from the original changes. We'll squash when we land.)

Sorry, I'm used to code review tools that gracefully handle force pushes and can show diffs between successive updates... I will avoid force pushes here in the future.

`-p` is similar to `-m` except that it will recursively typecheck submodules.

Unfortunately the early module walk was being done with search paths that
did not benefit from site_packages for the selected python executable,

which resulted in some packages being typechecked fine with `-m`, but
rejected as `not found` by `-p`.

Fixes python#9386
@huguesb
Copy link
Contributor Author

huguesb commented Sep 8, 2020

This looks like it should work, but I'd like a small refactoring to reduce the code duplication.

Also, please add a test. Instructions in test-data/unit/README.md. You could add a test to cmdline.test.

The framework for cmdline.test explicitly disables site-packages. I'm modifying the pep561 test suite instead, since it already provisions a typed pkg in a venv.

@gvanrossum gvanrossum merged commit d7553fe into python:master Sep 8, 2020
@gvanrossum
Copy link
Member

Thanks for this contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-p fails to find packages that are found by -m
2 participants