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(
19491949                # and unevaluated annotations inside a function body 
19501950                if  not  (
19511951                    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+                     )
19531963                ) and  not  (
19541964                    isinstance (stmt , nodes .AnnAssign )
19551965                    and  utils .get_node_first_ancestor_of_type (stmt , nodes .FunctionDef )
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments