# Shadowing We currently show special diagnostic hints when a class or function is shadowed by a variable assignment. ## Implicit class shadowing ```py class C: ... C = 1 # snapshot: invalid-assignment ``` ```snapshot error[invalid-assignment]: Object of type `Literal[1]` is not assignable to `` --> src/mdtest_snippet.py:3:5 | 3 | C = 1 # snapshot: invalid-assignment | - ^ Incompatible value of type `Literal[1]` | | | Declared type `` info: Implicit shadowing of class `C`. Add an annotation to make it explicit if this is intentional ``` ## Implicit function shadowing ```py def f(): ... f = 1 # snapshot: invalid-assignment ``` ```snapshot error[invalid-assignment]: Object of type `Literal[1]` is not assignable to `def f() -> Unknown` --> src/mdtest_snippet.py:3:5 | 3 | f = 1 # snapshot: invalid-assignment | - ^ Incompatible value of type `Literal[1]` | | | Declared type `def f() -> Unknown` info: Implicit shadowing of function `f`. Add an annotation to make it explicit if this is intentional ``` ## No implicit shadowing for attribute assignments ```py from configparser import ConfigParser config = ConfigParser() config.optionxform = str # snapshot: invalid-assignment ``` ```snapshot error[invalid-assignment]: Object of type `` is not assignable to attribute `optionxform` of type `(optionstr: str) -> str` --> src/mdtest_snippet.py:4:1 | 4 | config.optionxform = str # snapshot: invalid-assignment | ^^^^^^^^^^^^^^^^^^ info: type `` has inferred callable type `Overload[(object: object = "") -> str, (object: Buffer, encoding: str = "utf-8", errors: str = "strict") -> str]` ```