- Are you reporting a bug, or opening a feature request?
A bug, unless this is somehow intended behavior.
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
https://github.com/henribru/stubtest-bug
- What is the actual behavior/output?
error: stubtest_bug.foo.Bar is not present at runtime
Stub: at line -1
Any
Runtime:
MISSING
error: stubtest_bug.foo.Baz is not present at runtime
Stub: at line -1
Any
Runtime:
MISSING
- What is the behavior/output you expect?
Given that Baz is reexported while Bar isn't, I would only expect an error for Baz. Importing a name that's not present at runtime in the stub to use in type annotations is a common use case and shouldn't produce errors, since Mypy won't let you import that name anyway without it being reexported.
Note that this seems to work as expected if there are annotations for the module you import from. The error only occurs if you import from a module without annotations and stick a type ignore comment at the import (the latter is needed to make stubtest run at all).
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
Python 3.7.3 and Mypy 0.770. I haven't tested master, but seems like there haven't been any changes to stubtest since 0.770 anyway.
A bug, unless this is somehow intended behavior.
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
https://github.com/henribru/stubtest-bug
Given that Baz is reexported while Bar isn't, I would only expect an error for Baz. Importing a name that's not present at runtime in the stub to use in type annotations is a common use case and shouldn't produce errors, since Mypy won't let you import that name anyway without it being reexported.
Note that this seems to work as expected if there are annotations for the module you import from. The error only occurs if you import from a module without annotations and stick a type ignore comment at the import (the latter is needed to make stubtest run at all).
Do you see the same issue after installing mypy from Git master?
Python 3.7.3 and Mypy 0.770. I haven't tested master, but seems like there haven't been any changes to stubtest since 0.770 anyway.