-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Sync typeshed #12321
Sync typeshed #12321
Conversation
Source commit: python/typeshed@4e87b90
This comment has been minimized.
This comment has been minimized.
There's quite a lot of fallout. I will investigate the (possible) regressions and test failures later. |
To save you some time on a few of these:
|
Here's a PR that will fix several of the broken tests here: #12323 |
This comment has been minimized.
This comment has been minimized.
This doesn't seem right,
|
Being fixed here python/typeshed#7491 |
python/typeshed#7491 has now been merged, so I think this particular regression has now been fixed on typeshed's master branch (thanks again for your help reviewing @graingert). |
Diff from mypy_primer, showing the effect of this PR on open source code: boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/boost.py:547: error: Need type annotation for "task"
+ boostedblob/boost.py:547: error: Argument 1 to "create_task" has incompatible type "Awaitable[T]"; expected "Union[Generator[Any, None, <nothing>], Coroutine[Any, Any, <nothing>]]"
bidict (https://github.com/jab/bidict)
+ bidict/_frozenbidict.py:38: error: Unused "type: ignore" comment
paasta (https://github.com/yelp/paasta)
- paasta_tools/instance/kubernetes.py:571: error: Argument 1 to "append" of "list" has incompatible type "Task[Sequence[Any]]"; expected "Future[Dict[str, Any]]"
+ paasta_tools/instance/kubernetes.py:563: error: Need type annotation for "pods_task"
+ paasta_tools/instance/kubernetes.py:564: error: Argument 1 to "create_task" has incompatible type "Awaitable[Sequence[Any]]"; expected "Union[Generator[Any, None, <nothing>], Coroutine[Any, Any, <nothing>]]"
+ paasta_tools/instance/kubernetes.py:1054: error: Need type annotation for "pods_task"
+ paasta_tools/instance/kubernetes.py:1055: error: Argument 1 to "create_task" has incompatible type "Awaitable[Sequence[Any]]"; expected "Union[Generator[Any, None, <nothing>], Coroutine[Any, Any, <nothing>]]"
+ paasta_tools/instance/kubernetes.py:1239: error: Need type annotation for "pods_task"
+ paasta_tools/instance/kubernetes.py:1240: error: Argument 1 to "create_task" has incompatible type "Awaitable[Sequence[Any]]"; expected "Union[Generator[Any, None, <nothing>], Coroutine[Any, Any, <nothing>]]"
pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/class_validators.py:332: error: Need type annotation for "all_attributes" [var-annotated]
+ pydantic/class_validators.py:332: error: Argument 1 to "ChainMap" has incompatible type "*List[MappingProxyType[str, Any]]"; expected "MutableMapping[<nothing>, <nothing>]" [arg-type]
pandera (https://github.com/pandera-dev/pandera)
+ pandera/checks.py:74: error: Argument 1 to "ChainMap" has incompatible type "MappingProxyType[str, Any]"; expected "MutableMapping[str, Callable[..., Any]]" [arg-type]
+ pandera/model.py:373: error: Need type annotation for "attrs" (hint: "attrs: Dict[<type>, <type>] = ...") [var-annotated]
anyio (https://github.com/agronholm/anyio)
+ src/anyio/from_thread.py:397: error: Argument 2 to "submit" of "Executor" has incompatible type "Callable[[], Coroutine[Any, Any, None]]"; expected "Callable[..., Coroutine[Any, Any, T_Retval]]" [arg-type]
+ src/anyio/_backends/_asyncio.py:1365: error: Redundant cast to "StreamProtocol" [redundant-cast]
+ src/anyio/_backends/_asyncio.py:1555: error: Redundant cast to "DatagramProtocol" [redundant-cast]
+ src/anyio/_backends/_asyncio.py:1571: error: Unused "type: ignore" comment
pip (https://github.com/pypa/pip)
+ src/pip/_internal/network/session.py:406: error: Argument 1 to "ip_address" has incompatible type "Optional[str]"; expected "Union[int, str, bytes, IPv4Address, IPv6Address]"
+ src/pip/_internal/network/lazy_wheel.py:139: error: "__exit__" of "_TemporaryFileWrapper" does not return a value
steam.py (https://github.com/Gobot1234/steam.py)
- steam/_const.py:16: error: Module "typing_extensions" has no attribute "Never" [attr-defined]
- steam/enums.py:118: error: Incompatible types in "yield from" (actual type "Enum", expected type "E") [misc]
- steam/enums.py:181: note: def [_TT <: type] __new__(cls, cls: Type[_TT], str, Tuple[type, ...], Dict[str, Any], **kwds: Any) -> _TT
+ steam/enums.py:181: note: def [Self] __new__(cls, cls: Type[Self], str, Tuple[type, ...], Dict[str, Any], **kwds: Any) -> Self
- steam/manifest.py:45: error: Module "typing_extensions" has no attribute "Never" [attr-defined]
+ steam/clan.py:555: error: Parameter 1 of Literal[...] is invalid [misc]
+ steam/clan.py:567: error: Variable "steam.enums.ClanEvent.Other" is not valid as a type [valid-type]
+ steam/clan.py:567: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
+ steam/clan.py:567: error: Parameter 1 of Literal[...] is invalid [misc]
+ steam/http.py:114: error: Variable "steam.http.StrOrURL" is not valid as a type [valid-type]
- steam/clan.py:555: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
+ steam/http.py:114: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/debug/tbtools.py:378: error: Unsupported operand types for - ("None" and "int") [operator]
+ src/werkzeug/debug/tbtools.py:378: note: Left operand is of type "Optional[int]"
+ src/werkzeug/test.py:94: error: Incompatible types in assignment (expression has type "Callable[[bytes], int]", variable has type "Callable[[Arg(bytes, 's')], int]") [assignment]
- tests/test_wrappers.py:1109: note: Use "-> None" if function does not return a value
- tests/test_wrappers.py:1123: error: Function is missing a return type annotation [no-untyped-def]
- tests/test_wrappers.py:1123: note: Use "-> None" if function does not return a value
- tests/test_wrappers.py:1132: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
+ tests/test_wrappers.py:1109: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
zulip (https://github.com/zulip/zulip)
+ zerver/lib/test_console_output.py:123: error: Return type "Optional[bool]" of "__exit__" incompatible with return type "None" in supertype "IO" [override]
tornado (https://github.com/tornadoweb/tornado)
+ tornado/platform/asyncio.py:662: error: Return type "None" of "remove_reader" incompatible with return type "bool" in supertype "AbstractEventLoop"
+ tornado/platform/asyncio.py:666: error: Return type "None" of "remove_writer" incompatible with return type "bool" in supertype "AbstractEventLoop"
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/locale/__init__.py: note: In member "__radd__" of class "_TranslationProxy":
+ sphinx/locale/__init__.py:62:5: error: Argument 1 of "__radd__" is incompatible with supertype "UserString"; supertype defines the argument type as "object"
+ sphinx/locale/__init__.py:62:5: note: This violates the Liskov substitution principle
+ sphinx/locale/__init__.py:62:5: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ sphinx/locale/__init__.py:62:5: error: Return type "str" of "__radd__" incompatible with return type "_TranslationProxy" in supertype "UserString"
+ sphinx/locale/__init__.py: note: In member "__rmod__" of class "_TranslationProxy":
+ sphinx/locale/__init__.py:68:5: error: Return type "str" of "__rmod__" incompatible with return type "_TranslationProxy" in supertype "UserString"
+ sphinx/locale/__init__.py: note: In member "__rmul__" of class "_TranslationProxy":
+ sphinx/locale/__init__.py:74:5: error: Return type "str" of "__rmul__" incompatible with return type "_TranslationProxy" in supertype "UserString"
+ sphinx/domains/python.py:1442: error: Unused "type: ignore" comment
pylint (https://github.com/pycqa/pylint)
+ pylint/config/arguments_manager.py:84: error: Argument "action" to "add_argument" of "_ActionsContainer" has incompatible type "str"; expected "Union[Type[Action], Literal['store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count', 'help', 'version', 'extend']]" [arg-type]
+ pylint/config/arguments_manager.py:129: error: Argument "action" to "add_argument" of "_ActionsContainer" has incompatible type "str"; expected "Union[Type[Action], Literal['store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count', 'help', 'version', 'extend']]" [arg-type]
python-chess (https://github.com/niklasf/python-chess)
+ chess/engine.py:122: error: Unused "type: ignore" comment
+ chess/engine.py:123: error: Unused "type: ignore" comment
+ chess/engine.py:1214: error: Unused "type: ignore" comment
pyp (https://github.com/hauntsaninja/pyp)
+ pyp.py:643: error: Argument 1 to "code_for_line" has incompatible type "Optional[int]"; expected "int"
+ pyp.py:643: note: Error code "arg-type" not covered by "type: ignore" comment
pylox (https://github.com/sco1/pylox)
- pylox/containers/array.py:84: error: All overload variants of "pop" of "MutableMapping" require at least one argument [call-overload]
+ pylox/containers/array.py:84: error: All overload variants of "pop" of "dict" require at least one argument [call-overload]
- 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, Union[Any, _T]) -> Union[Any, _T]
websockets (https://github.com/aaugustin/websockets)
+ src/websockets/legacy/client.py:641: error: "_ProtocolT" has no attribute "close"
+ src/websockets/legacy/client.py:655: error: Incompatible types in assignment (expression has type "WebSocketClientProtocol", variable has type "_ProtocolT")
+ src/websockets/legacy/client.py:658: error: "_ProtocolT" has no attribute "handshake"
+ src/websockets/legacy/client.py:660: error: "_ProtocolT" has no attribute "origin"
+ src/websockets/legacy/client.py:661: error: "_ProtocolT" has no attribute "available_extensions"
+ src/websockets/legacy/client.py:662: error: "_ProtocolT" has no attribute "available_subprotocols"
+ src/websockets/legacy/client.py:663: error: "_ProtocolT" has no attribute "extra_headers"
+ src/websockets/legacy/client.py:666: error: "_ProtocolT" has no attribute "fail_connection"
+ src/websockets/legacy/client.py:667: error: "_ProtocolT" has no attribute "wait_closed"
+ src/websockets/legacy/client.py:671: error: "_ProtocolT" has no attribute "fail_connection"
+ src/websockets/legacy/client.py:672: error: "_ProtocolT" has no attribute "wait_closed"
+ src/websockets/legacy/client.py:676: error: Incompatible return value type (got "_ProtocolT", expected "WebSocketClientProtocol")
xarray (https://github.com/pydata/xarray)
+ xarray/core/alignment.py:534: error: Argument 1 to "_reindex_one" of "Aligner" has incompatible type "Tuple[DataAlignable, Dict[Tuple[Tuple[Tuple[Hashable, Tuple[Hashable, ...]], ...], Type[Index]], Index]]"; expected "DataAlignable" [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/connector.py:1298: error: Redundant cast to "ResponseHandler" [redundant-cast]
freqtrade (https://github.com/freqtrade/freqtrade)
+ freqtrade/data/history/jsondatahandler.py:27: error: Signature of "ohlcv_get_available_data" incompatible with supertype "IDataHandler"
+ freqtrade/data/history/jsondatahandler.py:49: error: Signature of "ohlcv_get_pairs" incompatible with supertype "IDataHandler"
+ freqtrade/data/history/jsondatahandler.py:140: error: Signature of "trades_get_pairs" incompatible with supertype "IDataHandler"
+ freqtrade/data/history/hdf5datahandler.py:25: error: Signature of "ohlcv_get_available_data" incompatible with supertype "IDataHandler"
+ freqtrade/data/history/hdf5datahandler.py:48: error: Signature of "ohlcv_get_pairs" incompatible with supertype "IDataHandler"
+ freqtrade/data/history/hdf5datahandler.py:145: error: Signature of "trades_get_pairs" incompatible with supertype "IDataHandler"
core (https://github.com/home-assistant/core)
+ homeassistant/util/async_.py:158: error: Item "None" of "Optional[str]" has no attribute "strip" [union-attr]
+ homeassistant/util/async_.py:164: error: Item "None" of "Optional[str]" has no attribute "strip" [union-attr]
+ homeassistant/helpers/frame.py:112: error: Item "None" of "Optional[str]" has no attribute "strip" [union-attr]
+ homeassistant/core.py:441: error: Argument 1 to "create_task" of "AbstractEventLoop" has incompatible type "Awaitable[_R]"; expected "Union[Coroutine[Any, Any, _R], Generator[Any, None, _R]]" [arg-type]
+ homeassistant/core.py:472: error: Need type annotation for "task" [var-annotated]
+ homeassistant/core.py:472: error: Argument 1 to "create_task" of "AbstractEventLoop" has incompatible type "Awaitable[_R]"; expected "Union[Coroutine[Any, Any, <nothing>], Generator[Any, None, <nothing>]]" [arg-type]
+ homeassistant/runner.py:51: error: Unused "type: ignore[misc, valid-type]" comment
+ homeassistant/runner.py:62: error: "HassEventLoopPolicy" has no attribute "_loop_factory" [attr-defined]
+ homeassistant/runner.py:62: note: Error code "attr-defined" not covered by "type: ignore" comment
+ homeassistant/components/fritz/config_flow.py:133: error: Argument 1 to "ip_address" has incompatible type "Optional[str]"; expected "Union[int, str, bytes, IPv4Address, IPv6Address]" [arg-type]
+ homeassistant/components/statistics/sensor.py:648: error: Argument "method" to "quantiles" has incompatible type "str"; expected "Literal['inclusive', 'exclusive']" [arg-type]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/_libs/tslibs/timestamps.pyi:116: error: Return type "datetime" of "replace" incompatible with return type "Timestamp" in supertype "datetime" [override]
+ pandas/_libs/tslibs/timestamps.pyi:116: error: Signature of "replace" incompatible with supertype "date" [override]
+ pandas/_libs/tslibs/timestamps.pyi:116: note: Superclass:
+ pandas/_libs/tslibs/timestamps.pyi:116: note: def replace(self, year: int = ..., month: int = ..., day: int = ...) -> Timestamp
+ pandas/_libs/tslibs/timestamps.pyi:116: note: Subclass:
+ pandas/_libs/tslibs/timestamps.pyi:116: note: def replace(self, year: int = ..., month: int = ..., day: int = ..., hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[tzinfo] = ..., fold: int = ...) -> datetime
+ pandas/_config/localization.py:48: error: Argument 1 to "join" of "str" has incompatible type "Tuple[Optional[str], Optional[str]]"; expected "Iterable[str]" [arg-type]
+ pandas/io/parsers/base_parser.py:1044: error: Incompatible types in assignment (expression has type "defaultdict[str, Union[ExtensionDtype, str, dtype[Any], Type[object], Dict[Hashable, Union[ExtensionDtype, Union[str, dtype[Any], Type[str], Type[float], Type[int], Type[complex], Type[bool], Type[object]]]]]]", variable has type "Optional[Union[Union[ExtensionDtype, Union[str, dtype[Any], Type[str], Type[float], Type[int], Type[complex], Type[bool], Type[object]]], Dict[Hashable, Union[ExtensionDtype, Union[str, dtype[Any], Type[str], Type[float], Type[int], Type[complex], Type[bool], Type[object]]]]]]") [assignment]
+ pandas/io/parsers/base_parser.py:1045: error: Unused "type: ignore[arg-type, return-value]" comment
+ pandas/io/parsers/base_parser.py:1066: error: Value of type "Optional[Union[Union[ExtensionDtype, Union[str, dtype[Any], Type[str], Type[float], Type[int], Type[complex], Type[bool], Type[object]]], Dict[Hashable, Union[ExtensionDtype, Union[str, dtype[Any], Type[str], Type[float], Type[int], Type[complex], Type[bool], Type[object]]]]]]" is not indexable [index]
+ pandas/io/parsers/base_parser.py:1073: error: Value of type "Optional[Union[Union[ExtensionDtype, Union[str, dtype[Any], Type[str], Type[float], Type[int], Type[complex], Type[bool], Type[object]]], Dict[Hashable, Union[ExtensionDtype, Union[str, dtype[Any], Type[str], Type[float], Type[int], Type[complex], Type[bool], Type[object]]]]]]" is not indexable [index]
|
I investigated most of the remaining errors. A few things look like real regressions, but since they don't seem to cause a lot of trouble, I'm going to merge this now and file issues (or create PRs) about them afterwards (next week). |
These were introduced in python#7329 and they cause false positives in code that used to be accepted before. There was a false positive in https://github.com/pycqa/pylint (encountered in python/mypy#12321) and I also saw false positives in an internal codebase. I suggest not using literal types here, since they can be kind of awkward to annotate in callers that don't pass a literal string. Rrequiring callers to write annotations like `Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="]` is not very user friendly.
Source commit:
python/typeshed@4e87b90