Skip to content

Fix search paths for -p - #9387

Merged
gvanrossum merged 1 commit into
python:masterfrom
huguesb:fix-p
Sep 8, 2020
Merged

gvanrossum merged 1 commit into
python:masterfrom
huguesb:fix-p

Conversation

@huguesb

@huguesb huguesb commented Aug 31, 2020

Copy link
Copy Markdown
Contributor

-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

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.

Comment thread mypy/main.py Resolved
Comment thread mypy/main.py Resolved
@gvanrossum

Copy link
Copy Markdown
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

huguesb commented Sep 8, 2020

Copy link
Copy Markdown
Contributor Author

(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

huguesb commented Sep 8, 2020

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

3 participants