Skip to content

"Module has no attribute" error when using "__import__()" #7501

@blueyed

Description

@blueyed

I've noticed that __import__('pdb').set_trace() is handled differently than import pdb; pdb.set_trace():

% mypy =(echo "__import__('pdb').set_trace()"; echo "import pdb; pdb.set_trace(); pdb.meh")
/tmp/zshkq7d0B:1: error: Module has no attribute "set_trace"
/tmp/zshkq7d0B:2: error: Module has no attribute "meh"
Found 2 errors in 1 file (checked 1 source file)

I think this should behave the same.
I've not checked other modules, but pdb.set_trace is in typeshed.

mypy master (28423cd)

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