Skip to content

Remove unnecessary union in the default type in .get() and .pop() methods #10294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

superbobry
Copy link
Contributor

Fixes #10293.

@superbobry
Copy link
Contributor Author

There are more usages in stubs/ which I did not update because I'm not familiar with these libraries enough.

@superbobry superbobry force-pushed the dict-pop-get branch 2 times, most recently from 23f0d99 to ed51569 Compare June 9, 2023 20:34
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

Diff from mypy_primer, showing the effect of this PR on open source code:

pip (https://github.com/pypa/pip)
+ src/pip/_internal/pyproject.py:162: error: Need type annotation for "backend_path"  [var-annotated]
+ src/pip/_internal/models/link.py:266: error: Need type annotation for "hashes"  [var-annotated]

anyio (https://github.com/agronholm/anyio)
+ src/anyio/streams/memory.py:232: error: Unused "type: ignore" comment
+ src/anyio/streams/memory.py:237: error: Unused "type: ignore" comment

vision (https://github.com/pytorch/vision)
+ torchvision/prototype/models/depth/stereo/crestereo.py:1024: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "Callable[..., Any]"  [arg-type]
+ torchvision/prototype/models/depth/stereo/crestereo.py:1032: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "Callable[..., Any]"  [arg-type]

python-chess (https://github.com/niklasf/python-chess)
+ chess/engine.py:2229: error: Argument 2 to "get" of "dict" has incompatible type "int"; expected "bool"  [arg-type]
+ chess/engine.py:2472: error: Argument 2 to "get" of "dict" has incompatible type "bool"; expected "Optional[str]"  [arg-type]

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/io/compat.py:499: error: Argument 1 to "tuple" has incompatible type "Optional[Any]"; expected "Iterable[Any]"  [arg-type]
+ mitmproxy/http.py:762: error: Argument 2 to "get" of "Mapping" has incompatible type "None"; expected "str"  [arg-type]
+ mitmproxy/proxy/events.py:96: error: Invalid index type "Optional[Any]" for "Dict[Command, Type[CommandCompleted]]"; expected type "Command"  [index]
+ mitmproxy/contentviews/http3.py:137: error: Need type annotation for "frames"  [var-annotated]
+ mitmproxy/addons/dumper.py:114: error: Argument after ** must be a mapping, not "Union[Dict[str, Union[str, bool]], Dict[<nothing>, <nothing>]]"  [arg-type]

httpx-caching (https://github.com/johtso/httpx-caching)
+ httpx_caching/_sync/_cache.py:20: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "bytes"  [arg-type]
+ httpx_caching/_async/_cache.py:20: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "bytes"  [arg-type]

manticore (https://github.com/trailofbits/manticore)
+ manticore/native/state.py:129: error: Need type annotation for "cbs"  [var-annotated]

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/book_providers.py: note: In member "get_identifiers" of class "AbstractBookProvider":
+ openlibrary/book_providers.py:63: error: No overload variant of "get" of "dict" matches argument types "str", "List[<nothing>]"  [call-overload]
+ openlibrary/book_providers.py:63: note: Possible overload variants:
+ openlibrary/book_providers.py:63: note:     def get(self, <nothing>, /) -> None
+ openlibrary/book_providers.py:63: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ openlibrary/book_providers.py: note: In member "get_identifiers" of class "InternetArchiveProvider":
+ openlibrary/book_providers.py:127: error: Need type annotation for "availability"  [var-annotated]
+ openlibrary/book_providers.py: note: In function "get_cover_url":
+ openlibrary/book_providers.py:254: error: Need type annotation for "availability"  [var-annotated]

pylox (https://github.com/sco1/pylox)
- pylox/containers/array.py:84: note:     def [_T] pop(self, Any, Union[Any, _T], /) -> Union[Any, _T]
+ pylox/containers/array.py:84: note:     def [_T] pop(self, Any, _T, /) -> Union[Any, _T]

pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/mypy.py:243: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ pydantic/mypy.py:243: note: Possible overload variants:
+ pydantic/mypy.py:243: note:     def get(self, <nothing>, /) -> None
+ pydantic/mypy.py:243: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ pydantic/v1/mypy.py:243: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ pydantic/v1/mypy.py:243: note: Possible overload variants:
+ pydantic/v1/mypy.py:243: note:     def get(self, <nothing>, /) -> None
+ pydantic/v1/mypy.py:243: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ pydantic/_internal/_fields.py:90: error: Need type annotation for "annotations"  [var-annotated]
+ pydantic/json_schema.py:821: error: Need type annotation for "properties"  [var-annotated]
+ pydantic/_internal/_model_construction.py:256: error: Need type annotation for "raw_annotations"  [var-annotated]
+ pydantic/v1/class_validators.py:168: error: Need type annotation for "validators"  [var-annotated]
+ pydantic/v1/schema.py:1070: error: Argument "unique_items" to "conlist" has incompatible type "Optional[Any]"; expected "bool"  [arg-type]
+ pydantic/v1/decorator.py:181: error: Need type annotation for "var_kwargs"  [var-annotated]
+ pydantic/deprecated/decorator.py:187: error: Need type annotation for "var_kwargs"  [var-annotated]

comtypes (https://github.com/enthought/comtypes)
+ comtypes/client/_generate.py:115: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]

cloud-init (https://github.com/canonical/cloud-init)
+ cloudinit/net/netplan.py:105: error: Need type annotation for "subnets"  [var-annotated]
+ cloudinit/net/netplan.py:374: error: Need type annotation for "interfaces"  [var-annotated]
+ cloudinit/sources/DataSourceLXD.py:202: error: Need type annotation for "config"  [var-annotated]
+ cloudinit/sources/DataSourceLXD.py:203: error: Need type annotation for "user_metadata"  [var-annotated]
+ cloudinit/sources/DataSourceLXD.py:231: error: Need type annotation for "md"  [var-annotated]
+ cloudinit/config/schema.py:836: error: Need type annotation for "property_types"  [var-annotated]
+ cloudinit/config/schema.py:853: error: Need type annotation for "items"  [var-annotated]
+ cloudinit/config/schema.py:854: error: Need type annotation for "sub_property_types"  [var-annotated]
+ cloudinit/config/schema.py:962: error: Need type annotation for "oneOf"  [var-annotated]
+ cloudinit/config/schema.py:963: error: Need type annotation for "anyOf"  [var-annotated]
+ cloudinit/config/schema.py:989: error: Need type annotation for "property_schemas"  [var-annotated]
+ cloudinit/config/schema.py:1115: error: Need type annotation for "defs"  [var-annotated]
+ cloudinit/cmd/status.py:209: error: Need type annotation for "errors" (hint: "errors: List[<type>] = ...")  [var-annotated]
+ cloudinit/config/cc_write_files.py:122: error: Need type annotation for "file_list"  [var-annotated]
+ cloudinit/config/cc_ubuntu_advantage.py:386: error: No overload variant of "get" of "dict" matches argument types "str", "bool"  [call-overload]
+ cloudinit/config/cc_ubuntu_advantage.py:386: note: Possible overload variants:
+ cloudinit/config/cc_ubuntu_advantage.py:386: note:     def get(self, <nothing>, /) -> None
+ cloudinit/config/cc_ubuntu_advantage.py:386: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ cloudinit/config/cc_snap.py:189: error: Need type annotation for "cfgin"  [var-annotated]
+ cloudinit/config/cc_seed_random.py:113: error: Need type annotation for "mycfg"  [var-annotated]
+ cloudinit/config/cc_rsyslog.py:173: error: Need type annotation for "mycfg"  [var-annotated]
+ cloudinit/config/cc_mounts.py:450: error: Need type annotation for "device_aliases"  [var-annotated]
+ cloudinit/config/cc_lxd.py:214: error: Need type annotation for "init_cfg"  [var-annotated]
+ cloudinit/config/cc_lxd.py:216: error: Need type annotation for "bridge_cfg"  [var-annotated]
+ cloudinit/config/cc_landscape.py:111: error: Need type annotation for "ls_cloudcfg"  [var-annotated]
+ cloudinit/config/cc_keys_to_console.py:83: error: No overload variant of "get" of "dict" matches argument types "str", "bool"  [call-overload]
+ cloudinit/config/cc_keys_to_console.py:83: note: Possible overload variants:
+ cloudinit/config/cc_keys_to_console.py:83: note:     def get(self, <nothing>, /) -> None
+ cloudinit/config/cc_keys_to_console.py:83: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ cloudinit/config/cc_grub_dpkg.py:144: error: Need type annotation for "mycfg"  [var-annotated]
+ cloudinit/config/cc_disk_setup.py:119: error: Need type annotation for "device_aliases"  [var-annotated]
+ cloudinit/config/cc_ca_certs.py:266: error: Unsupported right operand type for in ("Optional[Any]")  [operator]
+ cloudinit/config/cc_ca_certs.py:272: error: Item "None" of "Optional[Any]" has no attribute "get"  [union-attr]
+ cloudinit/config/cc_ca_certs.py:273: error: Item "None" of "Optional[Any]" has no attribute "get"  [union-attr]
+ cloudinit/config/cc_ca_certs.py:279: error: Unsupported right operand type for in ("Optional[Any]")  [operator]
+ cloudinit/config/cc_apt_configure.py:180: error: Need type annotation for "apt_cfg"  [var-annotated]
+ cloudinit/config/cc_ansible.py:258: error: Need type annotation for "actions"  [var-annotated]
+ cloudinit/config/cc_write_files_deferred.py:43: error: Need type annotation for "file_list"  [var-annotated]

sublime_debugger (https://github.com/daveleroy/sublime_debugger)
+ modules/ui/input.py:129: error: Need type annotation for "modifier_keys"  [var-annotated]
+ modules/adapters_registry.py:50: error: Need type annotation for "body"  [var-annotated]
+ modules/debugger.py:883: error: No overload variant of "get" of "dict" matches argument types "str", "str"  [call-overload]
+ modules/debugger.py:883: note: Possible overload variants:
+ modules/debugger.py:883: note:     def get(self, <nothing>, /) -> None
+ modules/debugger.py:883: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ modules/adapters/sublime_debug.py:218: error: Need type annotation for "linked_packages"  [var-annotated]

paasta (https://github.com/yelp/paasta)
+ paasta_tools/utils.py:2642: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ paasta_tools/utils.py:2642: note: Possible overload variants:
+ paasta_tools/utils.py:2642: note:     def get(self, <nothing>, /) -> None
+ paasta_tools/utils.py:2642: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ paasta_tools/utils.py:3300: error: Need type annotation for "auto_config"  [var-annotated]
+ paasta_tools/utils.py:3333: error: Need type annotation for "auto_config"  [var-annotated]
+ paasta_tools/kubernetes_tools.py:1228: error: Need type annotation for "config"  [var-annotated]
+ paasta_tools/marathon_dashboard.py:92: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ paasta_tools/marathon_dashboard.py:92: note: Possible overload variants:
+ paasta_tools/marathon_dashboard.py:92: note:     def get(self, <nothing>, /) -> None
+ paasta_tools/marathon_dashboard.py:92: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ paasta_tools/setup_kubernetes_cr.py:234: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ paasta_tools/setup_kubernetes_cr.py:234: note: Possible overload variants:
+ paasta_tools/setup_kubernetes_cr.py:234: note:     def get(self, <nothing>, /) -> None
+ paasta_tools/setup_kubernetes_cr.py:234: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ paasta_tools/cli/cmds/status.py:1974: error: Need type annotation for "group"  [var-annotated]
+ paasta_tools/cli/cmds/spark_run.py:1072: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ paasta_tools/cli/cmds/spark_run.py:1072: note: Possible overload variants:
+ paasta_tools/cli/cmds/spark_run.py:1072: note:     def get(self, <nothing>, /) -> None
+ paasta_tools/cli/cmds/spark_run.py:1072: note:     def [_T] get(self, <nothing>, _T, /) -> _T

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/indexers/objects.py:320: error: Argument 2 to "pop" of "dict" has incompatible type "Union[int, BaseIndexer]"; expected "int"  [arg-type]
+ pandas/core/interchange/from_dataframe.py:415: error: No overload variant of "get" of "dict" matches argument types "int", "None"  [call-overload]
+ pandas/core/interchange/from_dataframe.py:415: note: Possible overload variants:
+ pandas/core/interchange/from_dataframe.py:415: note:     def get(self, <nothing>, /) -> None
+ pandas/core/interchange/from_dataframe.py:415: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ pandas/core/apply.py:433: error: Dict entry 0 has incompatible type "str": "Optional[Any]"; expected "str": "bool"  [dict-item]
+ pandas/core/apply.py:433: error: Dict entry 1 has incompatible type "str": "Optional[Any]"; expected "str": "bool"  [dict-item]
+ pandas/io/sql.py:104: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "Literal['ignore', 'raise', 'coerce']"  [arg-type]
+ pandas/io/pytables.py:3745: error: Need type annotation for "info"  [var-annotated]
+ pandas/io/pytables.py:4531: error: Need type annotation for "info"  [var-annotated]
+ pandas/core/generic.py:2082: error: Need type annotation for "attrs"  [var-annotated]

ignite (https://github.com/pytorch/ignite)
+ ignite/contrib/handlers/tqdm_logger.py:215: error: Argument 1 to "_OutputHandler" has incompatible type "Optional[Any]"; expected "str"  [arg-type]

sympy (https://github.com/sympy/sympy)
+ sympy/core/evalf.py:436: error: Item "bool" of "Union[Any, Literal[True]]" has no attribute "values"  [union-attr]
+ sympy/core/evalf.py:1187: error: Incompatible types in assignment (expression has type "Union[Any, float]", variable has type "int")  [assignment]

SinbadCogs (https://github.com/mikeshardmind/SinbadCogs)
+ rss/core.py:232: error: Need type annotation for "match_rule"  [var-annotated]
+ rss/core.py:272: error: Need type annotation for "roles"  [var-annotated]

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/config/findpaths.py:79: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ src/_pytest/config/findpaths.py:79: note: Possible overload variants:
+ src/_pytest/config/findpaths.py:79: note:     def get(self, <nothing>, /) -> None
+ src/_pytest/config/findpaths.py:79: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ src/_pytest/mark/structures.py:374: error: Need type annotation for "mark_lists"  [var-annotated]
+ src/_pytest/terminal.py:1137: error: Need type annotation for "failed"  [var-annotated]
+ src/_pytest/terminal.py:1149: error: Need type annotation for "xfailed"  [var-annotated]
+ src/_pytest/terminal.py:1164: error: Need type annotation for "xpassed"  [var-annotated]
+ src/_pytest/terminal.py:1269: error: Need type annotation for "reports"  [var-annotated]

operator (https://github.com/canonical/operator)
- ops/model.py:783: note:          def get(self, str, /) -> Optional[Binding]
+ ops/model.py:783: note:          def get(self, key: str) -> Optional[Binding]
- ops/model.py:783: note:          def [_T] get(self, str, /, default: Union[Binding, _T]) -> Union[Binding, _T]
+ ops/model.py:783: note:          def [_T] get(self, key: str, default: _T) -> Union[Binding, _T]
- ops/model.py:783: note:          def get(self, str, /) -> Optional[Binding]
+ ops/model.py:783: note:          def get(self, key: str) -> Optional[Binding]
- ops/model.py:783: note:          def [_T] get(self, str, /, default: Union[Binding, _T]) -> Union[Binding, _T]
+ ops/model.py:783: note:          def [_T] get(self, key: str, default: _T) -> Union[Binding, _T]
+ ops/model.py:2947: error: Need type annotation for "units"  [var-annotated]
- ops/model.py:2948: error: Item "None" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...]]" has no attribute "values"  [union-attr]
+ ops/model.py:2948: error: Item "None" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...], Dict[Any, Any]]" has no attribute "values"  [union-attr]
- ops/model.py:2948: error: Item "int" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...]]" has no attribute "values"  [union-attr]
+ ops/model.py:2948: error: Item "int" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...], Dict[Any, Any]]" has no attribute "values"  [union-attr]
- ops/model.py:2948: error: Item "float" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...]]" has no attribute "values"  [union-attr]
+ ops/model.py:2948: error: Item "float" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...], Dict[Any, Any]]" has no attribute "values"  [union-attr]
- ops/model.py:2948: error: Item "str" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...]]" has no attribute "values"  [union-attr]
+ ops/model.py:2948: error: Item "str" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...], Dict[Any, Any]]" has no attribute "values"  [union-attr]
- ops/model.py:2948: error: Item "List[JsonObject]" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...]]" has no attribute "values"  [union-attr]
+ ops/model.py:2948: error: Item "List[JsonObject]" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...], Dict[Any, Any]]" has no attribute "values"  [union-attr]
- ops/model.py:2948: error: Item "Tuple[JsonObject, ...]" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...]]" has no attribute "values"  [union-attr]
+ ops/model.py:2948: error: Item "Tuple[JsonObject, ...]" of "Union[Any, None, int, float, str, Dict[str, JsonObject], List[JsonObject], Tuple[JsonObject, ...], Dict[Any, Any]]" has no attribute "values"  [union-attr]
+ ops/testing.py:340: error: Argument 1 has incompatible type "Optional[List[int]]"; expected "MutableSequence[Any]"  [arg-type]
+ ops/testing.py:341: error: Item "None" of "Optional[List[int]]" has no attribute "__iter__" (not iterable)  [union-attr]
- ops/testing.py:876: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "Union[Dict[str, str], Mapping[str, str]]"  [arg-type]
+ ops/testing.py:876: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "Mapping[str, str]"  [arg-type]
- ops/testing.py:1879: note:     def [_T] pop(self, int, Union[Dict[str, Any], _T], /) -> Union[Dict[str, Any], _T]
+ ops/testing.py:1879: note:     def [_T] pop(self, int, _T, /) -> Union[Dict[str, Any], _T]

