Skip to content

Confusing error message when class definition duplicated across if-else #1874

Closed
@sangsta

Description

@sangsta

I have a block of code that looks like this:

if foo:
    class A(object):
        ...
else:
    class A(object):
        ...

mypy complains for the second class definition:

error: Name 'A' already defined

However, this is technically not true.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions