Skip to content
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 #17528

Closed
wants to merge 4 commits into from
Closed

Sync typeshed #17528

wants to merge 4 commits into from

Conversation

github-actions[bot]
Copy link
Contributor

Sync typeshed

Source commit:
python/typeshed@f863db6

Note that you will need to close and re-open the PR in order to trigger CI.

@AlexWaygood AlexWaygood reopened this Jul 15, 2024

This comment has been minimized.

mypybot and others added 4 commits July 23, 2024 04:02
This is allegedly causing large performance problems, see 13821

typeshed/8231 had zero hits on mypy_primer, so it's not the worst thing
to undo. Patching this in typeshed also feels weird, since there's a
more general soundness issue. If a typevar has a bound or constraint, we
might not want to solve it to a Literal.

If we can confirm the performance regression or fix the unsoundness
within mypy, I might pursue upstreaming this in typeshed.

(Reminder: add this to the sync_typeshed script once merged)
Copy link
Contributor Author

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

pandas (https://github.com/pandas-dev/pandas)
+ pandas/io/common.py:915: error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot be "_IOWrapper | BaseBuffer"  [type-var]
+ pandas/io/common.py:916: error: Unused "type: ignore" comment  [unused-ignore]

aioredis (https://github.com/aio-libs/aioredis)
- aioredis/connection.py:933: error: Unsupported right operand type for in ("bytes | memoryview | int")  [operator]
+ aioredis/connection.py:933: error: Unsupported right operand type for in ("bytes | memoryview[int] | int")  [operator]
- aioredis/connection.py:934: error: Item "memoryview" of "bytes | memoryview | int" has no attribute "split"  [union-attr]
+ aioredis/connection.py:934: error: Item "memoryview[int]" of "bytes | memoryview[int] | int" has no attribute "split"  [union-attr]
- aioredis/connection.py:934: error: Item "int" of "bytes | memoryview | int" has no attribute "split"  [union-attr]
+ aioredis/connection.py:934: error: Item "int" of "bytes | memoryview[int] | int" has no attribute "split"  [union-attr]
- aioredis/client.py:4114: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview, Any | None]", variable has type "dict[bytes | str | memoryview, Callable[[dict[str, str]], Awaitable[None]]]")  [assignment]
+ aioredis/client.py:4114: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview[int], Any | None]", variable has type "dict[bytes | str | memoryview[int], Callable[[dict[str, str]], Awaitable[None]]]")  [assignment]
- aioredis/client.py:4158: error: Argument 1 to "update" of "MutableMapping" has incompatible type "dict[bytes | str | memoryview, Any | None]"; expected "SupportsKeysAndGetItem[bytes | str | memoryview, Callable[[dict[str, str]], Awaitable[None]]]"  [arg-type]
+ aioredis/client.py:4158: error: Argument 1 to "update" of "MutableMapping" has incompatible type "dict[bytes | str | memoryview[int], Any | None]"; expected "SupportsKeysAndGetItem[bytes | str | memoryview[int], Callable[[dict[str, str]], Awaitable[None]]]"  [arg-type]
- aioredis/client.py:4172: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview, Callable[[dict[str, str]], Awaitable[None]]]", variable has type "dict[Any, Any | None]")  [assignment]
+ aioredis/client.py:4172: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview[int], Callable[[dict[str, str]], Awaitable[None]]]", variable has type "dict[Any, Any | None]")  [assignment]