Auto-Split (https://github.com/Avasam/Auto-Split)
- src/capture_method/__init__.py:102: note:          def [_T] get(self, CaptureMethodEnum, Union[CaptureMethodInfo, _T], /) -> Union[CaptureMethodInfo, _T]
+ src/capture_method/__init__.py:102: note:          def [_T] get(self, CaptureMethodEnum, _T, /) -> Union[CaptureMethodInfo, _T]
- src/capture_method/__init__.py:102: note:          def get(self, CaptureMethodEnum, /) -> Optional[CaptureMethodInfo]
+ src/capture_method/__init__.py:102: note:          def get(self, key: CaptureMethodEnum) -> Optional[CaptureMethodInfo]
- src/capture_method/__init__.py:102: note:          def [_T] get(self, CaptureMethodEnum, /, default: Union[CaptureMethodInfo, _T]) -> Union[CaptureMethodInfo, _T]
+ src/capture_method/__init__.py:102: note:          def [_T] get(self, key: CaptureMethodEnum, default: _T) -> Union[CaptureMethodInfo, _T]
- src/capture_method/__init__.py:102: note:          def [_T] get(self, CaptureMethodEnum, Union[CaptureMethodInfo, _T], /) -> Union[CaptureMethodInfo, _T]
+ src/capture_method/__init__.py:102: note:          def [_T] get(self, CaptureMethodEnum, _T, /) -> Union[CaptureMethodInfo, _T]
- src/capture_method/__init__.py:102: note:          def get(self, CaptureMethodEnum, /) -> Optional[CaptureMethodInfo]
+ src/capture_method/__init__.py:102: note:          def get(self, key: CaptureMethodEnum) -> Optional[CaptureMethodInfo]
- src/capture_method/__init__.py:102: note:          def [_T] get(self, CaptureMethodEnum, /, default: Union[CaptureMethodInfo, _T]) -> Union[CaptureMethodInfo, _T]
+ src/capture_method/__init__.py:102: note:          def [_T] get(self, key: CaptureMethodEnum, default: _T) -> Union[CaptureMethodInfo, _T]

tornado (https://github.com/tornadoweb/tornado)
+ tornado/locale.py:271: error: No overload variant of "get" of "dict" matches argument types "str", "str"  [call-overload]
+ tornado/locale.py:271: note: Possible overload variants:
+ tornado/locale.py:271: note:     def get(self, <nothing>, /) -> None
+ tornado/locale.py:271: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ tornado/locale.py:496: error: Need type annotation for "message_dict"  [var-annotated]
+ tornado/web.py:1486: error: Need type annotation for "cookie_kwargs"  [var-annotated]
+ tornado/web.py:2147: error: Need type annotation for "static_handler_args"  [var-annotated]
+ tornado/test/web_test.py:1668: error: Need type annotation for "reason"  [var-annotated]

pylint (https://github.com/pycqa/pylint)
+ pylint/message/message_id_store.py:87: error: Need type annotation for "existing_old_names"  [var-annotated]
+ pylint/lint/message_state_handler.py:284: error: Need type annotation for "lines"  [var-annotated]
+ pylint/config/utils.py:52: error: Argument "action" to "_StoreTrueArgument" has incompatible type "Union[Any, str]"; expected "Literal['store_true']"  [arg-type]
+ pylint/config/utils.py:66: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ pylint/config/utils.py:74: error: Argument "action" to "_ExtendArgument" has incompatible type "Union[Any, str]"; expected "Literal['extend']"  [arg-type]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/docfields.py: note: In member "transform" of class "DocFieldTransformer":
+ sphinx/util/docfields.py:362:30: error: Need type annotation for "fieldtypes"  [var-annotated]
+ sphinx/transforms/i18n.py: note: In member "update_autofootnote_references" of class "_NodeUpdater":
+ sphinx/transforms/i18n.py:208:20: error: Need type annotation for "refs"  [var-annotated]
+ sphinx/jinja2glue.py: note: In function "warning":
+ sphinx/jinja2glue.py:107:20: error: Unsupported left operand type for + ("None")  [operator]
+ sphinx/jinja2glue.py:107:20: note: Both left and right operands are unions
+ sphinx/ext/autodoc/__init__.py: note: In member "get_module_members" of class "ModuleDocumenter":
+ sphinx/ext/autodoc/__init__.py:1046:29: error: Need type annotation for "docstring"  [var-annotated]
+ sphinx/builders/html/__init__.py:664:27: error: Need type annotation for "fignumbers"  [var-annotated]
+ sphinx/builders/html/__init__.py: note: In member "index_page" of class "StandaloneHTMLBuilder":
+ sphinx/builders/html/__init__.py:953:24: error: Need type annotation for "metadata"  [var-annotated]
+ sphinx/domains/cpp.py: note: In member "run" of class "CPPNamespacePushObject":
+ sphinx/domains/cpp.py:7539:17: error: Need type annotation for "stack"  [var-annotated]
+ sphinx/domains/c.py: note: In member "run" of class "CNamespacePushObject":
+ sphinx/domains/c.py:3449:17: error: Need type annotation for "stack"  [var-annotated]
+ sphinx/ext/autodoc/typehints.py:56:19: error: Need type annotation for "annotations"  [var-annotated]
+ sphinx/environment/collectors/toctree.py: note: In function "assign_figure_numbers":
+ sphinx/environment/collectors/toctree.py:268:26: error: Need type annotation for "secnumbers"  [var-annotated]
+ sphinx/directives/code.py: note: In member "run" of class "LiteralInclude":
+ sphinx/directives/code.py:456:41: error: Incompatible types in assignment (expression has type "Union[Any, int]", target has type "List[int]")  [assignment]
+ sphinx/testing/fixtures.py: note: In function "app_params":
+ sphinx/testing/fixtures.py:91:33: error: Unsupported left operand type for / ("str")  [operator]
+ sphinx/testing/fixtures.py:91:33: note: Right operand is of type "Union[Any, str]"
+ sphinx/testing/fixtures.py:95:25: error: Unsupported left operand type for / ("str")  [operator]

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/gdblib/events.py: note: In function "connect":
+ pwndbg/gdblib/events.py:147: error: Need type annotation for "dispatched"  [var-annotated]
+ pwndbg/commands/heap.py: note: In function "vis_heap_chunks":
+ pwndbg/commands/heap.py:906: error: Need type annotation for "labels" (hint: "labels: List[<type>] = ...")  [var-annotated]
+ pwndbg/commands/context.py: note: In function "context":
+ pwndbg/commands/context.py:395: error: Need type annotation for "settings"  [var-annotated]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/structured_configs/_implementations.py:2100: error: Argument 2 to "get" of "dict" has incompatible type "object"; expected "type"  [arg-type]
+ src/hydra_zen/structured_configs/_implementations.py:2152: error: Argument 1 to "append" of "list" has incompatible type "Tuple[str, object]"; expected "Union[Tuple[str, Type[Any]], Tuple[str, Type[Any], Any]]"  [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:2154: error: Incompatible types in assignment (expression has type "Tuple[str, Any, Any]", variable has type "Tuple[str, Any]")  [assignment]
+ src/hydra_zen/structured_configs/_implementations.py:2154: error: Incompatible types in assignment (expression has type "Tuple[str, object, Any]", variable has type "Tuple[str, object]")  [assignment]
- src/hydra_zen/structured_configs/_implementations.py:2155: error: Argument 1 to "append" of "list" has incompatible type "Tuple[str, Any]"; expected "Tuple[str, type, Field[Any]]"  [arg-type]
+ src/hydra_zen/structured_configs/_implementations.py:2155: error: Argument 1 to "append" of "list" has incompatible type "Tuple[str, object]"; expected "Tuple[str, type, Field[Any]]"  [arg-type]

pandera (https://github.com/pandera-dev/pandera)
+ pandera/schema_statistics/pandas.py:166: error: Value of type "Union[Any, float]" is not indexable  [index]
+ pandera/schema_statistics/pandas.py:169: error: Value of type "Union[Any, float]" is not indexable  [index]
+ pandera/api/pandas/model.py:343: error: Need type annotation for "field_checks"  [var-annotated]

mypy (https://github.com/python/mypy)
+ mypy/errors.py:499: error: No overload variant of "get" of "dict" matches argument types "int", "List[<nothing>]"  [call-overload]
+ mypy/errors.py:499: note: Possible overload variants:
+ mypy/errors.py:499: note:     def get(self, <nothing>, /) -> None
+ mypy/errors.py:499: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ mypy/errors.py:499: error: Need type annotation for "ignored_codes"  [var-annotated]
+ mypyc/irbuild/ll_builder.py:1384: error: Need type annotation for "call_c_ops_candidates"  [var-annotated]
+ mypyc/irbuild/ll_builder.py:1638: error: Need type annotation for "call_c_ops_candidates"  [var-annotated]
+ mypyc/irbuild/ll_builder.py:2261: error: Need type annotation for "call_c_ops_candidates"  [var-annotated]
+ mypy/test/data.py:360: error: Need type annotation for "steps"  [var-annotated]
+ mypy/server/update.py:925: error: Unsupported operand types for - ("Set[<nothing>]" and "Set[str]")  [operator]
+ mypy/server/update.py:925: note: Left operand is of type "Union[Set[str], Set[<nothing>]]"
+ mypyc/irbuild/builder.py:1031: error: Need type annotation for "call_c_ops_candidates"  [var-annotated]
+ mypy/dmypy/client.py:581: error: Need type annotation for "telemetry"  [var-annotated]

starlette (https://github.com/encode/starlette)
+ starlette/testclient.py:720: error: Need type annotation for "headers"  [var-annotated]
+ starlette/templating.py:44: error: Need type annotation for "request"  [var-annotated]
+ starlette/templating.py:45: error: Need type annotation for "extensions"  [var-annotated]

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/software/conda.py:171: error: Need type annotation for "pip_requirements"  [var-annotated]
+ src/prefect/utilities/templating.py:184: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ src/prefect/utilities/templating.py:184: note: Possible overload variants:
+ src/prefect/utilities/templating.py:184: note:     def get(self, <nothing>, /) -> None
+ src/prefect/utilities/templating.py:184: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ src/prefect/settings.py:2190: error: Need type annotation for "raw_profiles"  [var-annotated]
+ src/prefect/blocks/core.py:696: error: Need type annotation for "nested_block_document_info"  [var-annotated]
+ src/prefect/logging/handlers.py:77: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "int"  [arg-type]
+ src/prefect/server/models/block_schemas.py:481: error: Need type annotation for "child_definitions"  [var-annotated]
+ src/prefect/server/orchestration/core_policy.py:122: error: Item "None" of "Optional[Any]" has no attribute "active_slots"  [union-attr]
+ src/prefect/server/orchestration/core_policy.py:124: error: Item "None" of "Optional[Any]" has no attribute "active_slots"  [union-attr]
+ src/prefect/server/orchestration/core_policy.py:136: error: Item "None" of "Optional[Any]" has no attribute "active_slots"  [union-attr]
+ src/prefect/server/orchestration/core_policy.py:138: error: Item "None" of "Optional[Any]" has no attribute "active_slots"  [union-attr]

optuna (https://github.com/optuna/optuna)
+ optuna/trial/_trial.py:65: error: Need type annotation for "_fixed_params"  [var-annotated]
+ optuna/storages/_rdb/storage.py:410: error: Need type annotation for "user_attrs"  [var-annotated]
+ optuna/storages/_rdb/storage.py:411: error: Need type annotation for "system_attrs"  [var-annotated]
- optuna/storages/_rdb/storage.py:417: error: Key expression in dictionary comprehension has incompatible type "Column"; expected type "str"  [misc]
+ optuna/storages/_rdb/storage.py:417: error: Key expression in dictionary comprehension has incompatible type "Union[Column, Any]"; expected type "str"  [misc]
- optuna/storages/_rdb/storage.py:417: error: Argument 1 to "loads" has incompatible type "Column"; expected "Union[str, bytes, bytearray]"  [arg-type]
+ optuna/storages/_rdb/storage.py:417: error: Argument 1 to "loads" has incompatible type "Union[Column, Any]"; expected "Union[str, bytes, bytearray]"  [arg-type]
- optuna/storages/_rdb/storage.py:418: error: Key expression in dictionary comprehension has incompatible type "Column"; expected type "str"  [misc]
+ optuna/storages/_rdb/storage.py:418: error: Key expression in dictionary comprehension has incompatible type "Union[Column, Any]"; expected type "str"  [misc]
- optuna/storages/_rdb/storage.py:418: error: Argument 1 to "loads" has incompatible type "Column"; expected "Union[str, bytes, bytearray]"  [arg-type]
+ optuna/storages/_rdb/storage.py:418: error: Argument 1 to "loads" has incompatible type "Union[Column, Any]"; expected "Union[str, bytes, bytearray]"  [arg-type]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/http.py:63: error: Argument 2 to "get" of "dict" has incompatible type "int"; expected "Language"  [arg-type]
+ steam/state.py:183: error: Argument 2 to "get" of "dict" has incompatible type "int"; expected "PersonaState"  [arg-type]
+ steam/state.py:184: error: Argument 2 to "get" of "dict" has incompatible type "int"; expected "UIMode"  [arg-type]
+ steam/state.py:185: error: Argument 2 to "get" of "dict" has incompatible type "int"; expected "PersonaStateFlag"  [arg-type]
- steam/state.py:1443: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "Union[Friend, CMsgClientFriendsListFriend]"  [arg-type]
+ steam/state.py:1443: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "CMsgClientFriendsListFriend"  [arg-type]
- steam/ext/commands/utils.py:36: note:          def [_T] get(self, str, Union[_VT, _T], /) -> Union[_VT, _T]
+ steam/ext/commands/utils.py:36: note:          def [_T] get(self, str, _T, /) -> Union[_VT, _T]
- steam/ext/commands/utils.py:36: note:          def get(self, str, /) -> Optional[_VT]
+ steam/ext/commands/utils.py:36: note:          def get(self, key: str) -> Optional[_VT]
- steam/ext/commands/utils.py:36: note:          def [_T] get(self, str, /, default: Union[_VT, _T]) -> Union[_VT, _T]
+ steam/ext/commands/utils.py:36: note:          def [_T] get(self, key: str, default: _T) -> Union[_VT, _T]
- steam/ext/commands/utils.py:47: note:          def [_T] pop(self, str, Union[_VT, _T], /) -> Union[_VT, _T]
+ steam/ext/commands/utils.py:47: note:          def [_T] pop(self, str, _T, /) -> Union[_VT, _T]
- steam/ext/commands/utils.py:47: note:          def [_T] pop(self, str, /, default: Union[_VT, _T]) -> Union[_VT, _T]
+ steam/ext/commands/utils.py:47: note:          def [_T] pop(self, str, /, default: _T) -> Union[_VT, _T]

spack (https://github.com/spack/spack)
+ lib/spack/spack/util/environment.py:756: error: Need type annotation for "exclude"  [var-annotated]
+ lib/spack/spack/util/environment.py:757: error: Need type annotation for "include"  [var-annotated]

scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/datasets/_openml.py:395: error: No overload variant of "get" of "dict" matches argument types "str", "List[<nothing>]"  [call-overload]
+ sklearn/datasets/_openml.py:395: note: Possible overload variants:
+ sklearn/datasets/_openml.py:395: note:     def get(self, <nothing>, /) -> None
+ sklearn/datasets/_openml.py:395: note:     def [_T] get(self, <nothing>, _T, /) -> _T

poetry (https://github.com/python-poetry/poetry)
+ src/poetry/packages/locker.py:85: error: Need type annotation for "metadata"  [var-annotated]
+ src/poetry/packages/locker.py:116: error: Need type annotation for "source"  [var-annotated]
+ src/poetry/packages/locker.py:120: error: Argument 1 to "joinpath" of "PurePath" has incompatible type "Optional[Any]"; expected "Union[str, PathLike[str]]"  [arg-type]
+ src/poetry/packages/locker.py:155: error: Argument 1 to "Path" has incompatible type "Optional[Any]"; expected "Union[str, PathLike[str]]"  [arg-type]
+ src/poetry/packages/locker.py:164: error: Need type annotation for "extras"  [var-annotated]
+ src/poetry/utils/authenticator.py:237: error: Argument 2 to "send" of "Session" has incompatible type "**Dict[str, Union[Any, int]]"; expected "Optional[bool]"  [arg-type]
+ src/poetry/utils/authenticator.py:237: error: Argument 2 to "send" of "Session" has incompatible type "**Dict[str, Union[Any, int]]"; expected "Optional[Union[bool, str]]"  [arg-type]
+ src/poetry/utils/authenticator.py:237: error: Argument 2 to "send" of "Session" has incompatible type "**Dict[str, Union[Any, int]]"; expected "Optional[MutableMapping[str, str]]"  [arg-type]
+ src/poetry/utils/authenticator.py:237: error: Argument 2 to "send" of "Session" has incompatible type "**Dict[str, Union[Any, int]]"; expected "Optional[Union[str, Tuple[str, str]]]"  [arg-type]
+ src/poetry/utils/authenticator.py:237: error: Argument 2 to "send" of "Session" has incompatible type "**Dict[str, Union[Any, int]]"; expected "bool"  [arg-type]
+ src/poetry/factory.py:364: error: Need type annotation for "groups"  [var-annotated]
+ src/poetry/puzzle/provider.py:376: error: Need type annotation for "overrides"  [var-annotated]
+ src/poetry/puzzle/provider.py:679: error: Need type annotation for "package_overrides"  [var-annotated]
+ src/poetry/puzzle/provider.py:729: error: Need type annotation for "locked"  [var-annotated]
+ src/poetry/installation/installer.py:440: error: Need type annotation for "raw_extras"  [var-annotated]
+ tests/conftest.py:106: error: No overload variant of "get" of "dict" matches argument type "Optional[str]"  [call-overload]
+ tests/conftest.py:106: note: Possible overload variants:
+ tests/conftest.py:106: note:     def get(self, <nothing>, /) -> None
+ tests/conftest.py:106: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ tests/conftest.py:109: error: No overload variant of "get" of "dict" matches argument type "Optional[str]"  [call-overload]
+ tests/conftest.py:109: note: Possible overload variants:
+ tests/conftest.py:109: note:     def get(self, <nothing>, /) -> None
+ tests/conftest.py:109: note:     def [_T] get(self, <nothing>, _T, /) -> _T

pyppeteer (https://github.com/pyppeteer/pyppeteer)
+ pyppeteer/multimap.py:37: error: Need type annotation for "_set"  [var-annotated]
+ pyppeteer/connection.py:117: error: Need type annotation for "params"  [var-annotated]
+ pyppeteer/connection.py:121: error: Argument 1 to "get" of "dict" has incompatible type "Optional[Any]"; expected "str"  [arg-type]
+ pyppeteer/connection.py:123: error: Argument 1 to "_on_message" of "CDPSession" has incompatible type "Optional[Any]"; expected "str"  [arg-type]
+ pyppeteer/connection.py:125: error: Argument 1 to "get" of "dict" has incompatible type "Optional[Any]"; expected "str"  [arg-type]
+ pyppeteer/connection.py:128: error: Argument 1 to "__delitem__" of "dict" has incompatible type "Optional[Any]"; expected "str"  [arg-type]
+ pyppeteer/helper.py:44: error: Need type annotation for "stackTrace"  [var-annotated]
+ pyppeteer/helper.py:46: error: Item "None" of "Optional[Any]" has no attribute "__iter__" (not iterable)  [union-attr]
+ pyppeteer/page.py:212: error: Need type annotation for "entry"  [var-annotated]
+ pyppeteer/page.py:215: error: Need type annotation for "args"  [var-annotated]
+ pyppeteer/page.py:1368: error: Need type annotation for "marginOptions"  [var-annotated]
+ pyppeteer/network_manager.py:213: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ pyppeteer/network_manager.py:213: note: Possible overload variants:
+ pyppeteer/network_manager.py:213: note:     def get(self, <nothing>, /) -> None
+ pyppeteer/network_manager.py:213: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ pyppeteer/network_manager.py:265: error: Need type annotation for "_resp"  [var-annotated]
+ pyppeteer/network_manager.py:269: error: Argument 5 to "Response" has incompatible type "Optional[Any]"; expected "bool"  [arg-type]
+ pyppeteer/network_manager.py:270: error: Argument 6 to "Response" has incompatible type "Optional[Any]"; expected "bool"  [arg-type]
+ pyppeteer/network_manager.py:271: error: Argument 7 to "Response" has incompatible type "Optional[Any]"; expected "Dict[Any, Any]"  [arg-type]
+ pyppeteer/network_manager.py:342: error: Need type annotation for "headers"  [var-annotated]
+ pyppeteer/network_manager.py:498: error: Argument 1 to "get" of "dict" has incompatible type "Union[Any, int]"; expected "str"  [arg-type]
+ pyppeteer/network_manager.py:707: error: Need type annotation for "_hash"  [var-annotated]
+ pyppeteer/network_manager.py:727: error: Unsupported target for indexed assignment ("Union[Dict[Any, Any], Any, str, None]")  [index]
+ pyppeteer/launcher.py:102: error: Argument 1 to "filter" has incompatible type "Callable[[Any], bool]"; expected "Callable[[str], TypeGuard[str]]"  [arg-type]
+ pyppeteer/launcher.py:381: error: Need type annotation for "args"  [var-annotated]
+ pyppeteer/element_handle.py:285: error: Need type annotation for "model"  [var-annotated]
+ pyppeteer/element_handle.py:287: error: Argument 1 to "_fromProtocolQuad" of "ElementHandle" has incompatible type "Optional[Any]"; expected "List[int]"  [arg-type]
+ pyppeteer/element_handle.py:288: error: Argument 1 to "_fromProtocolQuad" of "ElementHandle" has incompatible type "Optional[Any]"; expected "List[int]"  [arg-type]
+ pyppeteer/element_handle.py:289: error: Argument 1 to "_fromProtocolQuad" of "ElementHandle" has incompatible type "Optional[Any]"; expected "List[int]"  [arg-type]
+ pyppeteer/element_handle.py:290: error: Argument 1 to "_fromProtocolQuad" of "ElementHandle" has incompatible type "Optional[Any]"; expected "List[int]"  [arg-type]
+ pyppeteer/coverage.py:260: error: Need type annotation for "header"  [var-annotated]

schema_salad (https://github.com/common-workflow-language/schema_salad)
+ schema_salad/avro/schema.py: note: In function "make_avsc_object":
+ schema_salad/avro/schema.py:597:26: error: Need type annotation for "fields"  [var-annotated]
+ schema_salad/schema.py: note: In function "print_inheritance":
+ schema_salad/schema.py:766:22: error: Need type annotation for "fields"  [var-annotated]
+ schema_salad/makedoc.py: note: In member "render_type" of class "RenderType":
+ schema_salad/makedoc.py:658:16: error: Need type annotation for "subs"  [var-annotated]

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/tests/plugins/test_storage_plugins.py: note: In member "clean_path" of class "MockConnection":
+ src/bandersnatch/tests/plugins/test_storage_plugins.py:144: error: Item "None" of "Optional[Any]" has no attribute "name"  [union-attr]
+ src/bandersnatch/tests/plugins/test_storage_plugins.py: note: In member "_strip_prefix" of class "MockConnection":
+ src/bandersnatch/tests/plugins/test_storage_plugins.py:156: error: Item "None" of "Optional[Any]" has no attribute "name"  [union-attr]

mkosi (https://github.com/systemd/mkosi)
+ mkosi/qemu.py:49:26: error: Need type annotation for "FIRMWARE_LOCATIONS"  [var-annotated]
+ mkosi/qemu.py:61:26: error: Need type annotation for "FIRMWARE_LOCATIONS"  [var-annotated]
+ mkosi/__init__.py:730:5: error: Need type annotation for "firmware" (hint: "firmware': Set[<type>] = ...")  [var-annotated]

alerta (https://github.com/alerta/alerta)
+ alerta/models/token.py:33: error: Need type annotation for "orgs"  [var-annotated]
+ alerta/models/token.py:34: error: Need type annotation for "groups"  [var-annotated]
+ alerta/models/token.py:35: error: Need type annotation for "roles"  [var-annotated]
+ alerta/models/token.py:36: error: Need type annotation for "scopes"  [var-annotated]
+ alerta/models/permission.py:29: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/permission.py:49: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/note.py:34: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/note.py:35: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/note.py:37: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/note.py:40: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ alerta/models/note.py:40: note: Possible overload variants:
+ alerta/models/note.py:40: note:     def get(self, <nothing>, /) -> None
+ alerta/models/note.py:40: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ alerta/models/note.py:76: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/note.py:77: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/note.py:79: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/key.py:50: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/key.py:52: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/key.py:54: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/key.py:88: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/key.py:90: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/key.py:91: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/key.py:92: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "datetime"  [arg-type]
+ alerta/models/key.py:95: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/heartbeat.py:85: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/heartbeat.py:89: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "int"  [arg-type]
+ alerta/models/heartbeat.py:90: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/heartbeat.py:120: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/heartbeat.py:124: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "datetime"  [arg-type]
+ alerta/models/heartbeat.py:125: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "int"  [arg-type]
+ alerta/models/heartbeat.py:129: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:32: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:33: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:34: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:35: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:84: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:85: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:106: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/group.py:107: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/customer.py:23: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/customer.py:24: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/customer.py:44: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/customer.py:45: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/blackout.py:42: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "int"  [arg-type]
+ alerta/models/alert.py:98: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/alert.py:99: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/alert.py:173: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/alert.py:174: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:66: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:68: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:72: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:107: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:108: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:109: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:110: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/models/user.py:116: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "str"  [arg-type]
+ alerta/webhooks/prometheus.py:85: error: Argument "resource" to "Alert" has incompatible type "Optional[Any]"; expected "str"  [arg-type]

isort (https://github.com/pycqa/isort)
+ isort/output.py:328: error: Argument 1 to "add_to_line" has incompatible type "Union[Any, Tuple[]]"; expected "Optional[List[str]]"  [arg-type]
+ isort/output.py:456: error: Need type annotation for "use_comments" (hint: "use_comments: List[<type>] = ...")  [var-annotated]
+ isort/output.py:458: error: Incompatible types in assignment (expression has type "Union[Any, Tuple[]]", variable has type "List[Any]")  [assignment]
+ isort/output.py:485: error: Argument 1 to "add_to_line" has incompatible type "Union[Any, Tuple[]]"; expected "Optional[List[str]]"  [arg-type]
+ isort/output.py:666: error: No overload variant of "pop" of "dict" matches argument types "str", "None"  [call-overload]
+ isort/output.py:666: note: Possible overload variants:
+ isort/output.py:666: note:     def pop(self, <nothing>, /) -> <nothing>
+ isort/output.py:666: note:     def [_T] pop(self, <nothing>, _T, /) -> _T
+ isort/main.py:1083: error: Need type annotation for "file_names"  [var-annotated]
+ isort/main.py:1273: error: Argument 1 to "join" of "str" has incompatible type "Union[Any, Literal[True]]"; expected "Iterable[str]"  [arg-type]
+ isort/main.py:1278: error: Argument 1 to "join" of "str" has incompatible type "Union[Any, Literal[True]]"; expected "Iterable[str]"  [arg-type]

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/analysis.py:282: error: Unsupported operand types for + ("List[Optional[Expr]]" and "List[Expr]")  [operator]
+ ibis/expr/analysis.py:282: error: Unsupported operand types for + ("List[Union[Expr, None, Any]]" and "List[Expr]")  [operator]

jax (https://github.com/google/jax)
+ jax/_src/interpreters/partial_eval.py:2556: error: Argument 2 to "get" of "dict" has incompatible type "Union[int, Tracer, Var, DBIdx, InDBIdx, OutDBIdx]"; expected "BoundedAxisSize"  [arg-type]
+ jax/experimental/shard_map.py:490: error: Argument 2 to "write" has incompatible type "Union[Any, Set[Hashable], List[Set[Hashable]]]"; expected "Set[Hashable]"  [arg-type]
+ jax/experimental/jax2tf/jax_export.py:275: error: Argument 2 to "get" of "dict" has incompatible type "List[<nothing>]"; expected "bool"  [arg-type]

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/wsgi.py:84: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ src/werkzeug/wsgi.py:241: error: Unused "type: ignore" comment
+ src/werkzeug/wsgi.py:314: error: Unused "type: ignore" comment
+ src/werkzeug/debug/__init__.py:374: error: Need type annotation for "contexts"  [var-annotated]

kopf (https://github.com/nolar/kopf)
+ kopf/_cogs/structs/bodies.py:240: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_cogs/structs/bodies.py:240: note: Possible overload variants:
+ kopf/_cogs/structs/bodies.py:240: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/bodies.py:240: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/bodies.py:241: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_cogs/structs/bodies.py:241: note: Possible overload variants:
+ kopf/_cogs/structs/bodies.py:241: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/bodies.py:241: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/bodies.py:242: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_cogs/structs/bodies.py:242: note: Possible overload variants:
+ kopf/_cogs/structs/bodies.py:242: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/bodies.py:242: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/bodies.py:267: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_cogs/structs/bodies.py:267: note: Possible overload variants:
+ kopf/_cogs/structs/bodies.py:267: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/bodies.py:267: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/bodies.py:268: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_cogs/structs/bodies.py:268: note: Possible overload variants:
+ kopf/_cogs/structs/bodies.py:268: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/bodies.py:268: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/finalizers.py:14: error: No overload variant of "get" of "dict" matches argument types "str", "None"  [call-overload]
+ kopf/_cogs/structs/finalizers.py:14: note: Possible overload variants:
+ kopf/_cogs/structs/finalizers.py:14: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/finalizers.py:14: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/finalizers.py:21: error: No overload variant of "get" of "dict" matches argument types "str", "List[<nothing>]"  [call-overload]
+ kopf/_cogs/structs/finalizers.py:21: note: Possible overload variants:
+ kopf/_cogs/structs/finalizers.py:21: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/finalizers.py:21: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/finalizers.py:32: error: No overload variant of "get" of "dict" matches argument types "str", "List[<nothing>]"  [call-overload]
+ kopf/_cogs/structs/finalizers.py:32: note: Possible overload variants:
+ kopf/_cogs/structs/finalizers.py:32: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/finalizers.py:32: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/structs/finalizers.py:44: error: No overload variant of "get" of "dict" matches argument types "str", "List[<nothing>]"  [call-overload]
+ kopf/_cogs/structs/finalizers.py:44: note: Possible overload variants:
+ kopf/_cogs/structs/finalizers.py:44: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/structs/finalizers.py:44: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_cogs/configs/conventions.py:69: error: Need type annotation for "owners"  [var-annotated]
+ kopf/_cogs/configs/diffbase.py:73: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ kopf/_cogs/configs/diffbase.py:73: note: Possible overload variants:
+ kopf/_cogs/configs/diffbase.py:73: note:     def get(self, <nothing>, /) -> None
+ kopf/_cogs/configs/diffbase.py:73: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_core/actions/loggers.py:123: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_core/actions/loggers.py:123: note: Possible overload variants:
+ kopf/_core/actions/loggers.py:123: note:     def get(self, <nothing>, /) -> None
+ kopf/_core/actions/loggers.py:123: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_core/actions/loggers.py:124: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_core/actions/loggers.py:124: note: Possible overload variants:
+ kopf/_core/actions/loggers.py:124: note:     def get(self, <nothing>, /) -> None
+ kopf/_core/actions/loggers.py:124: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_core/actions/loggers.py:125: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_core/actions/loggers.py:125: note: Possible overload variants:
+ kopf/_core/actions/loggers.py:125: note:     def get(self, <nothing>, /) -> None
+ kopf/_core/actions/loggers.py:125: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_kits/hierarchies.py:113: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ kopf/_kits/hierarchies.py:113: note: Possible overload variants:
+ kopf/_kits/hierarchies.py:113: note:     def get(self, <nothing>, /) -> None
+ kopf/_kits/hierarchies.py:113: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_kits/hierarchies.py:163: error: No overload variant of "get" of "dict" matches argument types "str", "None"  [call-overload]
+ kopf/_kits/hierarchies.py:163: note: Possible overload variants:
+ kopf/_kits/hierarchies.py:163: note:     def get(self, <nothing>, /) -> None
+ kopf/_kits/hierarchies.py:163: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_kits/hierarchies.py:218: error: No overload variant of "get" of "dict" matches argument types "str", "None"  [call-overload]
+ kopf/_kits/hierarchies.py:218: note: Possible overload variants:
+ kopf/_kits/hierarchies.py:218: note:     def get(self, <nothing>, /) -> None
+ kopf/_kits/hierarchies.py:218: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_kits/hierarchies.py:226: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ kopf/_kits/hierarchies.py:226: note: Possible overload variants:
+ kopf/_kits/hierarchies.py:226: note:     def get(self, <nothing>, /) -> None
+ kopf/_kits/hierarchies.py:226: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_kits/hierarchies.py:249: error: No overload variant of "get" of "dict" matches argument types "str", "None"  [call-overload]
+ kopf/_kits/hierarchies.py:249: note: Possible overload variants:
+ kopf/_kits/hierarchies.py:249: note:     def get(self, <nothing>, /) -> None
+ kopf/_kits/hierarchies.py:249: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_kits/hierarchies.py:250: error: No overload variant of "get" of "dict" matches argument types "str", "None"  [call-overload]
+ kopf/_kits/hierarchies.py:250: note: Possible overload variants:
+ kopf/_kits/hierarchies.py:250: note:     def get(self, <nothing>, /) -> None
+ kopf/_kits/hierarchies.py:250: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_kits/hierarchies.py:251: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ kopf/_kits/hierarchies.py:251: note: Possible overload variants:
+ kopf/_kits/hierarchies.py:251: note:     def get(self, <nothing>, /) -> None
+ kopf/_kits/hierarchies.py:251: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_core/intents/registries.py:439: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ kopf/_core/intents/registries.py:439: note: Possible overload variants:
+ kopf/_core/intents/registries.py:439: note:     def get(self, <nothing>, /) -> None
+ kopf/_core/intents/registries.py:439: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_core/intents/registries.py:450: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ kopf/_core/intents/registries.py:450: note: Possible overload variants:
+ kopf/_core/intents/registries.py:450: note:     def get(self, <nothing>, /) -> None
+ kopf/_core/intents/registries.py:450: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ kopf/_core/engines/indexing.py:232: error: Need type annotation for "meta"  [var-annotated]

spark (https://github.com/apache/spark)
+ python/pyspark/sql/session.py:425: error: Item "None" of "Union[Any, str, None]" has no attribute "startswith"  [union-attr]
+ python/pyspark/sql/session.py:497: error: Item "None" of "Union[Any, str, None]" has no attribute "startswith"  [union-attr]
+ python/pyspark/sql/session.py:499: error: Argument 1 to "_start_connect_server" of "SparkSession" has incompatible type "Union[Any, str, None]"; expected "str"  [arg-type]

materialize (https://github.com/MaterializeInc/materialize)
+ misc/python/materialize/output_consistency/generators/expression_generator.py:81: error: Need type annotation for "operations_with_return_category"  [var-annotated]
+ misc/python/materialize/output_consistency/generators/expression_generator.py:91: error: Need type annotation for "types_with_values"  [var-annotated]
+ misc/python/materialize/cargo.py:58: error: Need type annotation for "features"  [var-annotated]
+ misc/python/materialize/mzbuild.py:185: error: Unsupported operand types for / ("Path" and "None")  [operator]
+ misc/python/materialize/mzbuild.py:185: note: Right operand is of type "Optional[Any]"
+ misc/python/materialize/mzbuild.py:185: error: Argument 1 to "relative_to" of "PurePath" has incompatible type "Optional[Any]"; expected "Union[str, PathLike[str]]"  [arg-type]
+ misc/python/materialize/mzbuild.py:185: note: Left operand is of type "Union[Any, Path]"
+ misc/python/materialize/mzbuild.py:224: error: Need type annotation for "bin"  [var-annotated]
+ misc/python/materialize/mzbuild.py:226: error: Need type annotation for "example"  [var-annotated]
+ misc/python/materialize/mzbuild.py:229: error: Need type annotation for "extract"  [var-annotated]
+ misc/python/materialize/mzbuild.py:230: error: Need type annotation for "rustflags"  [var-annotated]

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ pymongo/errors.py: note: In member "timeout" of class "BulkWriteError":
+ pymongo/errors.py:301: error: Need type annotation for "wces"  [var-annotated]
+ pymongo/errors.py:305: error: Need type annotation for "werrs"  [var-annotated]
+ pymongo/hello.py: note: In member "last_write_date" of class "Hello":
+ pymongo/hello.py:182: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
+ pymongo/hello.py:182: note: Possible overload variants:
+ pymongo/hello.py:182: note:     def get(self, <nothing>, /) -> None
+ pymongo/hello.py:182: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ pymongo/collection.py: note: In member "options" of class "Collection":
+ pymongo/collection.py:2323: error: Need type annotation for "options"  [var-annotated]

twine (https://github.com/pypa/twine)
+ twine/repository.py:226: error: Need type annotation for "packages"  [var-annotated]

pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/api_jwk.py:108: error: Need type annotation for "keys"  [var-annotated]

streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/runtime/uploaded_file_manager.py: note: In member "get_all_files" of class "UploadedFileManager":
+ lib/streamlit/runtime/uploaded_file_manager.py:157:20: error: Incompatible return value type (got "Union[List[UploadedFileRec], List[<nothing>]]", expected "List[UploadedFileRec]")  [return-value]

aiortc (https://github.com/aiortc/aiortc)
+ src/aiortc/rtcdtlstransport.py:242: error: Need type annotation for "pt_receivers"  [var-annotated]

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/http/request/json_request.py:32: error: Argument 1 to "_dumps" of "JsonRequest" has incompatible type "Optional[Any]"; expected "Dict[Any, Any]"  [arg-type]
+ scrapy/http/request/json_request.py:54: error: Argument 1 to "_dumps" of "JsonRequest" has incompatible type "Optional[Any]"; expected "Dict[Any, Any]"  [arg-type]
+ scrapy/utils/log.py:232: error: Incompatible return value type (got "Tuple[Union[Any, int], Optional[Any], Any]", expected "Tuple[int, str, Dict[Any, Any]]")  [return-value]
+ scrapy/core/downloader/__init__.py:120: error: Need type annotation for "slot_settings"  [var-annotated]
+ scrapy/core/http2/stream.py:172: error: Incompatible return value type (got "Union[Any, int]", expected "bool")  [return-value]

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/client_reqrep.py:388: error: Need type annotation for "mrsl_val"  [var-annotated]

black (https://github.com/psf/black)
+ src/black/lines.py:405:35: error: Need type annotation for "trailing_comma_comments"  [var-annotated]
+ src/black/files.py:120:30: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ src/black/files.py:120:30: note: Possible overload variants:
+ src/black/files.py:120:30: note:     def get(self, <nothing>, /) -> None
+ src/black/files.py:120:30: note:     def [_T] get(self, <nothing>, _T, /) -> _T
+ src/black/files.py:141:24: error: Need type annotation for "project_metadata"  [var-annotated]
+ src/black/__init__.py:1010:16: error: No overload variant of "get" of "dict" matches argument types "str", "Dict[<nothing>, <nothing>]"  [call-overload]
+ src/black/__init__.py:1010:16: note: Possible overload variants:
+ src/black/__init__.py:1010:16: note:     def get(self, <nothing>, /) -> None
+ src/black/__init__.py:1010:16: note:     def [_T] get(self, <nothing>, _T, /) -> _T

speedrun.com_global_scoreboard_webapp (https://github.com/Avasam/speedrun.com_global_scoreboard_webapp)
+ backend/services/user_updater_helpers.py:186: error: Need type annotation for "existing_group"  [var-annotated]
- backend/services/user_updater_helpers.py:190: error: Incompatible types in assignment (expression has type "Union[List

... (truncated 74 lines) ...

@JelleZijlstra
Copy link
Member

We won't be able to accept a change that introduces this many new errors. Might be worth looking into some of these to see if there's any pattern in the new errors that we can support better.

It would also be good to add some more test cases to cover dict.get; it's been a very tricky function to cover in the stubs.

@superbobry
Copy link
Contributor Author

superbobry commented Jun 10, 2023

My guess is that these errors were previously masked by the overparameterized union type, but I will have a closer look and summarize some of the causes here.

@superbobry
Copy link
Contributor Author

The two failure in pypa/pip, for example, look reasonable:

I think a type checker could use list[Any] and dict[Any, Any] in these cases. Should I file a mypy bug?

@superbobry
Copy link
Contributor Author

Here is another example: PyCQA/isort

Should this be fixed in mypy?

@JelleZijlstra
Copy link
Member

Should this be fixed in mypy?

Possibly, but you'll have to be more precise about what needs to change in mypy (and possibly other type checkers).

I haven't looked at the mypy-primer output in much detail, but it will be hard sell to merge this without some type checker changes that make the input on typed codebases less disruptive.

@superbobry
Copy link
Contributor Author

superbobry commented Jun 12, 2023

I think the necessary fix here is to specialize empty collections to Any if mypy is unable to otherwise infer their type arguments. For example,

def test(d: dict[str, Any]) -> None:
    x = d.get("foo", {})
    reveal_type(x)

currently emits Any without this PR and Any | dict[<unknown>, <unknown>] with this PR. I think a more useful behavior (which is also consistent with PEP-484) is to emit Any | dict[Any, Any].

@superbobry
Copy link
Contributor Author

superbobry commented Jun 15, 2023

We won't be able to accept a change that introduces this many new errors.

Maybe as a counter-argument: it feels wrong to accept or reject a change to typeshed based on how many breakages it introduces under a specific type checker. The goal of typeshed, as I understand it, is to provide accurate/high-quality static types for standard library and various third-party projects. Making sure that mypy, pyright or any other type checker does not regress feels like a non-goal to me.

With that in mind, what do you think about the following process:

  • Once a PR comes in, it is evaluated in isolation -- does it make sense? does it fix a bug? is it an improvement?
  • The PR is then accepted or rejected solely based on the above.
  • Type checker maintainers are responsible for resolving any breakages, introduced by the PR. Type checkers typically cary their own version typeshed, so they are in contro and can delay upgrading before the breakages are address. We could set up a bot notifying type checker maintainers about new breakages.

?

@Akuli
Copy link
Collaborator

Akuli commented Jun 15, 2023

what do you think about the following process?

I like it in many cases, and in fact we already use it. Here is the list of everything that mypy currently reverts: https://github.com/python/mypy/blob/cfec71798175fcbf030d6d114750d6fac454b3c9/misc/sync-typeshed.py#L182-L184

However, these are all relatively small improvements, and the typeshed+mypy combination is usable even without the reverts.

Typeshed follows "practicality beats purity" in many situations. It just isn't practical to break the most commonly used dict methods in the most popular type checker, even if it would be the "correct" thing to do or if we aren't "responsible" for that. Mypy could easily revert it, but it would make things difficult for people who for whatever reason want to point mypy at a custom clone of typeshed, e.g. because the stubs in the latest mypy version are too old.

@superbobry
Copy link
Contributor Author

I see where you are coming from, but I hope we can disentangle the notion of practicality from any particular type checker. The popularity of mypy does not seem relevant here.

dict is ubiquitous in Python code, so it is important to get this right. At least one of the failures described above is caused by a true type error, which was previously masked by the way dict.get is annotated. Surely, it isn't practical to keep the annotations which are known to produce false negatives in user code?

Note also that I do not propose for mypy to revert this change, but rather to find a reasonable way to accommodate it. For example, by implementing python/mypy#15433.

@AlexWaygood
Copy link
Member

FYI I think this would also have a very high impact on pyright's typechecking, not just mypy. You can see in our CI that this PR causes the job where we run pyright on our own test suite to fail, as pyright can no longer infer the returned type from various calls to dict.get()

@superbobry
Copy link
Contributor Author

superbobry commented Jun 15, 2023

Yes, pyright also flags occurrences of collection literals where the type arguments cannot be inferred from the surrounding code. This is not specific to dict.get and will fail, e.g. given

from typing import TypeVar
T = TypeVar("T")
def f(x: T) -> T: ...
def test():
  return f({})

Sidenote: this is not an error (or even a warning) by default. The tests fail due to

"typeCheckingMode": "strict",

@eltoder
Copy link
Contributor

eltoder commented Jul 11, 2023

Maybe this can be helped with an extra overload:

    @overload
    def get(self, __key: _KT, __default: _VT) -> _VT: ...
    @overload
    def get(self, __key: _KT, __default: _T) -> _VT | _T: ...

Now if mypy can prove that the default has a type acceptable for _VT, it does not need to infer unknown type variables, so empty collection literals should work. I think this similar to how it works now.

Btw, do we really need the one argument overload for get? Can it just be

    @overload
    def get(self, __key: _KT, __default: _T = None) -> _VT | _T: ...

We do need it for pop, but get and pop have different behavior when called with one argument.

@AlexWaygood
Copy link
Member

Superseded by #10501, which fixes the issue in a much less disruptive way

tungol added a commit to tungol/typeshed that referenced this pull request Dec 11, 2024
Pushing this up just to compare the mypy-primer damage as compared
with python#13222. I expect it to be more disruptive, but I'm curious how
much more. It seems similar to but dramatically less disruptive than
an older attempt at changing dict.get in python#10294.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The type of __default= in dict.pop and dict.get doesn't look right
5 participants