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

Support importing types from nested packages #5591

Merged
merged 7 commits into from Sep 26, 2018

Conversation

Projects
None yet
4 participants
@macbeth322
Contributor

macbeth322 commented Sep 9, 2018

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.

macbeth322 added some commits Sep 9, 2018

@macbeth322

This comment has been minimized.

Contributor

macbeth322 commented Sep 17, 2018

Is anyone available to look at this?

@JukkaL

This comment has been minimized.

Collaborator

JukkaL commented Sep 17, 2018

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

@ethanhs

This comment has been minimized.

Collaborator

ethanhs commented Sep 17, 2018

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

@macbeth322

This comment has been minimized.

Contributor

macbeth322 commented Sep 24, 2018

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

@gvanrossum gvanrossum self-assigned this Sep 24, 2018

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 24, 2018

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

@gvanrossum

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!

Show resolved Hide resolved mypy/build.py Outdated
Show resolved Hide resolved mypy/build.py Outdated
Show resolved Hide resolved mypy/build.py Outdated
Show resolved Hide resolved mypy/build.py
@@ -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:

This comment has been minimized.

@gvanrossum

gvanrossum Sep 25, 2018

Member

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

This comment has been minimized.

@macbeth322

macbeth322 Sep 25, 2018

Contributor

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

This comment has been minimized.

@gvanrossum

gvanrossum Sep 26, 2018

Member

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

Show resolved Hide resolved mypy/build.py Outdated
Show resolved Hide resolved mypy/build.py Outdated
Show resolved Hide resolved mypy/build.py
Show resolved Hide resolved mypy/test/testpep561.py Outdated
Show resolved Hide resolved test-data/packages/typedpkg_namespace.alpha/setup.py Outdated
@macbeth322

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

Show resolved Hide resolved mypy/build.py
Show resolved Hide resolved mypy/build.py
@@ -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:

This comment has been minimized.

@macbeth322

macbeth322 Sep 25, 2018

Contributor

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

@gvanrossum

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:

This comment has been minimized.

@gvanrossum

gvanrossum Sep 26, 2018

Member

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

@gvanrossum gvanrossum merged commit 2244721 into python:master Sep 26, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment