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!
This is a result of the new --no-implicit-reexports flag, which is part of
--strict. See
https://mypy.readthedocs.io/en/latest/command_line.html#miscellaneous-strictness-flags
It can be fixed by doing import qaz as qaz.
On Thu, Jun 20, 2019, 11:03 Greg Bedwell notifications@github.com wrote:
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 qazprint(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!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/python/mypy/issues/7030?email_source=notifications&email_token=AACTC7LX4KKH23RBQFFIDS3P3PA7BA5CNFSM4HZZLD42YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G2YU3ZQ,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACTC7OKRAC356VYJUPGWSLP3PA7BANCNFSM4HZZLD4Q
.
Ah. Brilliant. Thanks! Sorry for the noise
@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?
Most helpful comment
@msullivan this is blocking when this happens in a dependency (I want to access
initfrom https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/__init__.py).Should I just run mypy with
--implicit-reexportthen?And/or should I ask the lib to export it using
init as init?