@@ -295,6 +295,30 @@ def _is_fixture_decorator(self, node: ast.expr) -> bool:
295
295
# No valid syntax can reach here
296
296
return False # pragma: nocover
297
297
298
+ def _is_overload_decorator (self , node : ast .expr ) -> bool :
299
+ """Determine whether an expression is an overload decorator.
300
+
301
+ Args:
302
+ node: The node to check.
303
+
304
+ Returns:
305
+ Whether the node is an overload decorator.
306
+ """
307
+ if isinstance (node , ast .Name ):
308
+ return node .id == "overload"
309
+
310
+ # Handle call
311
+ if isinstance (node , ast .Call ):
312
+ return self ._is_overload_decorator (node = node .func )
313
+
314
+ # Handle attr
315
+ if isinstance (node , ast .Attribute ):
316
+ value = node .value
317
+ return node .attr == "overload" and isinstance (value , ast .Name ) and value .id == "typing"
318
+
319
+ # There is no valid syntax that gets to here
320
+ return False # pragma: nocover
321
+
298
322
def _skip_function (self , node : ast .FunctionDef | ast .AsyncFunctionDef ) -> bool :
299
323
"""Check whether to skip a function.
300
324
@@ -321,6 +345,10 @@ def _skip_function(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> bool:
321
345
if self ._file_type in {types_ .FileType .TEST , types_ .FileType .FIXTURE }:
322
346
return any (self ._is_fixture_decorator (decorator ) for decorator in node .decorator_list )
323
347
348
+ # Check for overload
349
+ if any (self ._is_overload_decorator (decorator ) for decorator in node .decorator_list ):
350
+ return True
351
+
324
352
return False
325
353
326
354
def visit_any_function (self , node : ast .FunctionDef | ast .AsyncFunctionDef ) -> None :
0 commit comments