ibis (https://github.com/ibis-project/ibis)
- ibis/backends/sqlite/tests/conftest.py:44: error: Incompatible types in assignment (expression has type "TextIOWrapper", variable has type "StringIO")  [assignment]
+ ibis/backends/sqlite/tests/conftest.py:44: error: Incompatible types in assignment (expression has type "TextIOWrapper[_WrappedBuffer]", variable has type "StringIO")  [assignment]

urllib3 (https://github.com/urllib3/urllib3)
+ test/test_response.py:808: error: Unused "type: ignore" comment  [unused-ignore]
+ test/test_response.py:808: error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot be "HTTPResponse"  [type-var]
+ test/test_response.py:808: note: Error code "type-var" not covered by "type: ignore" comment
+ test/test_response.py:822: error: Unused "type: ignore" comment  [unused-ignore]
+ test/test_response.py:822: error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot be "HTTPResponse"  [type-var]
+ test/test_response.py:822: note: Error code "type-var" not covered by "type: ignore" comment
+ test/test_response.py:829: error: Unused "type: ignore" comment  [unused-ignore]
+ test/test_response.py:829: error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot be "HTTPResponse"  [type-var]
+ test/test_response.py:829: note: Error code "type-var" not covered by "type: ignore" comment

rich (https://github.com/Textualize/rich)
- rich/console.py:92: error: Item "None" of "TextIOWrapper | None" has no attribute "fileno"  [union-attr]
+ rich/console.py:92: error: Item "None" of "TextIOWrapper[_WrappedBuffer] | None" has no attribute "fileno"  [union-attr]
- rich/console.py:96: error: Item "None" of "TextIOWrapper | None" has no attribute "fileno"  [union-attr]
+ rich/console.py:96: error: Item "None" of "TextIOWrapper[_WrappedBuffer] | None" has no attribute "fileno"  [union-attr]
- rich/console.py:100: error: Item "None" of "TextIOWrapper | None" has no attribute "fileno"  [union-attr]
+ rich/console.py:100: error: Item "None" of "TextIOWrapper[_WrappedBuffer] | None" has no attribute "fileno"  [union-attr]

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/capture.py:180: error: Returning Any from function declared to return "str"  [no-any-return]
+ src/_pytest/capture.py:180: error: "_WrappedBuffer" has no attribute "mode"  [attr-defined]
- src/_pytest/capture.py:205: error: Item "None" of "TextIOWrapper | None" has no attribute "encoding"  [union-attr]
+ src/_pytest/capture.py:205: error: Item "None" of "TextIOWrapper[_WrappedBuffer] | None" has no attribute "encoding"  [union-attr]
+ src/_pytest/capture.py:552: error: Incompatible return value type (got "Buffer", expected "bytes")  [return-value]
- src/_pytest/faulthandler.py:67: error: Item "None" of "TextIOWrapper | None" has no attribute "fileno"  [union-attr]
+ src/_pytest/faulthandler.py:67: error: Item "None" of "TextIOWrapper[_WrappedBuffer] | None" has no attribute "fileno"  [union-attr]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_implementations.py:1130: note:     def [R, P`2102] builds(cls, type[BuildsWithSig[type[R], P]], /, *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None | Sequence[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None] = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['none', 'partial', 'all', 'object'] | None = ..., hydra_defaults: list[str | DataClass_ | type[DataClass_] | Mapping[str, str | Sequence[str] | None]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = ..., frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]
+ src/hydra_zen/structured_configs/_implementations.py:1130: note:     def [R, P`2103] builds(cls, type[BuildsWithSig[type[R], P]], /, *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None | Sequence[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None] = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['none', 'partial', 'all', 'object'] | None = ..., hydra_defaults: list[str | DataClass_ | type[DataClass_] | Mapping[str, str | Sequence[str] | None]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = ..., frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]
- src/hydra_zen/structured_configs/_implementations.py:1130: note:     def [P`2104, R] builds(cls, Callable[P, R], /, *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None | Sequence[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None] = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['none', 'partial', 'all', 'object'] | None = ..., hydra_defaults: list[str | DataClass_ | type[DataClass_] | Mapping[str, str | Sequence[str] | None]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = ..., frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]
+ src/hydra_zen/structured_configs/_implementations.py:1130: note:     def [P`2105, R] builds(cls, Callable[P, R], /, *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None | Sequence[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]] | ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]] | Just[Callable[[Callable[..., Any]], Callable[..., Any]]] | type[Builds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[ZenPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[HydraPartialBuilds[Callable[[Callable[..., Any]], Callable[..., Any]]]] | type[Just[Callable[[Callable[..., Any]], Callable[..., Any]]]] | Callable[[Callable[..., Any]], Callable[..., Any]] | str | None] = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['none', 'partial', 'all', 'object'] | None = ..., hydra_defaults: list[str | DataClass_ | type[DataClass_] | Mapping[str, str | Sequence[str] | None]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = ..., frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]

... (truncated 8 lines) ...

vision (https://github.com/pytorch/vision)
- torchvision/models/_api.py:128: error: Unused "type: ignore" comment  [unused-ignore]

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/filesystems.py:359: error: Incompatible types in assignment (expression has type "Path", variable has type "TextIOWrapper")  [assignment]
+ src/prefect/filesystems.py:359: error: Incompatible types in assignment (expression has type "Path", variable has type "TextIOWrapper[_WrappedBuffer]")  [assignment]
- src/prefect/filesystems.py:360: error: "TextIOWrapper" has no attribute "relative_to"  [attr-defined]
+ src/prefect/filesystems.py:360: error: "TextIOWrapper[_WrappedBuffer]" has no attribute "relative_to"  [attr-defined]
- src/prefect/filesystems.py:369: error: "TextIOWrapper" has no attribute "is_dir"  [attr-defined]
+ src/prefect/filesystems.py:369: error: "TextIOWrapper[_WrappedBuffer]" has no attribute "is_dir"  [attr-defined]
- src/prefect/filesystems.py:372: error: "TextIOWrapper" has no attribute "as_posix"  [attr-defined]
+ src/prefect/filesystems.py:372: error: "TextIOWrapper[_WrappedBuffer]" has no attribute "as_posix"  [attr-defined]

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/web_fileresponse.py:70: error: Unused "type: ignore" comment  [unused-ignore]
+ aiohttp/web.py:327:25: error: Argument 2 to "TCPSite" has incompatible type "str | memoryview[Any]"; expected "str | None"  [arg-type]

werkzeug (https://github.com/pallets/werkzeug)
- tests/test_wsgi.py:158: error: Incompatible types in assignment (expression has type "TextIOWrapper", variable has type "LimitedStream")  [assignment]
+ tests/test_wsgi.py:158: error: Incompatible types in assignment (expression has type "TextIOWrapper[BufferedReader]", variable has type "LimitedStream")  [assignment]

streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/web/server/component_request_handler_test.py: note: In function "test_support_binary_files_request":
- lib/tests/streamlit/web/server/component_request_handler_test.py:195:38: error: Argument 1 to "TextIOWrapper" has incompatible type "str"; expected "_WrappedBuffer"  [arg-type]

@cdce8p
Copy link
Collaborator

cdce8p commented Jul 25, 2024

Couldn't push the test fix here, so opened a new PR: #17586.

@cdce8p cdce8p closed this Jul 25, 2024
@JelleZijlstra JelleZijlstra deleted the mypybot/sync-typeshed branch July 25, 2024 18:46
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.

3 participants