typeshed
typeshed copied to clipboard
require Generator for `contextmanager`
re-try of #2772 / #2773
Diff from mypy_primer, showing the effect of this PR on open source code:
pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/parser_generator.py:64: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[Any, Any, Any]]" [arg-type]
+ src/pegen/parser_generator.py:78: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[Any, Any, Any]]" [arg-type]
jax (https://github.com/google/jax)
+ jax/_src/config.py:703: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/config.py:708: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/config.py:713: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/config.py:717: error: Need type annotation for "transfer_guard_host_to_device" [var-annotated]
+ jax/_src/config.py:718: error: Need type annotation for "transfer_guard_device_to_device" [var-annotated]
+ jax/_src/config.py:719: error: Need type annotation for "transfer_guard_device_to_host" [var-annotated]
+ jax/_src/config.py:720: error: Need type annotation for "transfer_guard" [var-annotated]
+ jax/_src/config.py:723: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/config.py:734: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/config.py:829: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:200: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:211: error: Argument 1 to "contextmanager" has incompatible type "Callable[[NameStack], Iterator[None]]"; expected "Callable[[NameStack], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:221: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:226: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[Any, Any, Any]]" [arg-type]
+ jax/core.py:893: error: Need type annotation for "eval_context" [var-annotated]
+ jax/interpreters/partial_eval.py:571: error: Need type annotation for "main" [var-annotated]
+ jax/experimental/djax.py:453: error: Need type annotation for "main" [var-annotated]
+ jax/experimental/sparse/transform.py:251: error: Need type annotation for "main" [var-annotated]
pytest (https://github.com/pytest-dev/pytest)
+ testing/test_pathlib.py:447: error: Need type annotation for "mp" [var-annotated]
+ testing/test_monkeypatch.py:53: error: Need type annotation for "mp" [var-annotated]
+ testing/test_monkeypatch.py:58: error: Need type annotation for "mp" [var-annotated]
+ testing/test_monkeypatch.py:65: error: Need type annotation for "mp" [var-annotated]
+ testing/test_monkeypatch.py:86: error: Need type annotation for "mp" [var-annotated]
+ testing/test_monkeypatch.py:91: error: Need type annotation for "mp" [var-annotated]
+ testing/test_monkeypatch.py:412: error: Need type annotation for "m" [var-annotated]
+ testing/test_monkeypatch.py:422: error: Need type annotation for "m" [var-annotated]
+ testing/test_link_resolve.py:65: error: Need type annotation for "subst" [var-annotated]
+ testing/test_config.py:890: error: Need type annotation for "mp" [var-annotated]
+ testing/test_config.py:1187: error: Need type annotation for "mp" [var-annotated]
+ testing/test_capture.py:1076: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1084: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1092: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1103: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1111: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1117: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1127: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1141: error: Need type annotation for "cap1" [var-annotated]
+ testing/test_capture.py:1143: error: Need type annotation for "cap2" [var-annotated]
+ testing/test_capture.py:1151: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1159: error: Need type annotation for "cap" [var-annotated]
+ testing/test_capture.py:1188: error: Need type annotation for "cap1" [var-annotated]
+ testing/test_capture.py:1190: error: Need type annotation for "cap2" [var-annotated]
+ testing/test_capture.py:1220: error: Need type annotation for "cap" [var-annotated]
+ testing/python/fixtures.py:1653: error: Need type annotation for "mp" [var-annotated]
+ testing/python/collect.py:65: error: Need type annotation for "mp" [var-annotated]
+ testing/io/test_terminalwriter.py:46: error: Need type annotation for "m" [var-annotated]
+ testing/test_faulthandler.py:167: error: Need type annotation for "mp" [var-annotated]
zulip (https://github.com/zulip/zulip)
+ zerver/lib/context_managers.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[int, IO[Any]], bool], Iterator[None]]"; expected "Callable[[Union[int, IO[Any]], bool], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/context_managers.py:22: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, bool], Iterator[None]]"; expected "Callable[[str, bool], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/sqlalchemy_utils.py:24: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:132: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:155: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:85: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, Any], Iterator[None]]"; expected "Callable[[Any, Any], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:94: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:115: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:183: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[IO[str]]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:692: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, KwArg(object)], Iterator[MagicMock]]"; expected "Callable[[str, KwArg(object)], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:721: error: Need type annotation for "m" [var-annotated]
+ zerver/views/message_fetch.py:1051: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/views/message_fetch.py:1362: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/lib/test_classes.py:1181: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase], Iterator[None]]"; expected "Callable[[ZulipTestCase], Generator[Any, Any, Any]]" [arg-type]
+ zerver/lib/test_classes.py:1424: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Iterator[None]]"; expected "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Generator[Any, Any, Any]]" [arg-type]
+ analytics/tests/test_activity_views.py:36: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_users.py:794: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_users.py:795: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_users.py:1309: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_users.py:1954: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_users.py:1955: error: Need type annotation for "cache_queries" [var-annotated]
+ zerver/tests/test_upload.py:636: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_upload.py:699: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_upload.py:727: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_upload.py:770: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_typing.py:151: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_typing.py:188: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_typing.py:369: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_typing.py:405: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:2202: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:2203: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_subs.py:4176: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:4477: error: Need type annotation for "query_count" [var-annotated]
+ zerver/tests/test_subs.py:4478: error: Need type annotation for "cache_count" [var-annotated]
+ zerver/tests/test_subs.py:4536: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:4586: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:4587: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_subs.py:5052: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:5442: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:5567: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_subs.py:5718: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_soft_deactivation.py:343: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_soft_deactivation.py:400: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_soft_deactivation.py:574: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_signup.py:869: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_signup.py:869: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:1155: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_signup.py:1156: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_scim.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[SCIMTestCase, bool], Iterator[None]]"; expected "Callable[[SCIMTestCase, bool], Generator[Any, Any, Any]]" [arg-type]
+ zerver/tests/test_retention.py:1058: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_report.py:158: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_queue_worker.py:75: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FakeClient], Iterator[None]]"; expected "Callable[[FakeClient], Generator[Any, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:871: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PushNotificationTest], Iterator[APNsContext]]"; expected "Callable[[PushNotificationTest], Generator[Any, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:952: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1012: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1525: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1543: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1560: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:2447: error: Need type annotation for "mock_publish" [var-annotated]
+ zerver/tests/test_message_send.py:1614: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_message_fetch.py:66: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:73: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:2981: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_message_fetch.py:3022: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:3161: error: Need type annotation for "all_queries" [var-annotated]
+ zerver/tests/test_message_fetch.py:3208: error: Need type annotation for "all_queries" [var-annotated]
+ zerver/tests/test_message_fetch.py:3232: error: Need type annotation for "all_queries" [var-annotated]
+ zerver/tests/test_message_fetch.py:3284: error: Need type annotation for "all_queries" [var-annotated]
+ zerver/tests/test_message_edit.py:49: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_message_edit.py:269: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_message_edit.py:1864: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_message_edit.py:1864: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_message_dict.py:178: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_link_embed.py:392: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:423: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:465: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:576: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:609: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:680: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:712: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:747: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:785: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:822: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_home.py:240: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_home.py:416: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_home.py:449: error: Need type annotation for "queries2" [var-annotated]
+ zerver/tests/test_home.py:996: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_home.py:1044: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_external.py:77: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int, int, str], Iterator[None]]"; expected "Callable[[int, int, str], Generator[Any, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:295: error: Argument 1 to "contextmanager" has incompatible type "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Iterator[Mock]]"; expected "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Generator[Any, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:344: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:360: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:378: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_example.py:371: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_event_queue.py:38: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_email_mirror.py:1385: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_digest.py:70: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_digest.py:123: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_digest.py:180: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_digest.py:181: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_custom_profile_data.py:751: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_bots.py:157: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_auth_backends.py:3177: error: Argument 1 to "contextmanager" has incompatible type "Callable[[AppleAuthBackendNativeFlowTest], Iterator[None]]"; expected "Callable[[AppleAuthBackendNativeFlowTest], Generator[Any, Any, Any]]" [arg-type]
+ zerver/management/commands/process_queue.py:19: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger, str, bool], Iterator[None]]"; expected "Callable[[Logger, str, bool], Generator[Any, Any, Any]]" [arg-type]
+ zerver/tests/test_message_flags.py:1309: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_message_flags.py:1370: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_logging_handlers.py:203: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_event_system.py:1005: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_cache.py:91: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_cache.py:110: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_cache.py:128: error: Need type annotation for "queries" [var-annotated]
+ zerver/tests/test_cache.py:136: error: Need type annotation for "queries_two" [var-annotated]
+ zerver/tests/test_cache.py:156: error: Need type annotation for "queries" [var-annotated]
+ tools/lib/test_server.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool, str, Optional[str], bool], Iterator[None]]"; expected "Callable[[bool, str, Optional[str], bool], Generator[Any, Any, Any]]" [arg-type]
black (https://github.com/psf/black)
+ src/blib2to3/pgen2/parse.py:74:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder, int], Iterator[None]]"; expected "Callable[[Recorder, int], Generator[Any, Any, Any]]"
+ src/blib2to3/pgen2/parse.py:85:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder], Iterator[None]]"; expected "Callable[[Recorder], Generator[Any, Any, Any]]"
+ src/blib2to3/pgen2/driver.py:68:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[TokenProxy], Iterator[TokenProxy]]"; expected "Callable[[TokenProxy], Generator[Any, Any, Any]]"
+ src/black/__init__.py:1407:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[Any, Any, Any]]"
urllib3 (https://github.com/urllib3/urllib3)
+ test/test_response.py:965: error: Need type annotation for "fp" [var-annotated]
+ dummyserver/testcase.py:313: error: Need type annotation for "m" [var-annotated]
+ test/conftest.py:137: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:149: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:161: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:175: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:190: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:205: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:222: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:237: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:253: error: Need type annotation for "cfg" [var-annotated]
+ test/conftest.py:269: error: Need type annotation for "cfg" [var-annotated]
xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_backends_file_manager.py:218: error: <nothing> has no attribute "read" [attr-defined]
+ xarray/tests/test_distributed.py:166: error: Need type annotation for "filename" [var-annotated]
vision (https://github.com/pytorch/vision)
+ torchvision/datasets/imagenet.py:127: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[str]]"; expected "Callable[[], Generator[Any, Any, Any]]" [arg-type]
+ torchvision/datasets/imagenet.py:142: error: Need type annotation for "tmp_dir" [var-annotated]
isort (https://github.com/pycqa/isort)
+ isort/io.py:55: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path]], Iterator[File]]"; expected "Callable[[Union[str, Path]], Generator[Any, Any, Any]]"
+ isort/deprecated/finders.py:40: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[Any, Any, Any]]"
+ isort/api.py:337: error: Need type annotation for "source_file"
+ isort/api.py:353: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[TextIO]]"; expected "Callable[[], Generator[Any, Any, Any]]"
+ isort/api.py:358: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path], File], Iterator[TextIO]]"; expected "Callable[[Union[str, Path], File], Generator[Any, Any, Any]]"
+ isort/api.py:405: error: Need type annotation for "source_file"
+ isort/api.py:423: error: Need type annotation for "output_stream_context"
+ isort/api.py:591: error: Need type annotation for "source_file"
+ isort/pylama_isort.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[Any, Any, Any]]"
bokeh (https://github.com/bokeh/bokeh)
+ bokeh/embed/standalone.py:355:10: error: Need type annotation for "doc" [var-annotated]
+ bokeh/embed/standalone.py: note: In function "json_item":
+ bokeh/embed/standalone.py:426:10: error: Need type annotation for "doc" [var-annotated]
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/logging.py: note: In function "pending_logging":
+ sphinx/util/logging.py:271:14: error: Need type annotation for "memhandler"
+ sphinx/util/logging.py: note: In member "collect" of class "LogCollector":
+ sphinx/util/logging.py:349:14: error: Need type annotation for "memhandler"
optuna (https://github.com/optuna/optuna)
+ optuna/storages/_rdb/storage.py:229: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:252: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:271: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:302: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:315: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:328: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:336: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:344: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:352: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:360: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:370: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:380: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:391: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:402: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:538: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:650: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:676: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:724: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:739: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:769: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:796: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:822: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:843: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:864: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:883: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:907: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1005: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1023: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1085: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1111: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1159: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1196: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1256: error: Need type annotation for "session"
+ optuna/storages/_rdb/storage.py:1264: error: Need type annotation for "session"
+ tests/storages_tests/rdb_tests/test_storage.py:165: error: Need type annotation for "session"
+ tests/storages_tests/rdb_tests/test_storage.py:290: error: Need type annotation for "session"
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/test_utils.py:465: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Callable[[], AbstractEventLoop], bool], Iterator[AbstractEventLoop]]"; expected "Callable[[Callable[[], AbstractEventLoop], bool], Generator[Any, Any, Any]]" [arg-type]
+ aiohttp/pytest_plugin.py:186: error: Need type annotation for "_loop" [var-annotated]
+ aiohttp/pytest_plugin.py:235: error: Need type annotation for "_loop" [var-annotated]
+ aiohttp/pytest_plugin.py:247: error: Need type annotation for "_loop" [var-annotated]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/_config/localization.py:20: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Tuple[str, str]], int], Iterator[Union[str, Tuple[str, str]]]]"; expected "Callable[[Union[str, Tuple[str, str]], int], Generator[Any, Any, Any]]" [arg-type]
+ pandas/core/common.py:533: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, str, Any], Iterator[None]]"; expected "Callable[[Any, str, Any], Generator[Any, Any, Any]]" [arg-type]
+ pandas/io/formats/format.py:1201: error: Need type annotation for "f" [var-annotated]
+ pandas/core/groupby/groupby.py:999: error: Argument 1 to "contextmanager" has incompatible type "Callable[[GroupBy[NDFrameT]], Iterator[GroupBy[Any]]]"; expected "Callable[[GroupBy[NDFrameT]], Generator[Any, Any, Any]]" [arg-type]
+ pandas/_testing/_io.py:309: error: Need type annotation for "temp_path" [var-annotated]
+ pandas/io/formats/style.py:3796: error: <nothing> object is not iterable [misc]
+ pandas/io/formats/style.py:3801: error: Cannot determine type of "mpl" [has-type]
+ pandas/io/formats/style.py:3802: error: Cannot determine type of "plt" [has-type]
+ pandas/io/formats/style.py:3831: error: Cannot determine type of "mpl" [has-type]
+ pandas/io/formats/style.py:3834: error: Cannot determine type of "mpl" [has-type]
+ pandas/io/formats/style.py:4072: error: <nothing> object is not iterable [misc]
+ pandas/io/formats/style.py:4074: error: Cannot determine type of "mpl" [has-type]
+ pandas/io/formats/style.py:4078: error: Cannot determine type of "mpl" [has-type]
+ pandas/io/formats/style.py:4081: error: Cannot determine type of "mpl" [has-type]
+ pandas/io/formats/style.py:4083: error: Cannot determine type of "mpl" [has-type]
+ pandas/tests/io/pytables/test_categorical.py:219: error: Need type annotation for "path" [var-annotated]
edgedb (https://github.com/edgedb/edgedb)
+ edb/schema/delta.py:1445:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CommandContext], Iterator[CommandContext]]"; expected "Callable[[CommandContext], Generator[Any, Any, Any]]"
+ edb/edgeql/tracer.py:857:37: error: <nothing> has no attribute "schema"
+ edb/edgeql/tracer.py:859:13: error: <nothing> has no attribute "path_prefix"
+ edb/edgeql/tracer.py:862:14: error: Need type annotation for "nctx"
+ edb/edgeql/tracer.py:916:37: error: <nothing> has no attribute "schema"
+ edb/edgeql/tra```
Diff from mypy_primer, showing the effect of this PR on open source code:
pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/parser_generator.py:64: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/pegen/parser_generator.py:78: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
black (https://github.com/psf/black)
+ src/blib2to3/pgen2/parse.py:74:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder, int], Iterator[None]]"; expected "Callable[[Recorder, int], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/parse.py:85:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder], Iterator[None]]"; expected "Callable[[Recorder], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/driver.py:68:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[TokenProxy], Iterator[TokenProxy]]"; expected "Callable[[TokenProxy], Generator[<nothing>, Any, Any]]"
+ src/black/__init__.py:1407:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
jax (https://github.com/google/jax)
+ jax/_src/config.py:703: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:708: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:713: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:717: error: Need type annotation for "transfer_guard_host_to_device" [var-annotated]
+ jax/_src/config.py:718: error: Need type annotation for "transfer_guard_device_to_device" [var-annotated]
+ jax/_src/config.py:719: error: Need type annotation for "transfer_guard_device_to_host" [var-annotated]
+ jax/_src/config.py:720: error: Need type annotation for "transfer_guard" [var-annotated]
+ jax/_src/config.py:723: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:734: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:829: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:200: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:211: error: Argument 1 to "contextmanager" has incompatible type "Callable[[NameStack], Iterator[None]]"; expected "Callable[[NameStack], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:221: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:226: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
zulip (https://github.com/zulip/zulip)
+ zerver/lib/context_managers.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[int, IO[Any]], bool], Iterator[None]]"; expected "Callable[[Union[int, IO[Any]], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/context_managers.py:22: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, bool], Iterator[None]]"; expected "Callable[[str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/sqlalchemy_utils.py:24: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:132: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:155: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:85: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, Any], Iterator[None]]"; expected "Callable[[Any, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:94: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:115: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:183: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[IO[str]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:692: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, KwArg(object)], Iterator[MagicMock]]"; expected "Callable[[str, KwArg(object)], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:721: error: Need type annotation for "m" [var-annotated]
+ zerver/views/message_fetch.py:1051: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/views/message_fetch.py:1362: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/lib/test_classes.py:1181: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase], Iterator[None]]"; expected "Callable[[ZulipTestCase], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_classes.py:1424: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Iterator[None]]"; expected "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_users.py:795: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_users.py:1955: error: Need type annotation for "cache_queries" [var-annotated]
+ zerver/tests/test_subs.py:2203: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_subs.py:4478: error: Need type annotation for "cache_count" [var-annotated]
+ zerver/tests/test_subs.py:4587: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:869: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:1156: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_scim.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[SCIMTestCase, bool], Iterator[None]]"; expected "Callable[[SCIMTestCase, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_report.py:158: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_queue_worker.py:75: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FakeClient], Iterator[None]]"; expected "Callable[[FakeClient], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:871: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PushNotificationTest], Iterator[APNsContext]]"; expected "Callable[[PushNotificationTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:952: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1012: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1525: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1543: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1560: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:2447: error: Need type annotation for "mock_publish" [var-annotated]
+ zerver/tests/test_message_fetch.py:66: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:73: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:3022: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/tests/test_message_edit.py:1864: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_link_embed.py:392: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:423: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:465: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:576: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:609: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:680: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:712: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:747: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:785: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:822: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_external.py:77: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int, int, str], Iterator[None]]"; expected "Callable[[int, int, str], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:295: error: Argument 1 to "contextmanager" has incompatible type "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Iterator[Mock]]"; expected "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:344: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:360: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:378: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_event_queue.py:38: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_email_mirror.py:1385: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_digest.py:181: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_auth_backends.py:3177: error: Argument 1 to "contextmanager" has incompatible type "Callable[[AppleAuthBackendNativeFlowTest], Iterator[None]]"; expected "Callable[[AppleAuthBackendNativeFlowTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/management/commands/process_queue.py:19: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger, str, bool], Iterator[None]]"; expected "Callable[[Logger, str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_logging_handlers.py:203: error: Need type annotation for "m" [var-annotated]
+ tools/lib/test_server.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool, str, Optional[str], bool], Iterator[None]]"; expected "Callable[[bool, str, Optional[str], bool], Generator[<nothing>, Any, Any]]" [arg-type]
vision (https://github.com/pytorch/vision)
+ torchvision/datasets/imagenet.py:127: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[str]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ torchvision/datasets/imagenet.py:142: error: Need type annotation for "tmp_dir" [var-annotated]
anyio (https://github.com/agronholm/anyio)
+ src/anyio/pytest_plugin.py:27: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, Dict[str, Any]], Iterator[TestRunner]]"; expected "Callable[[str, Dict[str, Any]], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/anyio/pytest_plugin.py:62: error: Need type annotation for "runner" [var-annotated]
+ src/anyio/pytest_plugin.py:107: error: Need type annotation for "runner" [var-annotated]
+ src/anyio/pytest_plugin.py:126: error: Need type annotation for "runner" [var-annotated]
isort (https://github.com/pycqa/isort)
+ isort/io.py:55: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path]], Iterator[File]]"; expected "Callable[[Union[str, Path]], Generator[<nothing>, Any, Any]]"
+ isort/deprecated/finders.py:40: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]"
+ isort/api.py:337: error: Need type annotation for "source_file"
+ isort/api.py:353: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[TextIO]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ isort/api.py:358: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path], File], Iterator[TextIO]]"; expected "Callable[[Union[str, Path], File], Generator[<nothing>, Any, Any]]"
+ isort/api.py:405: error: Need type annotation for "source_file"
+ isort/api.py:423: error: Need type annotation for "output_stream_context"
+ isort/api.py:591: error: Need type annotation for "source_file"
+ isort/pylama_isort.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
edgedb (https://github.com/edgedb/edgedb)
+ edb/schema/delta.py:1445:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CommandContext], Iterator[CommandContext]]"; expected "Callable[[CommandContext], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1364:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1457:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1160:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder], Iterator[None]]"; expected "Callable[[PathFinder], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1164:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder, Optional[Expr], bool], Iterator[None]]"; expected "Callable[[PathFinder, Optional[Expr], bool], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:76:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path], Optional[Path]], Iterator[Path]]"; expected "Callable[[Optional[Path], Optional[Path]], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:442:24: error: Need type annotation for "runstate_dir_mgr"
pandas (https://github.com/pandas-dev/pandas)
+ pandas/_config/localization.py:20: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Tuple[str, str]], int], Iterator[Union[str, Tuple[str, str]]]]"; expected "Callable[[Union[str, Tuple[str, str]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/common.py:533: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, str, Any], Iterator[None]]"; expected "Callable[[Any, str, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/groupby/groupby.py:999: error: Argument 1 to "contextmanager" has incompatible type "Callable[[GroupBy[NDFrameT]], Iterator[GroupBy[Any]]]"; expected "Callable[[GroupBy[NDFrameT]], Generator[<nothing>, Any, Any]]" [arg-type]
mkosi (https://github.com/systemd/mkosi)
+ mkosi/backend.py:45:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int], Iterator[int]]"; expected "Callable[[int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:652:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:678:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:703:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:730:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:876:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Type[MkosiPrinter], str, Optional[str]], Iterator[List[Any]]]"; expected "Callable[[Type[MkosiPrinter], str, Optional[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:101:17: error: Need type annotation for "complete_step" [var-annotated]
+ mkosi/__init__.py:549:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[Path, str], int, int], Iterator[int]]"; expected "Callable[[Union[Path, str], int, int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:590:10: error: Need type annotation for "oldfd" [var-annotated]
+ mkosi/__init__.py:594:18: error: Need type annotation for "newfd" [var-annotated]
+ mkosi/__init__.py:683:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[None]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:923:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[BinaryIO]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[BinaryIO]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:942:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[Path]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:955:18: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:1157:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Partition, Path, Dict[str, str]], Iterator[Path]]"; expected "Callable[[Partition, Path, Dict[str, str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1275:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Optional[Path], bool], Iterator[LuksSetupOutput]]"; expected "Callable[[MkosiArgs, Optional[Path], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1471:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Iterator[None]]"; expected "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1559:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1574:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7004:10: error: Need type annotation for "base_image" [var-annotated]
+ mkosi/__init__.py:7005:10: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:7018:14: error: Need type annotation for "encrypted" [var-annotated]
+ mkosi/__init__.py:7103:21: error: Need type annotation for "mount" [var-annotated]
+ mkosi/__init__.py:7270:10: error: Need type annotation for "dir_fd" [var-annotated]
+ mkosi/__init__.py:7363:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7570:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[List[str]]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7663:10: error: Need type annotation for "cmdline" [var-annotated]
+ mkosi/gentoo.py:37:10: error: Need type annotation for "fd" [var-annotated]
poetry (https://github.com/python-poetry/poetry)
+ src/poetry/config/file_config_source.py:33: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:47: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:62: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FileConfigSource], Iterator[Any]]"; expected "Callable[[FileConfigSource], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/utils/helpers.py:41: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Any), KwArg(Any)], Iterator[str]]"; expected "Callable[[VarArg(Any), KwArg(Any)], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/repositories/pypi_repository.py:432: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/pypi_repository.py:445: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/legacy_repository.py:363: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/puzzle/provider.py:90: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider, Env], Iterator[Provider]]"; expected "Callable[[Provider, Env], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/provider.py:812: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider], Iterator[None]]"; expected "Callable[[Provider], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/solver.py:64: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Solver, Env], Iterator[None]]"; expected "Callable[[Solver, Env], Generator[<nothing>, Any, Any]]" [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/test_utils.py:465: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Callable[[], AbstractEventLoop], bool], Iterator[AbstractEventLoop]]"; expected "Callable[[Callable[[], AbstractEventLoop], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ aiohttp/pytest_plugin.py:235: error: Need type annotation for "_loop" [var-annotated]
+ aiohttp/pytest_plugin.py:247: error: Need type annotation for "_loop" [var-annotated]
asynq (https://github.com/quora/asynq)
+ asynq/debug.pyi:60: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool], Iterator[None]]"; expected "Callable[[bool], Generator[<nothing>, Any, Any]]"
bokeh (https://github.com/bokeh/bokeh)
+ bokeh/embed/standalone.py:355:10: error: Need type annotation for "doc" [var-annotated]
+ bokeh/embed/standalone.py: note: In function "json_item":
+ bokeh/embed/standalone.py:426:10: error: Need type annotation for "doc" [var-annotated]
pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
+ pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Generator[_T_co, Any, Any]], Tuple[Any, ...], Dict[str, Any]], None]")
- pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
+ pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Generator[_T_co, Any, Any]], Tuple[Any, ...], Dict[str, Any]], None]")
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/context.py:114: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Iterator[Context]]"; expected "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/tasks.py:207: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(str)], Iterator[None]]"; expected "Callable[[VarArg(str)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/configuration.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Dict[Any, Any]], Iterator[Any]]"; expected "Callable[[Dict[Any, Any]], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/base.py:18: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Executor], Iterator[None]]"; expected "Callable[[Executor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:204: error: Argument 1 to "contextmanager" has incompatible type "Callable[[DaskExecutor], Iterator[None]]"; expected "Callable[[DaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:559: error: Argument 1 to "contextmanager" has incompatible type "Callable[[LocalDaskExecutor], Iterator[Any]]"; expected "Callable[[LocalDaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:657: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:675: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:346: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Flow], Iterator[Flow]]"; expected "Callable[[Flow], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:373: error: Need type annotation for "_ctx"
+ src/prefect/utilities/executors.py:75: error: Need type annotation for "configured_heartbeat"
+ src/prefect/utilities/executors.py:89: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:95: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, Optional[int]], Iterator[None]]"; expected "Callable[[str, Optional[int]], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:106: error: Argument 1 to "contextmanager" has incompatible type "Callable[[List[str], Logger], Iterator[None]]"; expected "Callable[[List[str], Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:193: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger], Iterator[None]]"; expected "Callable[[Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/flow_runner.py:303: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FlowRunner], Iterator[Any]]"; expected "Callable[[FlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/cloud/flow_runner.py:168: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CloudFlowRunner], Iterator[Any]]"; expected "Callable[[CloudFlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/debug.py:71: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
spark (https://github.com/apache/spark)
+ python/pyspark/pandas/utils.py:488: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Dict[str, Any], DefaultNamedArg(Optional[SparkSession], 'spark')], Iterator[None]]"; expected "Callable[[Dict[str, Any], DefaultNamedArg(Optional[SparkSession], 'spark')], Generator[<nothing>, Any, Any]]" [arg-type]
+ python/pyspark/pandas/config.py:375: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Any)], Iterator[None]]"; expected "Callable[[VarArg(Any)], Generator[<nothing>, Any, Any]]" [arg-type]
mypy (https://github.com/python/mypy)
+ mypy/state.py:12: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool], Iterator[None]]"; expected "Callable[[bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/backports.py:14: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypyc/crash.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, int], Iterator[None]]"; expected "Callable[[str, int], Generator[<nothing>, A```
Diff from mypy_primer, showing the effect of this PR on open source code:
black (https://github.com/psf/black)
+ src/blib2to3/pgen2/parse.py:74:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder, int], Iterator[None]]"; expected "Callable[[Recorder, int], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/parse.py:85:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder], Iterator[None]]"; expected "Callable[[Recorder], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/driver.py:68:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[TokenProxy], Iterator[TokenProxy]]"; expected "Callable[[TokenProxy], Generator[<nothing>, Any, Any]]"
+ src/black/__init__.py:1407:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/parser_generator.py:64: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/pegen/parser_generator.py:78: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
jax (https://github.com/google/jax)
+ jax/_src/config.py:703: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:708: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:713: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:717: error: Need type annotation for "transfer_guard_host_to_device" [var-annotated]
+ jax/_src/config.py:718: error: Need type annotation for "transfer_guard_device_to_device" [var-annotated]
+ jax/_src/config.py:719: error: Need type annotation for "transfer_guard_device_to_host" [var-annotated]
+ jax/_src/config.py:720: error: Need type annotation for "transfer_guard" [var-annotated]
+ jax/_src/config.py:723: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:734: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:829: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:200: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:211: error: Argument 1 to "contextmanager" has incompatible type "Callable[[NameStack], Iterator[None]]"; expected "Callable[[NameStack], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:221: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:226: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
zulip (https://github.com/zulip/zulip)
+ zerver/lib/context_managers.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[int, IO[Any]], bool], Iterator[None]]"; expected "Callable[[Union[int, IO[Any]], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/context_managers.py:22: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, bool], Iterator[None]]"; expected "Callable[[str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/sqlalchemy_utils.py:24: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:132: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:155: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:85: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, Any], Iterator[None]]"; expected "Callable[[Any, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:94: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:115: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:183: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[IO[str]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:692: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, KwArg(object)], Iterator[MagicMock]]"; expected "Callable[[str, KwArg(object)], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:721: error: Need type annotation for "m" [var-annotated]
+ zerver/views/message_fetch.py:1051: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/views/message_fetch.py:1362: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/lib/test_classes.py:1181: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase], Iterator[None]]"; expected "Callable[[ZulipTestCase], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_classes.py:1424: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Iterator[None]]"; expected "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_users.py:795: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_users.py:1955: error: Need type annotation for "cache_queries" [var-annotated]
+ zerver/tests/test_subs.py:2203: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_subs.py:4478: error: Need type annotation for "cache_count" [var-annotated]
+ zerver/tests/test_subs.py:4587: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:869: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:1156: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_scim.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[SCIMTestCase, bool], Iterator[None]]"; expected "Callable[[SCIMTestCase, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_report.py:158: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_queue_worker.py:75: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FakeClient], Iterator[None]]"; expected "Callable[[FakeClient], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:871: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PushNotificationTest], Iterator[APNsContext]]"; expected "Callable[[PushNotificationTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:952: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1012: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1525: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1543: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1560: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:2447: error: Need type annotation for "mock_publish" [var-annotated]
+ zerver/tests/test_message_fetch.py:66: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:73: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:3022: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/tests/test_message_edit.py:1864: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_link_embed.py:392: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:423: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:465: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:576: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:609: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:680: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:712: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:747: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:785: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:822: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_external.py:77: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int, int, str], Iterator[None]]"; expected "Callable[[int, int, str], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:295: error: Argument 1 to "contextmanager" has incompatible type "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Iterator[Mock]]"; expected "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:344: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:360: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:378: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_event_queue.py:38: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_email_mirror.py:1385: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_digest.py:181: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_auth_backends.py:3177: error: Argument 1 to "contextmanager" has incompatible type "Callable[[AppleAuthBackendNativeFlowTest], Iterator[None]]"; expected "Callable[[AppleAuthBackendNativeFlowTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/management/commands/process_queue.py:19: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger, str, bool], Iterator[None]]"; expected "Callable[[Logger, str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_logging_handlers.py:203: error: Need type annotation for "m" [var-annotated]
+ tools/lib/test_server.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool, str, Optional[str], bool], Iterator[None]]"; expected "Callable[[bool, str, Optional[str], bool], Generator[<nothing>, Any, Any]]" [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/test_utils.py:465: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Callable[[], AbstractEventLoop], bool], Iterator[AbstractEventLoop]]"; expected "Callable[[Callable[[], AbstractEventLoop], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ aiohttp/pytest_plugin.py:235: error: Need type annotation for "_loop" [var-annotated]
+ aiohttp/pytest_plugin.py:247: error: Need type annotation for "_loop" [var-annotated]
poetry (https://github.com/python-poetry/poetry)
+ src/poetry/config/file_config_source.py:33: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:47: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:62: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FileConfigSource], Iterator[Any]]"; expected "Callable[[FileConfigSource], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/utils/helpers.py:41: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Any), KwArg(Any)], Iterator[str]]"; expected "Callable[[VarArg(Any), KwArg(Any)], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/repositories/pypi_repository.py:432: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/pypi_repository.py:445: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/legacy_repository.py:363: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/puzzle/provider.py:90: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider, Env], Iterator[Provider]]"; expected "Callable[[Provider, Env], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/provider.py:812: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider], Iterator[None]]"; expected "Callable[[Provider], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/solver.py:64: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Solver, Env], Iterator[None]]"; expected "Callable[[Solver, Env], Generator[<nothing>, Any, Any]]" [arg-type]
asynq (https://github.com/quora/asynq)
+ asynq/debug.pyi:60: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool], Iterator[None]]"; expected "Callable[[bool], Generator[<nothing>, Any, Any]]"
pandas (https://github.com/pandas-dev/pandas)
+ pandas/_config/localization.py:20: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Tuple[str, str]], int], Iterator[Union[str, Tuple[str, str]]]]"; expected "Callable[[Union[str, Tuple[str, str]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/common.py:533: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, str, Any], Iterator[None]]"; expected "Callable[[Any, str, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/groupby/groupby.py:999: error: Argument 1 to "contextmanager" has incompatible type "Callable[[GroupBy[NDFrameT]], Iterator[GroupBy[Any]]]"; expected "Callable[[GroupBy[NDFrameT]], Generator[<nothing>, Any, Any]]" [arg-type]
isort (https://github.com/pycqa/isort)
+ isort/io.py:55: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path]], Iterator[File]]"; expected "Callable[[Union[str, Path]], Generator[<nothing>, Any, Any]]"
+ isort/deprecated/finders.py:40: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]"
+ isort/api.py:337: error: Need type annotation for "source_file"
+ isort/api.py:353: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[TextIO]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ isort/api.py:358: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path], File], Iterator[TextIO]]"; expected "Callable[[Union[str, Path], File], Generator[<nothing>, Any, Any]]"
+ isort/api.py:405: error: Need type annotation for "source_file"
+ isort/api.py:423: error: Need type annotation for "output_stream_context"
+ isort/api.py:591: error: Need type annotation for "source_file"
+ isort/pylama_isort.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
mkosi (https://github.com/systemd/mkosi)
+ mkosi/backend.py:45:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int], Iterator[int]]"; expected "Callable[[int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:652:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:678:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:703:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:730:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:876:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Type[MkosiPrinter], str, Optional[str]], Iterator[List[Any]]]"; expected "Callable[[Type[MkosiPrinter], str, Optional[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:101:17: error: Need type annotation for "complete_step" [var-annotated]
+ mkosi/__init__.py:549:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[Path, str], int, int], Iterator[int]]"; expected "Callable[[Union[Path, str], int, int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:590:10: error: Need type annotation for "oldfd" [var-annotated]
+ mkosi/__init__.py:594:18: error: Need type annotation for "newfd" [var-annotated]
+ mkosi/__init__.py:683:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[None]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:923:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[BinaryIO]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[BinaryIO]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:942:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[Path]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:955:18: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:1157:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Partition, Path, Dict[str, str]], Iterator[Path]]"; expected "Callable[[Partition, Path, Dict[str, str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1275:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Optional[Path], bool], Iterator[LuksSetupOutput]]"; expected "Callable[[MkosiArgs, Optional[Path], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1471:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Iterator[None]]"; expected "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1559:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1574:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7004:10: error: Need type annotation for "base_image" [var-annotated]
+ mkosi/__init__.py:7005:10: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:7018:14: error: Need type annotation for "encrypted" [var-annotated]
+ mkosi/__init__.py:7103:21: error: Need type annotation for "mount" [var-annotated]
+ mkosi/__init__.py:7270:10: error: Need type annotation for "dir_fd" [var-annotated]
+ mkosi/__init__.py:7363:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7570:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[List[str]]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7663:10: error: Need type annotation for "cmdline" [var-annotated]
+ mkosi/gentoo.py:37:10: error: Need type annotation for "fd" [var-annotated]
anyio (https://github.com/agronholm/anyio)
+ src/anyio/pytest_plugin.py:27: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, Dict[str, Any]], Iterator[TestRunner]]"; expected "Callable[[str, Dict[str, Any]], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/anyio/pytest_plugin.py:62: error: Need type annotation for "runner" [var-annotated]
+ src/anyio/pytest_plugin.py:107: error: Need type annotation for "runner" [var-annotated]
+ src/anyio/pytest_plugin.py:126: error: Need type annotation for "runner" [var-annotated]
edgedb (https://github.com/edgedb/edgedb)
+ edb/schema/delta.py:1445:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CommandContext], Iterator[CommandContext]]"; expected "Callable[[CommandContext], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1364:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1457:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1160:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder], Iterator[None]]"; expected "Callable[[PathFinder], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1164:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder, Optional[Expr], bool], Iterator[None]]"; expected "Callable[[PathFinder, Optional[Expr], bool], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:76:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path], Optional[Path]], Iterator[Path]]"; expected "Callable[[Optional[Path], Optional[Path]], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:442:24: error: Need type annotation for "runstate_dir_mgr"
bokeh (https://github.com/bokeh/bokeh)
+ bokeh/embed/standalone.py:355:10: error: Need type annotation for "doc" [var-annotated]
+ bokeh/embed/standalone.py: note: In function "json_item":
+ bokeh/embed/standalone.py:426:10: error: Need type annotation for "doc" [var-annotated]
vision (https://github.com/pytorch/vision)
+ torchvision/datasets/imagenet.py:127: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[str]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ torchvision/datasets/imagenet.py:142: error: Need type annotation for "tmp_dir" [var-annotated]
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/context.py:114: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Iterator[Context]]"; expected "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/tasks.py:207: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(str)], Iterator[None]]"; expected "Callable[[VarArg(str)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/configuration.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Dict[Any, Any]], Iterator[Any]]"; expected "Callable[[Dict[Any, Any]], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/base.py:18: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Executor], Iterator[None]]"; expected "Callable[[Executor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:204: error: Argument 1 to "contextmanager" has incompatible type "Callable[[DaskExecutor], Iterator[None]]"; expected "Callable[[DaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:559: error: Argument 1 to "contextmanager" has incompatible type "Callable[[LocalDaskExecutor], Iterator[Any]]"; expected "Callable[[LocalDaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:657: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:675: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:346: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Flow], Iterator[Flow]]"; expected "Callable[[Flow], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:373: error: Need type annotation for "_ctx"
+ src/prefect/utilities/executors.py:75: error: Need type annotation for "configured_heartbeat"
+ src/prefect/utilities/executors.py:89: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:95: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, Optional[int]], Iterator[None]]"; expected "Callable[[str, Optional[int]], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:106: error: Argument 1 to "contextmanager" has incompatible type "Callable[[List[str], Logger], Iterator[None]]"; expected "Callable[[List[str], Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:193: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger], Iterator[None]]"; expected "Callable[[Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/flow_runner.py:303: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FlowRunner], Iterator[Any]]"; expected "Callable[[FlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/cloud/flow_runner.py:168: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CloudFlowRunner], Iterator[Any]]"; expected "Callable[[CloudFlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/debug.py:71: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
mypy (https://github.com/python/mypy)
+ mypy/state.py:12: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool], Iterator[None]]"; expected "Callable[[bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/backports.py:14: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypyc/crash.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, int], Iterator[None]]"; expected "Callable[[str, int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/scope.py:56: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Scope, str], Iterator[None]]"; expected "Callable[[Scope, str], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/scope.py:66: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Scope, FuncBase], Iterator[None]]"; expected "Callable[[Scope, FuncBase], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/scope.py:99: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Scope, TypeInfo], Iterator[None]]"; expected "Callable[[Scope, TypeInfo], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/scope.py:113: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Scope, Tuple[str, Optional[TypeInfo], Optional[FuncBase]]], Iterator[None]]"; expected "Callable[[Scope, Tuple[str, Optional[TypeInfo], Optional[FuncBase]]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/server/aststrip.py:232: error: Argument 1 to "contextmanager" has incompatible type "Callable[[NodeStripVisitor, TypeInfo], Iterator[None]]"; expected "Callable[[NodeStripVisitor, TypeInfo], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/server/aststrip.py:242: error: Argument 1 to "contextmanager" has incompatible type "Callable[[NodeStripVisitor, TypeInfo], Iterator[None]]"; expected "Callable[[NodeStripVisitor, TypeInfo], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/renaming.py:274: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VariableRenameVisitor], Iterator[None]]"; expected "Callable[[VariableRenameVisitor], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/renaming.py:284: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VariableRenameVisitor], Iterator[None]]"; expected "Callable[[VariableRenameVisitor],```
just to gauge impact here, while there's a lot of repositories with this mistake, the fix is pretty easy. here's black for instance:
$ git diff | cat
diff --git a/src/black/__init__.py b/src/black/__init__.py
index c4ec99b..e6f4e80 100644
--- a/src/black/__init__.py
+++ b/src/black/__init__.py
@@ -19,7 +19,6 @@ from typing import (
Any,
Dict,
Generator,
- Iterator,
List,
MutableMapping,
Optional,
@@ -1405,7 +1404,7 @@ def assert_stable(src: str, dst: str, mode: Mode) -> None:
@contextmanager
-def nullcontext() -> Iterator[None]:
+def nullcontext() -> Generator[None, None, None]:
"""Return an empty context manager.
To be used like `nullcontext` in Python 3.7.
diff --git a/src/blib2to3/pgen2/driver.py b/src/blib2to3/pgen2/driver.py
index 8fe8206..5f8a905 100644
--- a/src/blib2to3/pgen2/driver.py
+++ b/src/blib2to3/pgen2/driver.py
@@ -24,12 +24,12 @@ import sys
from typing import (
Any,
cast,
+ Generator,
IO,
Iterable,
List,
Optional,
Text,
- Iterator,
Tuple,
TypeVar,
Generic,
@@ -66,7 +66,7 @@ class TokenProxy:
self._release_ranges: List[ReleaseRange] = []
@contextmanager
- def release(self) -> Iterator["TokenProxy"]:
+ def release(self) -> Generator["TokenProxy", None, None]:
release_range = ReleaseRange(self._counter)
self._release_ranges.append(release_range)
try:
diff --git a/src/blib2to3/pgen2/parse.py b/src/blib2to3/pgen2/parse.py
index a9dc11f..f7c31bf 100644
--- a/src/blib2to3/pgen2/parse.py
+++ b/src/blib2to3/pgen2/parse.py
@@ -17,13 +17,13 @@ from . import grammar, token, tokenize
from typing import (
cast,
Any,
+ Generator,
Optional,
Text,
Union,
Tuple,
Dict,
List,
- Iterator,
Callable,
Set,
TYPE_CHECKING,
@@ -72,7 +72,7 @@ class Recorder:
return self._dead_ilabels.symmetric_difference(self._ilabels)
@contextmanager
- def switch_to(self, ilabel: int) -> Iterator[None]:
+ def switch_to(self, ilabel: int) -> Generator[None, None, None]:
with self.backtrack():
self.parser.stack = self._points[ilabel]
try:
@@ -83,7 +83,7 @@ class Recorder:
self.parser.stack = self._start_point
@contextmanager
- def backtrack(self) -> Iterator[None]:
+ def backtrack(self) -> Generator[None, None, None]:
"""
Use the node-level invariant ones for basic parsing operations (push/pop/shift).
These still will operate on the stack; but they won't create any new nodes, or
Arguably the mypy docs would also have to be updated:
A basic generator that only yields values can be succinctly annotated as having a return type of either
Iterator[YieldType]orIterable[YieldType].
There's also similar guidance in the CPython docs for typing.Generator.
Arguably the mypy docs would also have to be updated:
A basic generator that only yields values can be succinctly annotated as having a return type of either
Iterator[YieldType]orIterable[YieldType].There's also similar guidance in the CPython docs for
typing.Generator.
I don't think either of those need updates -- this is specifically for context managers (the problem here is a Generator is an Iterator, but an Iterator is not a Generator)
I know this is quite controversial, but I would like to see this go in rather sooner than later. The longer we wait the worse it gets, and our stubs are arguably wrong.
I also agree we should do this, but it's definitely going to be quite disruptive. mypy-primer is only going to show a fraction of the real-world code that needs to be changed.
I agree with @AlexWaygood that we should call this out explicitly in the mypy and typing docs; @contextmanager is one of the most common uses of generators and people will get confused by this error. I can help get these docs updates merged.
@asottile do you think it's possible to provide a codemod that fixes these annotations?
^I started typing out a response, but (as is so often the case) @JelleZijlstra beat me to it, and I agree with everything he said :)
I also agree we should do this, but it's definitely going to be quite disruptive. mypy-primer is only going to show a fraction of the real-world code that needs to be changed.
I agree with @AlexWaygood that we should call this out explicitly in the mypy and typing docs;
@contextmanageris one of the most common uses of generators and people will get confused by this error. I can help get these docs updates merged.@asottile do you think it's possible to provide a codemod that fixes these annotations?
here's the start of one, based on the approach outlined here (same as pyupgrade / add-trailing-comma / yesqa / etc. work):
from __future__ import annotations
import argparse
import ast
import sys
from typing import Sequence
import tokenize_rt
def is_ctxmanager(node: ast.AST, name: str) -> bool:
return (
isinstance(node, ast.Name) and node.id == name
) or (
isinstance(node, ast.Attribute) and
node.attr == name and
# simple name, might be an aliased import :shrugs:
isinstance(node.value, ast.Name)
)
def is_iterator(node: ast.AST, name: str) -> bool:
return (
isinstance(node, ast.Subscript) and (
(
isinstance(node.value, ast.Name) and
node.value.id == name
) or (
isinstance(node.value, ast.Attribute) and
node.value.attr == name and
# simple name, might be an aliased import :shrugs:
isinstance(node.value.value, ast.Name)
)
)
)
class Visitor(ast.NodeVisitor):
def __init__(self) -> None:
self.iter_to_generator: set[tokenize_rt.Offset] = set()
self.aiter_to_agenerator: set[tokenize_rt.Offset] = set()
def visit_FunctionDef(self, node: ast.FunctionDef) -> None:
if (
len(node.decorator_list) == 1 and
is_ctxmanager(node.decorator_list[0], 'contextmanager') and
node.returns is not None and
is_iterator(node.returns, 'Iterator')
):
offset = tokenize_rt.Offset(
node.returns.lineno,
node.returns.col_offset,
)
self.iter_to_generator.add(offset)
self.generic_visit(node)
def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None:
if (
len(node.decorator_list) == 1 and
is_ctxmanager(node.decorator_list[0], 'asynccontextmanager') and
node.returns is not None and
is_iterator(node.returns, 'AsyncIterator')
):
offset = tokenize_rt.Offset(
node.returns.lineno,
node.returns.col_offset,
)
self.aiter_to_agenerator.add(offset)
self.generic_visit(node)
def _fix(
i: int,
tokens: list[tokenize_rt.Token],
n: int,
orig: str,
dest: str,
) -> None:
j = i
try:
while tokens[i].src != orig:
i += 1
except Exception:
breakpoint()
raise
tokens[i] = tokens[i]._replace(src=dest)
while tokens[i].src != '[':
i += 1
i += 1
depth = 1
while depth:
if tokens[i].src in '([{':
depth += 1
elif tokens[i].src in ')]}':
depth -= 1
i += 1
tokens[i - 1] = tokens[i - 1]._replace(src=f'{", None" * n}]')
def _fix_file(filename: str) -> int:
with open(filename, 'rb') as fb:
contents_bytes = fb.read()
try:
contents_text_orig = contents_text = contents_bytes.decode()
except UnicodeDecodeError:
print(f'{filename} is non-utf-8 (not supported)')
return 1
tree = ast.parse(contents_text, filename=filename)
visitor = Visitor()
visitor.visit(tree)
if not visitor.iter_to_generator and not visitor.aiter_to_agenerator:
return 0
tokens = tokenize_rt.src_to_tokens(contents_text)
for i, token in tokenize_rt.reversed_enumerate(tokens):
if token.offset in visitor.iter_to_generator:
_fix(i, tokens, n=2, orig='Iterator', dest='Generator')
elif token.offset in visitor.aiter_to_agenerator:
_fix(i, tokens, n=1, orig='AsyncIterator', dest='AsyncGenerator')
contents_text = tokenize_rt.tokens_to_src(tokens)
if contents_text == contents_text_orig:
return 0
print(f'Rewriting {filename}')
with open(filename, 'w', encoding='UTF-8', newline='') as f:
f.write(contents_text)
return 1
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
args = parser.parse_args(argv)
if sys.version_info < (3, 10):
raise SystemExit(
'this script makes some assumptions about ast.Subscript and '
'needs python 3.10+',
)
ret = 0
for filename in args.filenames:
ret |= _fix_file(filename)
return ret
if __name__ == '__main__':
raise SystemExit(main())
it doesn't fix the imports, but that's tricky to do accurately and with respecting the user's style
import contextlib
from contextlib import contextmanager
from contextlib import asynccontextmanager
from typing import AsyncIterator, Iterator
import typing
import typing as t
def fn_unrelated() -> Iterator[None]:
yield
@contextlib.contextmanager
def ctx1() -> Iterator[None]:
yield
@contextmanager
def ctx2() -> Iterator[None]:
yield
@contextlib.asynccontextmanager
async def ctx3() -> AsyncIterator[None]:
yield
@asynccontextmanager
async def ctx4() -> AsyncIterator[None]:
yield
@contextlib.contextmanager
def ctx5() -> typing.Iterator[None]:
yield
@contextlib.contextmanager
def ctx6() -> t.Iterator[None]:
yield
$ diff -u t2.py.bak t2.py
--- t2.py.bak 2022-03-03 14:24:22.591697064 -0500
+++ t2.py 2022-03-03 14:42:18.439722185 -0500
@@ -10,25 +10,25 @@
yield
@contextlib.contextmanager
-def ctx1() -> Iterator[None]:
+def ctx1() -> Generator[None, None, None]:
yield
@contextmanager
-def ctx2() -> Iterator[None]:
+def ctx2() -> Generator[None, None, None]:
yield
@contextlib.asynccontextmanager
-async def ctx3() -> AsyncIterator[None]:
+async def ctx3() -> AsyncGenerator[None, None]:
yield
@asynccontextmanager
-async def ctx4() -> AsyncIterator[None]:
+async def ctx4() -> AsyncGenerator[None, None]:
yield
@contextlib.contextmanager
-def ctx5() -> typing.Iterator[None]:
+def ctx5() -> typing.Generator[None, None, None]:
yield
@contextlib.contextmanager
-def ctx6() -> t.Iterator[None]:
+def ctx6() -> t.Generator[None, None, None]:
yield
Seems like I'm in the minority, but I'm -1 on this.
Breaking almost every use case of contextmanager for something pretty niche is too much for me.
Other than your reports, I haven't encountered instances of people running into this. There are zero emojis on the issue report. There are two out links, neither of which seems to actually have the bug in question. Maybe a failure of my imagination, but I'm also struggling to think of the real world code that motivates someone to return an iterator here.
On the other hand, it's very common for users with correct code to get confused when adding types for Iterable, Iterator, Generator. By steering users to use the scary and not ergonomic Generator, this is a real loss of usability in the 99.99% use case going forward as well. There's a reason there's so much code out there that this would break.
It's a shame we don't have something like the following construct in typing.py:
_T_co = TypeVar("_T_co", covariant=True)
SimpleGenerator = Generator[_T_co, None, None]
Returning SimpleGenerator[_T_co] from these functions would be much more correct than returning Iterator[_T_co], and much more user-friendly than having to type out Generator[_T_co, None, None] every time.
it would be a bit nicer if we had TypeVar defaults so we could just write Generator[T].
Also note that a linter could warn for contextmanager decorated functions that don't yield. Could be a good check to add to pylint or flake8-bugbear. Since this wouldn't look at annotations, it'd side step the issue of forcing users to change their annotations.
the case I had would not have been detected by that -- it returned an iterable from another function call. I think this really needs type checkers to do the proper thing
the case I had would not have been detected by that -- it returned an iterable from another function call. I think this really needs type checkers to do the proper thing
@asottile I'm not sure I understand. If you have a function like this:
@contextmanager
def func():
return other_generator_function()
Then a flake8 plugin could easily require that you do this instead, ensuring type safety:
@contextmanager
def func():
yield from other_generator_function()
It doesn't need to do any fancy guesswork about whether other_generator_function is actually a generator function, it just needs to make sure that func yields somewhere, no?
We can agree that this would definitely be an imperfect solution, but it would be far less disruptive.
Generator[T] isn't great, because typing.py in standard library of released Pythons doesn't support it at runtime, and most people don't use from __future__ import annotations. This means we're stuck with Iterator[T] or Generator[T, None, None].
I prefer Iterator[T] because it's simple. You should not have to know about sending anything into a generator just to make a context manager, and having to know about iterators is already confusing enough. To me, Iterator[T] satisfies "practicality beats purity", "simple is better than complex", and also "prefer false negatives".
Another possible solution would be mypy automatically inferring the correct return type for functions that yield, but I don't think that's ever going to happen because mypy has a concept of typed and untyped functions, and def foo(): is untyped, regardless of whether or not it has decorators.
I prefer
Iterator[T]because it's simple.
But it's also confusing. A generator function return a generator after all (which happens to be an iterator as well).
You really shouldn't have to care. The type annotation in this case should IMO be something simple that doesn't get in the way, not something full of None, None that makes you stop and think about it carefully.
I'm still in favor of allowing Generator[X] for cases like this. Iterator[X] is just the wrong annotation and as this discussion shows problematic in some cases.
@asottile could you share more thoughts on why your case couldn't be caught by a simple and much less disruptive new linter check? It's unclear to at least Alex and I, see https://github.com/python/typeshed/pull/7430#issuecomment-1059053121
@hauntsaninja I addressed that here: https://github.com/python/typeshed/pull/7430#issuecomment-1058622386
additionally, the recommendation also does not work for async where there's no yield from or when there's branching logic (both of which are needed for the use case at work which caused an outage)
Diff from mypy_primer, showing the effect of this PR on open source code:
black (https://github.com/psf/black)
+ src/blib2to3/pgen2/parse.py:74:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder, int], Iterator[None]]"; expected "Callable[[Recorder, int], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/parse.py:85:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder], Iterator[None]]"; expected "Callable[[Recorder], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/driver.py:68:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[TokenProxy], Iterator[TokenProxy]]"; expected "Callable[[TokenProxy], Generator[<nothing>, Any, Any]]"
+ src/black/__init__.py:1407:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
jax (https://github.com/google/jax)
+ jax/_src/config.py:703: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:708: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:713: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:717: error: Need type annotation for "transfer_guard_host_to_device" [var-annotated]
+ jax/_src/config.py:718: error: Need type annotation for "transfer_guard_device_to_device" [var-annotated]
+ jax/_src/config.py:719: error: Need type annotation for "transfer_guard_device_to_host" [var-annotated]
+ jax/_src/config.py:720: error: Need type annotation for "transfer_guard" [var-annotated]
+ jax/_src/config.py:723: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:734: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:829: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:195: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:206: error: Argument 1 to "contextmanager" has incompatible type "Callable[[NameStack], Iterator[None]]"; expected "Callable[[NameStack], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:216: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:221: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
zulip (https://github.com/zulip/zulip)
+ zerver/lib/context_managers.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[int, IO[Any]], bool], Iterator[None]]"; expected "Callable[[Union[int, IO[Any]], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/context_managers.py:22: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, bool], Iterator[None]]"; expected "Callable[[str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/sqlalchemy_utils.py:24: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:132: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:155: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:85: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, Any], Iterator[None]]"; expected "Callable[[Any, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:94: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:115: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:183: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[IO[str]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:692: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, KwArg(object)], Iterator[MagicMock]]"; expected "Callable[[str, KwArg(object)], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:721: error: Need type annotation for "m" [var-annotated]
+ zerver/views/message_fetch.py:1051: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/views/message_fetch.py:1362: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/lib/test_classes.py:1183: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase], Iterator[None]]"; expected "Callable[[ZulipTestCase], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_classes.py:1426: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Iterator[None]]"; expected "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_users.py:813: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_users.py:1991: error: Need type annotation for "cache_queries" [var-annotated]
+ zerver/tests/test_subs.py:2205: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_subs.py:4483: error: Need type annotation for "cache_count" [var-annotated]
+ zerver/tests/test_subs.py:4592: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:869: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:1158: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_scim.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[SCIMTestCase, bool], Iterator[None]]"; expected "Callable[[SCIMTestCase, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_report.py:158: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_queue_worker.py:75: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FakeClient], Iterator[None]]"; expected "Callable[[FakeClient], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:885: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PushNotificationTest], Iterator[APNsContext]]"; expected "Callable[[PushNotificationTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:982: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1044: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1583: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1601: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1618: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:2504: error: Need type annotation for "mock_publish" [var-annotated]
+ zerver/tests/test_message_fetch.py:66: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:73: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:3022: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/tests/test_message_edit.py:2084: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_link_embed.py:392: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:423: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:465: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:576: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:609: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:680: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:712: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:747: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:785: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:822: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_external.py:77: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int, int, str], Iterator[None]]"; expected "Callable[[int, int, str], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:295: error: Argument 1 to "contextmanager" has incompatible type "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Iterator[Mock]]"; expected "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:344: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:360: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:378: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_event_queue.py:38: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_event_queue.py:44: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_event_queue.py:60: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_email_mirror.py:1385: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_digest.py:181: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_auth_backends.py:3168: error: Argument 1 to "contextmanager" has incompatible type "Callable[[AppleAuthBackendNativeFlowTest], Iterator[None]]"; expected "Callable[[AppleAuthBackendNativeFlowTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/management/commands/process_queue.py:19: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger, str, bool], Iterator[None]]"; expected "Callable[[Logger, str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_logging_handlers.py:203: error: Need type annotation for "m" [var-annotated]
+ tools/lib/test_server.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool, str, Optional[str], bool], Iterator[None]]"; expected "Callable[[bool, str, Optional[str], bool], Generator[<nothing>, Any, Any]]" [arg-type]
pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/parser_generator.py:64: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/pegen/parser_generator.py:78: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
vision (https://github.com/pytorch/vision)
+ torchvision/datasets/imagenet.py:127: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[str]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ torchvision/datasets/imagenet.py:142: error: Need type annotation for "tmp_dir" [var-annotated]
bokeh (https://github.com/bokeh/bokeh)
+ bokeh/embed/standalone.py:346:10: error: Need type annotation for "doc" [var-annotated]
+ bokeh/embed/standalone.py: note: In function "json_item":
+ bokeh/embed/standalone.py:417:10: error: Need type annotation for "doc" [var-annotated]
asynq (https://github.com/quora/asynq)
+ asynq/debug.pyi:60: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool], Iterator[None]]"; expected "Callable[[bool], Generator[<nothing>, Any, Any]]"
pandas (https://github.com/pandas-dev/pandas)
+ pandas/_config/localization.py:20: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Tuple[str, str]], int], Iterator[Union[str, Tuple[str, str]]]]"; expected "Callable[[Union[str, Tuple[str, str]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/common.py:533: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, str, Any], Iterator[None]]"; expected "Callable[[Any, str, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/groupby/groupby.py:1001: error: Argument 1 to "contextmanager" has incompatible type "Callable[[GroupBy[NDFrameT]], Iterator[GroupBy[Any]]]"; expected "Callable[[GroupBy[NDFrameT]], Generator[<nothing>, Any, Any]]" [arg-type]
edgedb (https://github.com/edgedb/edgedb)
+ edb/schema/delta.py:1458:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CommandContext], Iterator[CommandContext]]"; expected "Callable[[CommandContext], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1332:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1425:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1173:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder], Iterator[None]]"; expected "Callable[[PathFinder], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1177:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder, Optional[Expr], bool], Iterator[None]]"; expected "Callable[[PathFinder, Optional[Expr], bool], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:76:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path], Optional[Path]], Iterator[Path]]"; expected "Callable[[Optional[Path], Optional[Path]], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:443:24: error: Need type annotation for "runstate_dir_mgr"
isort (https://github.com/pycqa/isort)
+ isort/io.py:55: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path]], Iterator[File]]"; expected "Callable[[Union[str, Path]], Generator[<nothing>, Any, Any]]"
+ isort/deprecated/finders.py:40: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]"
+ isort/api.py:337: error: Need type annotation for "source_file"
+ isort/api.py:353: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[TextIO]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ isort/api.py:358: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path], File], Iterator[TextIO]]"; expected "Callable[[Union[str, Path], File], Generator[<nothing>, Any, Any]]"
+ isort/api.py:405: error: Need type annotation for "source_file"
+ isort/api.py:423: error: Need type annotation for "output_stream_context"
+ isort/api.py:591: error: Need type annotation for "source_file"
+ isort/pylama_isort.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
mkosi (https://github.com/systemd/mkosi)
+ mkosi/backend.py:45:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int], Iterator[int]]"; expected "Callable[[int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:652:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:678:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:703:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:730:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:876:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Type[MkosiPrinter], str, Optional[str]], Iterator[List[Any]]]"; expected "Callable[[Type[MkosiPrinter], str, Optional[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:101:17: error: Need type annotation for "complete_step" [var-annotated]
+ mkosi/__init__.py:549:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[Path, str], int, int], Iterator[int]]"; expected "Callable[[Union[Path, str], int, int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:590:10: error: Need type annotation for "oldfd" [var-annotated]
+ mkosi/__init__.py:594:18: error: Need type annotation for "newfd" [var-annotated]
+ mkosi/__init__.py:598:18: error: Need type annotation for "newfd" [var-annotated]
+ mkosi/__init__.py:683:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[None]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:923:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[BinaryIO]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[BinaryIO]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:942:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[Path]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:955:18: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:1157:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Partition, Path, Dict[str, str]], Iterator[Path]]"; expected "Callable[[Partition, Path, Dict[str, str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1275:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Optional[Path], bool], Iterator[LuksSetupOutput]]"; expected "Callable[[MkosiArgs, Optional[Path], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1471:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Iterator[None]]"; expected "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1559:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1574:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7004:10: error: Need type annotation for "base_image" [var-annotated]
+ mkosi/__init__.py:7005:10: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:7018:14: error: Need type annotation for "encrypted" [var-annotated]
+ mkosi/__init__.py:7103:21: error: Need type annotation for "mount" [var-annotated]
+ mkosi/__init__.py:7270:10: error: Need type annotation for "dir_fd" [var-annotated]
+ mkosi/__init__.py:7363:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7574:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[List[str]]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7667:10: error: Need type annotation for "cmdline" [var-annotated]
+ mkosi/gentoo.py:37:10: error: Need type annotation for "fd" [var-annotated]
poetry (https://github.com/python-poetry/poetry)
+ src/poetry/config/file_config_source.py:33: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:47: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:62: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FileConfigSource], Iterator[Any]]"; expected "Callable[[FileConfigSource], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/utils/helpers.py:41: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Any), KwArg(Any)], Iterator[str]]"; expected "Callable[[VarArg(Any), KwArg(Any)], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/repositories/pypi_repository.py:432: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/pypi_repository.py:445: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/legacy_repository.py:363: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/puzzle/provider.py:90: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider, Env], Iterator[Provider]]"; expected "Callable[[Provider, Env], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/provider.py:812: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider], Iterator[None]]"; expected "Callable[[Provider], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/solver.py:63: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Solver, Env], Iterator[None]]"; expected "Callable[[Solver, Env], Generator[<nothing>, Any, Any]]" [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/test_utils.py:465: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Callable[[], AbstractEventLoop], bool], Iterator[AbstractEventLoop]]"; expected "Callable[[Callable[[], AbstractEventLoop], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ aiohttp/pytest_plugin.py:235: error: Need type annotation for "_loop" [var-annotated]
+ aiohttp/pytest_plugin.py:247: error: Need type annotation for "_loop" [var-annotated]
pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
+ pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Generator[_T_co, Any, Any]], Tuple[Any, ...], Dict[str, Any]], None]")
- pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
+ pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Generator[_T_co, Any, Any]], Tuple[Any, ...], Dict[str, Any]], None]")
schema_salad (https://github.com/common-workflow-language/schema_salad)
+ schema_salad/tests/test_cli_args.py:11:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Tuple[StringIO, StringIO]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ schema_salad/tests/test_cli_args.py: note: In function "test_version":
+ schema_salad/tests/test_cli_args.py:25:14: error: <nothing> object is not iterable [misc]
+ schema_salad/tests/test_cli_args.py:28:20: error: Cannot determine type of "out" [has-type]
+ schema_salad/tests/test_cli_args.py: note: In function "test_empty_input":
+ schema_salad/tests/test_cli_args.py:35:10: error: <nothing> object is not iterable [misc]
+ schema_salad/tests/test_cli_args.py:38:16: error: Cannot determine type of "out" [has-type]
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/context.py:114: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Iterator[Context]]"; expected "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/tasks.py:207: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(str)], Iterator[None]]"; expected "Callable[[VarArg(str)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/configuration.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Dict[Any, Any]], Iterator[Any]]"; expected "Callable[[Dict[Any, Any]], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/base.py:18: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Executor], Iterator[None]]"; expected "Callable[[Executor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:204: error: Argument 1 to "contextmanager" has incompatible type "Callable[[DaskExecutor], Iterator[None]]"; expected "Callable[[DaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:559: error: Argument 1 to "contextmanager" has incompatible type "Callable[[LocalDaskExecutor], Iterator[Any]]"; expected "Callable[[LocalDaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:657: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:675: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:346: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Flow], Iterator[Flow]]"; expected "Callable[[Flow], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:373: error: Need type annotation for "_ctx"
+ src/prefect/utilities/executors.py:75: error: Need type annotation for "configured_heartbeat"
+ src/prefect/utilities/executors.py:89: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:95: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, Optional[int]], Iterator[None]]"; expected "Callable[[str, Optional[int]], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:106: error: Argument 1 to "contextmanager" has incompatible type "Callable[[List[str], Logger], Iterator[None]]"; expected "Callable[[List[str], Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:193: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger], Iterator[None]]"; expected "Callable[[Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/flow_runner.py:303: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FlowRunner], Iterator[Any]]"; expected "Callable[[FlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/cloud/flow_runner.py:168: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CloudFlowRunner], Iterator[Any]]"; expected "Callable[[CloudFlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/debug.py:71: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
spark (https://github.com/apache/spark)
+ python/pyspark/pandas/utils.py:488: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Dict[str, Any], DefaultNamedArg(Optional[SparkSession], 'spark')], Iterator[None]]"; expected "Callable[[Dict[str, Any], DefaultNamedArg(Optional[SparkSession], 'spark')], Generator[<nothing>, Any, Any]]" [arg-type]
+ python/pyspark/pandas/config.py:375: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Any)], Iterator[None]]"; expected "Callable[[VarArg(Any)], Generator[<nothing>, Any, Any]]" [arg-type]
c```
Diff from mypy_primer, showing the effect of this PR on open source code:
black (https://github.com/psf/black)
+ src/blib2to3/pgen2/parse.py:74:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder, int], Iterator[None]]"; expected "Callable[[Recorder, int], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/parse.py:85:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Recorder], Iterator[None]]"; expected "Callable[[Recorder], Generator[<nothing>, Any, Any]]"
+ src/blib2to3/pgen2/driver.py:68:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[TokenProxy], Iterator[TokenProxy]]"; expected "Callable[[TokenProxy], Generator[<nothing>, Any, Any]]"
+ src/black/__init__.py:1407:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
zulip (https://github.com/zulip/zulip)
+ zerver/lib/context_managers.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[int, IO[Any]], bool], Iterator[None]]"; expected "Callable[[Union[int, IO[Any]], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/context_managers.py:22: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, bool], Iterator[None]]"; expected "Callable[[str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/sqlalchemy_utils.py:24: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:132: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_console_output.py:155: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ExtraConsoleOutputFinder], Iterator[None]]"; expected "Callable[[ExtraConsoleOutputFinder], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:85: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, Any], Iterator[None]]"; expected "Callable[[Any, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:94: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:115: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[List[Tuple[str, Union[str, List[str]], Optional[str]]]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:183: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[IO[str]]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:692: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, KwArg(object)], Iterator[MagicMock]]"; expected "Callable[[str, KwArg(object)], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_helpers.py:721: error: Need type annotation for "m" [var-annotated]
+ zerver/views/message_fetch.py:1051: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/views/message_fetch.py:1362: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/lib/test_classes.py:1183: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase], Iterator[None]]"; expected "Callable[[ZulipTestCase], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/lib/test_classes.py:1426: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Iterator[None]]"; expected "Callable[[ZulipTestCase, List[Mapping[str, Any]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_users.py:813: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_users.py:1991: error: Need type annotation for "cache_queries" [var-annotated]
+ zerver/tests/test_subs.py:2205: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_subs.py:4483: error: Need type annotation for "cache_count" [var-annotated]
+ zerver/tests/test_subs.py:4592: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:869: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_signup.py:1158: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_scim.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[SCIMTestCase, bool], Iterator[None]]"; expected "Callable[[SCIMTestCase, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_report.py:158: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_queue_worker.py:75: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FakeClient], Iterator[None]]"; expected "Callable[[FakeClient], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:885: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PushNotificationTest], Iterator[APNsContext]]"; expected "Callable[[PushNotificationTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_push_notifications.py:982: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1044: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1583: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1601: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:1618: error: Need type annotation for "apns_context" [var-annotated]
+ zerver/tests/test_push_notifications.py:2504: error: Need type annotation for "mock_publish" [var-annotated]
+ zerver/tests/test_message_fetch.py:66: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:73: error: Need type annotation for "conn" [var-annotated]
+ zerver/tests/test_message_fetch.py:3022: error: Need type annotation for "sa_conn" [var-annotated]
+ zerver/tests/test_message_edit.py:2084: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_link_embed.py:392: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:423: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:465: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:576: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:609: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:680: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:712: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:747: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:785: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_link_embed.py:822: error: Need type annotation for "patched" [var-annotated]
+ zerver/tests/test_external.py:77: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int, int, str], Iterator[None]]"; expected "Callable[[int, int, str], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:295: error: Argument 1 to "contextmanager" has incompatible type "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Iterator[Mock]]"; expected "Callable[[RateLimitTests, Optional[Exception], Sequence[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_external.py:344: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:360: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_external.py:378: error: Need type annotation for "tor_open" [var-annotated]
+ zerver/tests/test_event_queue.py:38: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_event_queue.py:44: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_event_queue.py:60: error: Need type annotation for "mock_queue_json_publish" [var-annotated]
+ zerver/tests/test_email_mirror.py:1385: error: Need type annotation for "m" [var-annotated]
+ zerver/tests/test_digest.py:181: error: Need type annotation for "cache_tries" [var-annotated]
+ zerver/tests/test_auth_backends.py:3168: error: Argument 1 to "contextmanager" has incompatible type "Callable[[AppleAuthBackendNativeFlowTest], Iterator[None]]"; expected "Callable[[AppleAuthBackendNativeFlowTest], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/management/commands/process_queue.py:19: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger, str, bool], Iterator[None]]"; expected "Callable[[Logger, str, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ zerver/tests/test_logging_handlers.py:203: error: Need type annotation for "m" [var-annotated]
+ tools/lib/test_server.py:54: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool, str, Optional[str], bool], Iterator[None]]"; expected "Callable[[bool, str, Optional[str], bool], Generator[<nothing>, Any, Any]]" [arg-type]
pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/parser_generator.py:64: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/pegen/parser_generator.py:78: error: Argument 1 to "contextmanager" has incompatible type "Callable[[ParserGenerator], Iterator[None]]"; expected "Callable[[ParserGenerator], Generator[<nothing>, Any, Any]]" [arg-type]
jax (https://github.com/google/jax)
+ jax/_src/config.py:703: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:708: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:713: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:717: error: Need type annotation for "transfer_guard_host_to_device" [var-annotated]
+ jax/_src/config.py:718: error: Need type annotation for "transfer_guard_device_to_device" [var-annotated]
+ jax/_src/config.py:719: error: Need type annotation for "transfer_guard_device_to_host" [var-annotated]
+ jax/_src/config.py:720: error: Need type annotation for "transfer_guard" [var-annotated]
+ jax/_src/config.py:723: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:734: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/config.py:829: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:195: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:206: error: Argument 1 to "contextmanager" has incompatible type "Callable[[NameStack], Iterator[None]]"; expected "Callable[[NameStack], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:216: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ jax/_src/source_info_util.py:221: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[NameStack]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]" [arg-type]
mkosi (https://github.com/systemd/mkosi)
+ mkosi/backend.py:45:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[int], Iterator[int]]"; expected "Callable[[int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:652:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:678:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/backend.py:703:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:730:10: error: Need type annotation for "cm" [var-annotated]
+ mkosi/backend.py:876:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Type[MkosiPrinter], str, Optional[str]], Iterator[List[Any]]]"; expected "Callable[[Type[MkosiPrinter], str, Optional[str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:101:17: error: Need type annotation for "complete_step" [var-annotated]
+ mkosi/__init__.py:549:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[Path, str], int, int], Iterator[int]]"; expected "Callable[[Union[Path, str], int, int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:590:10: error: Need type annotation for "oldfd" [var-annotated]
+ mkosi/__init__.py:594:18: error: Need type annotation for "newfd" [var-annotated]
+ mkosi/__init__.py:598:18: error: Need type annotation for "newfd" [var-annotated]
+ mkosi/__init__.py:683:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[None]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:923:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[BinaryIO]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[BinaryIO]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:942:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path]], Iterator[Optional[Path]]]"; expected "Callable[[Optional[Path]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:955:18: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:1157:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Partition, Path, Dict[str, str]], Iterator[Path]]"; expected "Callable[[Partition, Path, Dict[str, str]], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1275:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Optional[Path], bool], Iterator[LuksSetupOutput]]"; expected "Callable[[MkosiArgs, Optional[Path], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1471:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Iterator[None]]"; expected "Callable[[MkosiArgs, Path, Optional[Path], Optional[Path], LuksSetupOutput, bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1559:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:1574:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs, Path], Iterator[None]]"; expected "Callable[[MkosiArgs, Path], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7004:10: error: Need type annotation for "base_image" [var-annotated]
+ mkosi/__init__.py:7005:10: error: Need type annotation for "loopdev" [var-annotated]
+ mkosi/__init__.py:7018:14: error: Need type annotation for "encrypted" [var-annotated]
+ mkosi/__init__.py:7103:21: error: Need type annotation for "mount" [var-annotated]
+ mkosi/__init__.py:7270:10: error: Need type annotation for "dir_fd" [var-annotated]
+ mkosi/__init__.py:7363:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7574:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[MkosiArgs], Iterator[List[str]]]"; expected "Callable[[MkosiArgs], Generator[<nothing>, Any, Any]]" [arg-type]
+ mkosi/__init__.py:7667:10: error: Need type annotation for "cmdline" [var-annotated]
+ mkosi/gentoo.py:37:10: error: Need type annotation for "fd" [var-annotated]
poetry (https://github.com/python-poetry/poetry)
+ src/poetry/config/file_config_source.py:33: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:47: error: Need type annotation for "config" [var-annotated]
+ src/poetry/config/file_config_source.py:62: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FileConfigSource], Iterator[Any]]"; expected "Callable[[FileConfigSource], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/utils/helpers.py:41: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Any), KwArg(Any)], Iterator[str]]"; expected "Callable[[VarArg(Any), KwArg(Any)], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/repositories/pypi_repository.py:432: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/pypi_repository.py:445: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/repositories/legacy_repository.py:363: error: Need type annotation for "temp_dir" [var-annotated]
+ src/poetry/puzzle/provider.py:90: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider, Env], Iterator[Provider]]"; expected "Callable[[Provider, Env], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/provider.py:812: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Provider], Iterator[None]]"; expected "Callable[[Provider], Generator[<nothing>, Any, Any]]" [arg-type]
+ src/poetry/puzzle/solver.py:63: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Solver, Env], Iterator[None]]"; expected "Callable[[Solver, Env], Generator[<nothing>, Any, Any]]" [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/test_utils.py:465: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Callable[[], AbstractEventLoop], bool], Iterator[AbstractEventLoop]]"; expected "Callable[[Callable[[], AbstractEventLoop], bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ aiohttp/pytest_plugin.py:235: error: Need type annotation for "_loop" [var-annotated]
+ aiohttp/pytest_plugin.py:247: error: Need type annotation for "_loop" [var-annotated]
bokeh (https://github.com/bokeh/bokeh)
+ bokeh/embed/standalone.py:346:10: error: Need type annotation for "doc" [var-annotated]
+ bokeh/embed/standalone.py: note: In function "json_item":
+ bokeh/embed/standalone.py:417:10: error: Need type annotation for "doc" [var-annotated]
isort (https://github.com/pycqa/isort)
+ isort/io.py:55: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path]], Iterator[File]]"; expected "Callable[[Union[str, Path]], Generator[<nothing>, Any, Any]]"
+ isort/deprecated/finders.py:40: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str], Iterator[None]]"; expected "Callable[[str], Generator[<nothing>, Any, Any]]"
+ isort/api.py:337: error: Need type annotation for "source_file"
+ isort/api.py:353: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[TextIO]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ isort/api.py:358: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Path], File], Iterator[TextIO]]"; expected "Callable[[Union[str, Path], File], Generator[<nothing>, Any, Any]]"
+ isort/api.py:405: error: Need type annotation for "source_file"
+ isort/api.py:423: error: Need type annotation for "output_stream_context"
+ isort/api.py:591: error: Need type annotation for "source_file"
+ isort/pylama_isort.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
edgedb (https://github.com/edgedb/edgedb)
+ edb/schema/delta.py:1458:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CommandContext], Iterator[CommandContext]]"; expected "Callable[[CommandContext], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1332:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/edgeql/compiler/setgen.py:1425:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[ContextLevel]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1173:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder], Iterator[None]]"; expected "Callable[[PathFinder], Generator[<nothing>, Any, Any]]"
+ edb/tools/toy_eval_model.py:1177:6: error: Argument 1 to "contextmanager" has incompatible type "Callable[[PathFinder, Optional[Expr], bool], Iterator[None]]"; expected "Callable[[PathFinder, Optional[Expr], bool], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:76:2: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Optional[Path], Optional[Path]], Iterator[Path]]"; expected "Callable[[Optional[Path], Optional[Path]], Generator[<nothing>, Any, Any]]"
+ edb/server/main.py:443:24: error: Need type annotation for "runstate_dir_mgr"
vision (https://github.com/pytorch/vision)
+ torchvision/datasets/imagenet.py:127: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[str]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ torchvision/datasets/imagenet.py:142: error: Need type annotation for "tmp_dir" [var-annotated]
asynq (https://github.com/quora/asynq)
+ asynq/debug.pyi:60: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool], Iterator[None]]"; expected "Callable[[bool], Generator[<nothing>, Any, Any]]"
pandas (https://github.com/pandas-dev/pandas)
+ pandas/_config/localization.py:20: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[str, Tuple[str, str]], int], Iterator[Union[str, Tuple[str, str]]]]"; expected "Callable[[Union[str, Tuple[str, str]], int], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/common.py:533: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Any, str, Any], Iterator[None]]"; expected "Callable[[Any, str, Any], Generator[<nothing>, Any, Any]]" [arg-type]
+ pandas/core/groupby/groupby.py:1001: error: Argument 1 to "contextmanager" has incompatible type "Callable[[GroupBy[NDFrameT]], Iterator[GroupBy[Any]]]"; expected "Callable[[GroupBy[NDFrameT]], Generator[<nothing>, Any, Any]]" [arg-type]
pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
+ pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Generator[_T_co, Any, Any]], Tuple[Any, ...], Dict[str, Any]], None]")
- pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
+ pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Generator[_T_co, Any, Any]], Tuple[Any, ...], Dict[str, Any]], None]")
spark (https://github.com/apache/spark)
+ python/pyspark/pandas/utils.py:488: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Dict[str, Any], DefaultNamedArg(Optional[SparkSession], 'spark')], Iterator[None]]"; expected "Callable[[Dict[str, Any], DefaultNamedArg(Optional[SparkSession], 'spark')], Generator[<nothing>, Any, Any]]" [arg-type]
+ python/pyspark/pandas/config.py:375: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Any)], Iterator[None]]"; expected "Callable[[VarArg(Any)], Generator[<nothing>, Any, Any]]" [arg-type]
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/context.py:114: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Iterator[Context]]"; expected "Callable[[Context, VarArg(MutableMapping[Any, Any]), KwArg(Any)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/tasks.py:207: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(str)], Iterator[None]]"; expected "Callable[[VarArg(str)], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/configuration.py:13: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Dict[Any, Any]], Iterator[Any]]"; expected "Callable[[Dict[Any, Any]], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/base.py:18: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Executor], Iterator[None]]"; expected "Callable[[Executor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:204: error: Argument 1 to "contextmanager" has incompatible type "Callable[[DaskExecutor], Iterator[None]]"; expected "Callable[[DaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:559: error: Argument 1 to "contextmanager" has incompatible type "Callable[[LocalDaskExecutor], Iterator[Any]]"; expected "Callable[[LocalDaskExecutor], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:657: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/executors/dask.py:675: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:346: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Flow], Iterator[Flow]]"; expected "Callable[[Flow], Generator[<nothing>, Any, Any]]"
+ src/prefect/core/flow.py:373: error: Need type annotation for "_ctx"
+ src/prefect/utilities/executors.py:75: error: Need type annotation for "configured_heartbeat"
+ src/prefect/utilities/executors.py:89: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:95: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, Optional[int]], Iterator[None]]"; expected "Callable[[str, Optional[int]], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:106: error: Argument 1 to "contextmanager" has incompatible type "Callable[[List[str], Logger], Iterator[None]]"; expected "Callable[[List[str], Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/executors.py:193: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Logger], Iterator[None]]"; expected "Callable[[Logger], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/flow_runner.py:303: error: Argument 1 to "contextmanager" has incompatible type "Callable[[FlowRunner], Iterator[Any]]"; expected "Callable[[FlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/engine/cloud/flow_runner.py:168: error: Argument 1 to "contextmanager" has incompatible type "Callable[[CloudFlowRunner], Iterator[Any]]"; expected "Callable[[CloudFlowRunner], Generator[<nothing>, Any, Any]]"
+ src/prefect/utilities/debug.py:71: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[Any]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]"
mypy (https://github.com/python/mypy)
+ mypy/state.py:12: error: Argument 1 to "contextmanager" has incompatible type "Callable[[bool], Iterator[None]]"; expected "Callable[[bool], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/backports.py:14: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], Iterator[None]]"; expected "Callable[[], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypyc/crash.py:9: error: Argument 1 to "contextmanager" has incompatible type "Callable[[str, int], Iterator[None]]"; expected "Callable[[str, int], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/scope.py:56: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Scope, str], Iterator[None]]"; expected "Callable[[Scope, str], Generator[<nothing>, Any, Any]]" [arg-type]
+ mypy/scope.py:66:```
So if I understood correctly, your function looks like this:
@contextlib.contextmanager
def foo() -> Iterator[int]:
return bar()
and it broke when bar() was changed to return an iterator that wasn't a generator, and using yield from instead of return doesn't work in your use case.
I understand that this is hard to detect correctly with linters, but I don't understand why it means linters won't help. If your code is correct and the linter still warns about it, wouldn't a linter's ignore comment at least make you pay more attention to it while refactoring?
Now consider what happens if we change the generator's yield type to Any (and also use Generator, as you suggest):
@contextlib.contextmanager
def foo() -> Generator[Any, None, None]:
return bar()
It would be nice if this was a linter error, even if bar() happens to return a generator. To me it looks like someone mistakenly wrote return instead of yield, and I expect that to be more common than actually wanting to return inside @contextlib.contextmanager.
it's an @asynccontextmanager and it has branching and defers to several generators but only on particular branches -- all of which aren't lintable without a type checker
the type checker is wrong and should be fixed, I'm not sure why there's so much resistance and insistence on keeping the type checker broken
It's technically not wrong:
>>> import contextlib
>>> @contextlib.contextmanager
... def foo():
... return iter([1])
...
>>> with foo():
... print("Hi")
...
Hi
but this is very unlikely to be what you wanted the code to do, and it would be good if type checkers warned about this.
I'm not sure why there's so much resistance and insistence
It's because people use Iterator[T] a lot, and requiring everyone to change those to more complicated (and IMO more confusing) Generator[T, None, None] just doesn't feel like a good idea. Generator[T] would help, but it would take a few years until people's minimum supported Python versions have that.
A couple ideas:
- Keep
Iteratorfor now, and reconsider this whenGenerator[T]becomes a thing, either with defaulted generics or with special-casing in type checkers? - Just merge this and revert if users complain? In the past, we have done this with other pull requests that have a big
mypy_primerdiff.
it is technically wrong, raise an exception in your context
FWIW, I'm strongly against this change, mostly because of the confusing Generator[T, None, None] type, and in part because of the huge amount of changes required for arguably a pretty minor benefit.
@Akuli
Keep Iterator for now, and reconsider this when Generator[T] becomes a thing, either with defaulted generics or with special-casing in type checkers?
In my opinion, this would a requirement to (potentially) make this a net improvement. If we could write Generator[T], the new state would be clearly better -- it's more precise, and not (significantly) more difficult to use than what we currently have. Then the main tradeoff would be the cost of the migration vs. improved type checking effectiveness.
Just merge this and revert if users complain? In the past, we have done this with other pull requests that have a big mypy_primer diff.
To be honest, I think that we should be more principled than this in typeshed, since the number of impacted users can be very large. If 1000 projects that use type checking each need to spend 15 minutes to fix their codebase, that's 250 hours lost.