Thanks to visit codestin.com
Credit goes to github.com

Skip to content

stubtest reports imported name as not present at runtime even though it's not reexported #8649

Description

@henribru
  • 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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