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

Projects
None yet
2 participants
@ethanhs
Copy link
Collaborator

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 :)

@ilevkivskyi
Copy link
Collaborator

ilevkivskyi left a comment

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?

@@ -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',

This comment has been minimized.

@ilevkivskyi

ilevkivskyi Jun 22, 2018

Collaborator

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


# 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.

This comment has been minimized.

@ilevkivskyi

ilevkivskyi Jun 22, 2018

Collaborator

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

@ilevkivskyi

This comment has been minimized.

Copy link
Collaborator

ilevkivskyi commented Jun 22, 2018

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

ethanhs added some commits Jun 22, 2018

@ethanhs

This comment has been minimized.

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

This comment has been minimized.

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

gvanrossum added a commit that referenced this pull request Jun 30, 2018

Fail fast if site-packages are in the path (#5301)
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 ethanhs:reorder_search_paths branch Dec 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.