@@ -260,14 +260,36 @@ def callback_with_extra_argument(line: str, extra: int) -> None:
260260 def callback_with_bytes_input (line : bytes ) -> None :
261261 pass
262262
263+ class CallableCallbackWithoutArguments :
264+ def __call__ (self ) -> None :
265+ pass
266+
267+ class CallableCallbackWithExtraArgument :
268+ def __call__ (self , line : str , extra : int ) -> None :
269+ pass
270+
271+ class CallableCallbackWithBytesInput :
272+ def __call__ (self , line : bytes ) -> None :
273+ pass
274+
263275 run ('python -c pass' , stdout_callback = callback_without_arguments ) # E: [arg-type]
264276 run ('python -c pass' , stderr_callback = callback_without_arguments ) # E: [arg-type]
265277 run ('python -c pass' , stdout_callback = callback_with_extra_argument ) # E: [arg-type]
266278 run ('python -c pass' , stderr_callback = callback_with_extra_argument ) # E: [arg-type]
267279 run ('python -c pass' , stdout_callback = callback_with_bytes_input ) # E: [arg-type]
268280 run ('python -c pass' , stderr_callback = callback_with_bytes_input ) # E: [arg-type]
281+ run ('python -c pass' , stdout_callback = CallableCallbackWithoutArguments ().__call__ ) # E: [arg-type]
282+ run ('python -c pass' , stderr_callback = CallableCallbackWithoutArguments ().__call__ ) # E: [arg-type]
283+ run ('python -c pass' , stdout_callback = CallableCallbackWithExtraArgument ().__call__ ) # E: [arg-type]
284+ run ('python -c pass' , stderr_callback = CallableCallbackWithExtraArgument ().__call__ ) # E: [arg-type]
285+ run ('python -c pass' , stdout_callback = CallableCallbackWithBytesInput ().__call__ ) # E: [arg-type]
286+ run ('python -c pass' , stderr_callback = CallableCallbackWithBytesInput ().__call__ ) # E: [arg-type]
269287 run ('python -c pass' , stdout_callback = None ) # E: [arg-type]
288+ run ('python -c pass' , stderr_callback = None ) # E: [arg-type]
289+ run ('python -c pass' , stdout_callback = 123 ) # E: [arg-type]
270290 run ('python -c pass' , stderr_callback = 123 ) # E: [arg-type]
291+ run ('python -c pass' , stdout_callback = object ()) # E: [arg-type]
292+ run ('python -c pass' , stderr_callback = object ()) # E: [arg-type]
271293
272294
273295@pytest .mark .mypy_testing
@@ -472,13 +494,22 @@ def test_run_static_return_type_is_not_changed_by_catch_exceptions() -> None:
472494
473495@pytest .mark .mypy_testing
474496def test_run_known_typing_gaps_are_currently_accepted () -> None :
475- """Current known gaps: mypy still accepts run() with no command args, timeout=True, and async callbacks ."""
497+ """Current known gaps: mypy still accepts cases that runtime validation rejects ."""
476498 async def async_callback (line : str ) -> None :
477499 pass
478500
501+ def generator_callback (line : str ):
502+ yield line
503+
504+ class CallbackClass :
505+ def __init__ (self , line : str ) -> None :
506+ pass
507+
479508 run ()
480509 run ('python -c pass' , timeout = True )
481510 run ('python -c pass' , stdout_callback = async_callback )
511+ run ('python -c pass' , stderr_callback = generator_callback )
512+ run ('python -c pass' , stdout_callback = CallbackClass )
482513
483514
484515@pytest .mark .mypy_testing
0 commit comments