@@ -700,18 +700,6 @@ def _verify_signature(
700
700
yield 'runtime does not have **kwargs argument "{}"' .format (stub .varkw .variable .name )
701
701
702
702
703
- def _verify_coroutine (
704
- stub : nodes .FuncItem , runtime : Any , * , runtime_is_coroutine : bool
705
- ) -> Optional [str ]:
706
- if stub .is_coroutine :
707
- if not runtime_is_coroutine :
708
- return 'is an "async def" function in the stub, but not at runtime'
709
- else :
710
- if runtime_is_coroutine :
711
- return 'is an "async def" function at runtime, but not in the stub'
712
- return None
713
-
714
-
715
703
@verify .register (nodes .FuncItem )
716
704
def verify_funcitem (
717
705
stub : nodes .FuncItem , runtime : MaybeMissing [Any ], object_path : List [str ]
@@ -735,21 +723,20 @@ def verify_funcitem(
735
723
stub_sig = Signature .from_funcitem (stub )
736
724
runtime_sig = Signature .from_inspect_signature (signature )
737
725
runtime_sig_desc = f'{ "async " if runtime_is_coroutine else "" } def { signature } '
726
+ stub_desc = f'def { stub_sig !r} '
738
727
else :
739
- runtime_sig_desc = None
740
-
741
- coroutine_mismatch_error = _verify_coroutine (
742
- stub ,
743
- runtime ,
744
- runtime_is_coroutine = runtime_is_coroutine
745
- )
728
+ runtime_sig_desc , stub_desc = None , None
746
729
747
- if coroutine_mismatch_error is not None :
730
+ # Don't raise an error if the stub is a coroutine, but the runtime isn't.
731
+ # That results in false positives.
732
+ # See https://github.com/python/typeshed/issues/7344
733
+ if runtime_is_coroutine and not stub .is_coroutine :
748
734
yield Error (
749
735
object_path ,
750
- coroutine_mismatch_error ,
736
+ 'is an "async def" function at runtime, but not in the stub' ,
751
737
stub ,
752
738
runtime ,
739
+ stub_desc = stub_desc ,
753
740
runtime_desc = runtime_sig_desc
754
741
)
755
742
0 commit comments