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

Refactor and reorder search path #5256

Merged
merged 4 commits into from Jun 25, 2018

Conversation

ethanhs
Copy link
Collaborator

@ethanhs ethanhs commented Jun 21, 2018

As promised in #5227, here is an implementation for refactoring and making the search path compliant with PEP 561. The order is specified in https://www.python.org/dev/peps/pep-0561/#type-checker-module-resolution-order.

This is also my first PR from an airplane :)

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Looks good!

But I would like to double check on a real code base that this works OK (since you have a lot of churn because of lib_path -> search_paths). In the meantime could you please consider two minor comments?

mypy/build.py Outdated
@@ -188,10 +188,43 @@ def default_flush_errors(new_messages: List[str], is_serious: bool) -> None:
raise


def compute_lib_path(sources: List[BuildSource],
SearchPaths = NamedTuple('SearchPaths',
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a comment above documenting the fields and a typical usage.

mypy/build.py Outdated

# Prepend a config-defined mypy path.
lib_path.extendleft(options.mypy_path)
# Start with a MYPYPATH environment variable to front of library path, if defined.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence reads a bit weird. Did you mean "prepend"?

@ilevkivskyi
Copy link
Member

(Hm, also there is a merge conflict now.)

@ethanhs
Copy link
Collaborator Author

ethanhs commented Jun 22, 2018

@ilevkivskyi this should be ready to try on another code base.

I think I will tackle (finally) setuptools support next. It should be faily straightforward.

@ethanhs
Copy link
Collaborator Author

ethanhs commented Jun 23, 2018

Before merging this I also should probably update https://mypy.readthedocs.io/en/latest/command_line.html#how-imports-are-found (which I will do shortly).

E: Done.

@ilevkivskyi ilevkivskyi merged commit 59947f8 into python:master Jun 25, 2018
gvanrossum pushed a commit that referenced this pull request Jun 30, 2018
With my refactoring in #5256, I realized that it would be pretty straightforward to give some nicer warnings if site-packages were in any of the PATHs.
@ethanhs ethanhs deleted the reorder_search_paths branch December 4, 2018 00:06
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.

None yet

2 participants