ruff/crates/red_knot_python_semantic/resources/mdtest/shadowing/function.md
Carl Meyer b8acadd6a2
[red-knot] have mdformat wrap mdtest files to 100 columns (#14020)
This makes it easier to read and edit (and review changes to) these
files as source, even though it doesn't affect the rendering.
2024-10-31 21:00:51 +00:00

456 B

Function shadowing

Parameter

Parameter x of type str is shadowed and reassigned with a new int value inside the function. No diagnostics should be generated.

def f(x: str):
    x: int = int(x)

Implicit error

def f(): ...

f = 1  # error: "Implicit shadowing of function `f`; annotate to make it explicit if this is intentional"

Explicit shadowing

def f(): ...

f: int = 1