88from typing import List
99from typing import Set
1010from typing import Tuple
11+ from typing import Union
1112
1213from tokenize_rt import Offset
1314from tokenize_rt import Token
2526
2627FUNC_TYPES = (ast .Lambda , ast .FunctionDef , ast .AsyncFunctionDef )
2728NON_LAMBDA_FUNC_TYPES = (ast .FunctionDef , ast .AsyncFunctionDef )
29+ NonLambdaFuncTypes_T = Union [ast .FunctionDef , ast .AsyncFunctionDef ]
2830
2931
3032def _fix_yield (i : int , tokens : List [Token ]) -> None :
@@ -44,6 +46,14 @@ def _is_simple_base(base: ast.AST) -> bool:
4446 )
4547
4648
49+ def _is_staticmethod_decorated (node : NonLambdaFuncTypes_T ) -> bool :
50+ for decorator in node .decorator_list :
51+ if isinstance (decorator , ast .Name ) and decorator .id == 'staticmethod' :
52+ return True
53+ else :
54+ return False
55+
56+
4757class Scope :
4858 def __init__ (self , node : ast .AST ) -> None :
4959 self .node = node
@@ -127,6 +137,7 @@ def visit_Call(self, node: ast.Call) -> None:
127137 isinstance (self ._scopes [- 1 ].node , NON_LAMBDA_FUNC_TYPES ) and
128138 node .func .attr == self ._scopes [- 1 ].node .name and
129139 node .func .attr != '__new__' and
140+ not _is_staticmethod_decorated (self ._scopes [- 1 ].node ) and
130141 len (self ._scopes [- 1 ].node .args .args ) >= 1 and
131142 node .args [0 ].id == self ._scopes [- 1 ].node .args .args [0 ].arg and
132143 # the function is an attribute of the contained class name
0 commit comments