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
Conversation
There was a problem hiding this 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', |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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"?
(Hm, also there is a merge conflict now.) |
@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. |
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. |
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.
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 :)