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 @@ -1949,7 +1949,17 @@ def _check_consumer(
1949
1949
# and unevaluated annotations inside a function body
1950
1950
if not (
1951
1951
self ._postponed_evaluation_enabled
1952
- and isinstance (stmt , (nodes .AnnAssign , nodes .FunctionDef ))
1952
+ and (
1953
+ isinstance (stmt , nodes .AnnAssign )
1954
+ or (
1955
+ isinstance (stmt , nodes .FunctionDef )
1956
+ and node
1957
+ not in {
1958
+ * (stmt .args .defaults or ()),
1959
+ * (stmt .args .kw_defaults or ()),
1960
+ }
1961
+ )
1962
+ )
1953
1963
) and not (
1954
1964
isinstance (stmt , nodes .AnnAssign )
1955
1965
and utils .get_node_first_ancestor_of_type (stmt , nodes .FunctionDef )
You can’t perform that action at this time.
0 commit comments