55
66import flake8 .options .manager
77
8-
98FunctionTypes = Union [ast .AsyncFunctionDef , ast .FunctionDef , ast .Lambda ]
109LintResult = Tuple [int , int , str , str ]
1110
@@ -237,10 +236,14 @@ def get_decorator_names(function: FunctionTypes) -> Iterable[str]:
237236
238237def is_stub_function (function : FunctionTypes ) -> bool :
239238 if isinstance (function , ast .Lambda ):
240- return isinstance (function .body , ast .Ellipsis )
239+ return isinstance (function .body , ast .Constant ) and function . body . value is ...
241240
242241 statement = function .body [0 ]
243- if isinstance (statement , ast .Expr ) and isinstance (statement .value , ast .Str ):
242+ if (
243+ isinstance (statement , ast .Expr )
244+ and isinstance (statement .value , ast .Constant )
245+ and isinstance (statement .value .value , str )
246+ ):
244247 if len (function .body ) > 1 :
245248 # first statement is a docstring, let's skip it
246249 statement = function .body [1 ]
@@ -250,7 +253,11 @@ def is_stub_function(function: FunctionTypes) -> bool:
250253
251254 if isinstance (statement , ast .Pass ):
252255 return True
253- if isinstance (statement , ast .Expr ) and isinstance (statement .value , ast .Ellipsis ):
256+ if (
257+ isinstance (statement , ast .Expr )
258+ and isinstance (statement .value , ast .Constant )
259+ and statement .value .value is ...
260+ ):
254261 return True
255262
256263 if isinstance (statement , ast .Raise ):
0 commit comments