Skip to content

Support importing types from nested packages #5591

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

Merged
merged 7 commits into from
Sep 26, 2018

Conversation

chrisphilip322
Copy link
Contributor

Attempts to address problems discussed in issue #1645. I enhanced the mypy.build._find_module to search for py.typed marker files at all package levels instead of at the top level. This change currently doesn't update stub package loading but I have added a test that fails without my change and passes with it.

@chrisphilip322
Copy link
Contributor Author

Is anyone available to look at this?

@JukkaL
Copy link
Collaborator

JukkaL commented Sep 17, 2018

@ethanhs Do you have time to look at this? This is related to PEP 561.

@emmatyping
Copy link
Member

Ah, sorry this PR got under my radar. I will take a look later this week.

@chrisphilip322
Copy link
Contributor Author

Hi @ethanhs, were you able to have a look at this last week?

@gvanrossum gvanrossum self-assigned this Sep 24, 2018
@gvanrossum
Copy link
Member

I'll review this unless @ethanhs steals it back from me again.

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.

I apologize for the long, nit-picking review! This is good work, but since the code you're changing is rather subtle I think it would be good to make the code as clear as possible. Please take my suggestions as attempts to help clarify both the existing code and the code you added. Thanks!

@@ -2357,11 +2376,13 @@ def find_module_and_diagnose(manager: BuildManager,
if not (options.ignore_missing_imports or in_partial_package(id, manager)):
module_not_found(manager, caller_line, caller_state, id)
raise ModuleNotFound
else:
elif root_source:
Copy link
Member

Choose a reason for hiding this comment

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

This could just be if since the previous if ḅlock always raises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally, I prefer the explicitness of using elif when chaining if statements but if its an issue I can change it.

Copy link
Member

Choose a reason for hiding this comment

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

In that case it would behoove you to change the if on L2375 to elif as well. :-) I'll let it slide.

Copy link
Contributor Author

@chrisphilip322 chrisphilip322 left a comment

Choose a reason for hiding this comment

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

@gvanrossum Thanks very much for your review! If there is anything I didn't satisfactorily address please let me know.

@@ -2357,11 +2376,13 @@ def find_module_and_diagnose(manager: BuildManager,
if not (options.ignore_missing_imports or in_partial_package(id, manager)):
module_not_found(manager, caller_line, caller_state, id)
raise ModuleNotFound
else:
elif root_source:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally, I prefer the explicitness of using elif when chaining if statements but if its an issue I can change it.

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.

I'll merge it now. Thanks for your efforts and for your attention to detail!

@@ -2357,11 +2376,13 @@ def find_module_and_diagnose(manager: BuildManager,
if not (options.ignore_missing_imports or in_partial_package(id, manager)):
module_not_found(manager, caller_line, caller_state, id)
raise ModuleNotFound
else:
elif root_source:
Copy link
Member

Choose a reason for hiding this comment

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

In that case it would behoove you to change the if on L2375 to elif as well. :-) I'll let it slide.

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.

4 participants