Skip to content

Incorrect handling of proxy imports #7067

@AMDmi3

Description

@AMDmi3

Regression in 0.710 (still not fixed in 0.711). Not sure how it's called properly, but the problem is that mypy doesn't properly handle symbols imported from a package which imports them too. Example:

provider.py

def foobar1() -> None:
    pass
def foobar2() -> None:
    pass
def foobar3() -> None:
    pass

proxy.py

from provider import foobar1, foobar2, foobar3

main.py

from proxy import foobar1, foobar2, foobar3

main.py runs without errors and mypy 0.701 doesn't complain. However mypy 0.710 does:

main.py:1: error: Module 'proxy' has no attribute 'foobar1'; maybe "foobar3" or "foobar2"?
main.py:1: error: Module 'proxy' has no attribute 'foobar2'; maybe "foobar3" or "foobar1"?
main.py:1: error: Module 'proxy' has no attribute 'foobar3'; maybe "foobar2" or "foobar1"?

It's funny it complains on the very names it suggests. Adding __all__ to proxy.py doesn't help (however IMO it should work regardless).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions