File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1+ Fix false-negative for ``used-before-assignment`` with ``from __future__ import annotations`` in function definitions.
2+
3+ Refs #10482
Original file line number Diff line number Diff line change @@ -1929,7 +1929,17 @@ def _check_consumer(
19291929 # and unevaluated annotations inside a function body
19301930 if not (
19311931 self ._postponed_evaluation_enabled
1932- and isinstance (stmt , (nodes .AnnAssign , nodes .FunctionDef ))
1932+ and (
1933+ isinstance (stmt , nodes .AnnAssign )
1934+ or (
1935+ isinstance (stmt , nodes .FunctionDef )
1936+ and node
1937+ not in {
1938+ * (stmt .args .defaults or ()),
1939+ * (stmt .args .kw_defaults or ()),
1940+ }
1941+ )
1942+ )
19331943 ) and not (
19341944 isinstance (stmt , nodes .AnnAssign )
19351945 and utils .get_node_first_ancestor_of_type (stmt , nodes .FunctionDef )
You can’t perform that action at this time.
0 commit comments