Skip to content

New "module has no attribute" errors in 0.710 #7030

@gregbedwell

Description

@gregbedwell

This is a change in behaviour I've noticed in 0.710. I can't help but think it's so simple that I'm obviously doing something very wrong, but I can't obviously see what. My apologies for wasting your time if it is user error! None of the other checking/linting tools I've tried warn about any issues here.

Here's a reproducer for what I'm seeing:

(py3.6) e:\tmp\mypy-issue>cat foo.py
from bar import qaz

print(qaz())
(py3.6) e:\tmp\mypy-issue>cat bar\__init__.py
from bar.baz import qaz

__all__ = [
    'qaz',
]
(py3.6) e:\tmp\mypy-issue>cat bar\baz.py
def qaz() -> int:
    return 42
(py3.6) e:\tmp\mypy-issue>python --version
Python 3.6.4

(py3.6) e:\tmp\mypy-issue>python foo.py
42
(py3.6) e:\tmp\mypy-issue>pip install -q "mypy<0.710"

(py3.6) e:\tmp\mypy-issue>mypy --version
mypy 0.701

(py3.6) e:\tmp\mypy-issue>mypy --strict .

(py3.6) e:\tmp\mypy-issue>pip install -q "mypy==0.710"

(py3.6) e:\tmp\mypy-issue>mypy --version
mypy 0.710

(py3.6) e:\tmp\mypy-issue>mypy --strict .
foo.py:1: error: Module 'bar' has no attribute 'qaz'

(py3.6) e:\tmp\mypy-issue>

Let me know if you need any more information.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions