Files
ruff/crates/red_knot_python_semantic/resources/mdtest/shadowing/function.md
Alex d77480768d [red-knot] Port type inference tests to new test framework (#13719)
## Summary

Porting infer tests to new markdown tests framework.

Link to the corresponding issue: #13696

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2024-10-15 11:23:46 -07:00

455 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(): pass
f = 1 # error: "Implicit shadowing of function `f`; annotate to make it explicit if this is intentional"

Explicit shadowing

def f(): pass
f: int = 1