Skip to content
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

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

Closed
gregbedwell opened this issue Jun 20, 2019 · 3 comments
Closed

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

gregbedwell opened this issue Jun 20, 2019 · 3 comments

Comments

@gregbedwell
Copy link

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!

@msullivan
Copy link
Collaborator

msullivan commented Jun 20, 2019 via email

@gregbedwell
Copy link
Author

Ah. Brilliant. Thanks! Sorry for the noise

@pcorpet
Copy link

pcorpet commented Jun 24, 2019

@msullivan this is blocking when this happens in a dependency (I want to access init from https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/__init__.py).

Should I just run mypy with --implicit-reexport then?

And/or should I ask the lib to export it using init as init?

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

No branches or pull requests

3 participants