@@ -291,6 +291,9 @@ def visit_FunctionDef(self, node: FunctionDef) -> None:
291
291
if hasattr (argument , 'annotation' ) and argument .annotation :
292
292
self .visit (argument .annotation )
293
293
294
+ if node .returns :
295
+ self .visit (node .returns )
296
+
294
297
def visit_AsyncFunctionDef (self , node : AsyncFunctionDef ) -> None :
295
298
"""Remove and map function arguments and returns."""
296
299
if self ._function_is_wrapped_by_validate_arguments (node ):
@@ -299,6 +302,9 @@ def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> None:
299
302
if hasattr (argument , 'annotation' ) and argument .annotation :
300
303
self .visit (argument .annotation )
301
304
305
+ if node .returns :
306
+ self .visit (node .returns )
307
+
302
308
303
309
class SQLAlchemyAnnotationVisitor (AnnotationVisitor ):
304
310
"""Adds any names in the annotation to mapped names."""
@@ -548,24 +554,13 @@ def handle_fastapi_decorator(self, node: AsyncFunctionDef | FunctionDef) -> None
548
554
549
555
To achieve this, we just visit the annotations to register them as "uses".
550
556
"""
551
- for path in [node .args .args , node .args .kwonlyargs ]:
557
+ for path in [node .args .args , node .args .kwonlyargs , node . args . posonlyargs ]:
552
558
for argument in path :
553
559
if hasattr (argument , 'annotation' ) and argument .annotation :
554
560
self .visit (argument .annotation )
555
- if (
556
- hasattr (node .args , 'kwarg' )
557
- and node .args .kwarg
558
- and hasattr (node .args .kwarg , 'annotation' )
559
- and node .args .kwarg .annotation
560
- ):
561
- self .visit (node .args .kwarg .annotation )
562
- if (
563
- hasattr (node .args , 'vararg' )
564
- and node .args .vararg
565
- and hasattr (node .args .vararg , 'annotation' )
566
- and node .args .vararg .annotation
567
- ):
568
- self .visit (node .args .vararg .annotation )
561
+
562
+ if node .returns :
563
+ self .visit (node .returns )
569
564
570
565
571
566
class FunctoolsSingledispatchMixin :
@@ -627,6 +622,9 @@ def handle_singledispatch_decorator(self, node: FunctionDef | AsyncFunctionDef)
627
622
if hasattr (argument , 'annotation' ) and argument .annotation :
628
623
self .visit (argument .annotation )
629
624
625
+ if node .returns :
626
+ self .visit (node .returns )
627
+
630
628
631
629
@dataclass
632
630
class ImportName :
0 commit comments