Check that each name is defined once [no-redef]
Mypy may generate an error if you have multiple definitions for a namein the same namespace. The reason is that this is often an error, asthe second definition may overwrite the first one. Also, mypy oftencan’t be able to determine whether references point to the first orthe second definition, which would compromise type checking.
If you silence this error, all references to the defined name refer tothe first definition.
Example:
- class A:
- def __init__(self, x: int) -> None: ...
- class A: # Error: Name 'A' already defined on line 1 [no-redef]
- def __init__(self, x: str) -> None: ...
- # Error: Argument 1 to "A" has incompatible type "str"; expected "int"
- # (the first definition wins!)
- A('x')