Skip to content

Incorrect detection of name after failed import #10042

Closed as not planned
Closed as not planned
@AlbertoEAF

Description

@AlbertoEAF

The following:

# File bug.py
try:
    import simplejson as json
except (ImportError, SyntaxError):
    import json

results in:

mypy.py:4: error: Name 'json' already defined (by an import)
Found 1 error in 1 file (checked 1 source file)

under mypy 0.8 in Ubuntu18.04 with python 3.7.4. (mypy bug.py)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions