Skip to content

Conversation

@cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jul 15, 2025

Source commit:
python/typeshed@84e41f2

mypybot and others added 7 commits July 15, 2025 00:07
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)
@cdce8p cdce8p mentioned this pull request Jul 15, 2025
@github-actions
Copy link
Contributor

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:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None, mode: Literal['r|*', 'r|', 'r|gz', 'r|bz2', 'r|xz'], fileobj: _Fileobj | None = ..., bufsize: int = ..., *, format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile
+ pandas/io/common.py:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None, mode: Literal['r|*', 'r|', 'r|gz', 'r|bz2', 'r|xz', 'r|zst'], fileobj: _Fileobj | None = ..., bufsize: int = ..., *, format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile
- pandas/io/common.py:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None = ..., *, mode: Literal['r|*', 'r|', 'r|gz', 'r|bz2', 'r|xz'], fileobj: _Fileobj | None = ..., bufsize: int = ..., format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile
+ pandas/io/common.py:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None = ..., *, mode: Literal['r|*', 'r|', 'r|gz', 'r|bz2', 'r|xz', 'r|zst'], fileobj: _Fileobj | None = ..., bufsize: int = ..., format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile
- pandas/io/common.py:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None, mode: Literal['w|', 'w|xz'], fileobj: _Fileobj | None = ..., bufsize: int = ..., *, format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile
+ pandas/io/common.py:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None, mode: Literal['w|', 'w|xz', 'w|zst'], fileobj: _Fileobj | None = ..., bufsize: int = ..., *, format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile
- pandas/io/common.py:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None = ..., *, mode: Literal['w|', 'w|xz'], fileobj: _Fileobj | None = ..., bufsize: int = ..., format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile
+ pandas/io/common.py:995: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None = ..., *, mode: Literal['w|', 'w|xz', 'w|zst'], fileobj: _Fileobj | None = ..., bufsize: int = ..., format: int | None = ..., tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ...) -> TarFile

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/ext/commands/utils.py:43: note:          def get(self, str, /, default: _VT) -> _VT
+ steam/ext/commands/utils.py:43: note:          @overload
- steam/ext/commands/utils.py:43: note:          def [_T] get(self, str, /, default: _VT | _T) -> _VT | _T
+ steam/ext/commands/utils.py:43: note:          def [_T] get(self, str, /, default: _T) -> _VT | _T

django-stubs (https://github.com/typeddjango/django-stubs)
+ django-stubs/utils/datastructures.pyi:65: error: Unused "type: ignore" comment  [unused-ignore]

spack (https://github.com/spack/spack)
+ lib/spack/spack/cmd/style.py:666: error: Incompatible types in assignment (expression has type "str | bytes | int | float | complex | EllipsisType | None", variable has type "str")  [assignment]

pyodide (https://github.com/pyodide/pyodide)
+ pyodide-build/pyodide_build/xbuildenv_releases.py:220: note:     def get(self, str, /, default: str) -> str
- pyodide-build/pyodide_build/xbuildenv_releases.py:220: note:     def [_T] get(self, str, /, default: str | _T) -> str | _T
+ pyodide-build/pyodide_build/xbuildenv_releases.py:220: note:     def [_T] get(self, str, /, default: _T) -> str | _T

ignite (https://github.com/pytorch/ignite)
+ ignite/handlers/visdom_logger.py:182: error: Redundant cast to "str"  [redundant-cast]

operator (https://github.com/canonical/operator)
+ ops/model.py:1025: note:          def get(self, str, /, default: Binding) -> Binding
+ ops/model.py:1025: note:          @overload
- ops/model.py:1025: note:          def [_T] get(self, str, /, default: Binding | _T) -> Binding | _T
+ ops/model.py:1025: note:          def [_T] get(self, str, /, default: _T) -> Binding | _T

starlette (https://github.com/encode/starlette)
+ starlette/requests.py:137: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]

discord.py (https://github.com/Rapptz/discord.py)
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/typing.pyi:1014: note: "update" of "TypedDict" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/typing.pyi:1015: note: "update" of "TypedDict" defined here

core (https://github.com/home-assistant/core)
+ homeassistant/components/transmission/coordinator.py:63: error: Returning Any from function declared to return "int"  [no-any-return]
+ homeassistant/components/transmission/coordinator.py:68: error: Returning Any from function declared to return "str"  [no-any-return]
+ homeassistant/components/islamic_prayer_times/coordinator.py:57: error: Returning Any from function declared to return "str"  [no-any-return]
+ homeassistant/components/islamic_prayer_times/coordinator.py:71: error: Returning Any from function declared to return "str"  [no-any-return]
+ homeassistant/components/islamic_prayer_times/coordinator.py:76: error: Returning Any from function declared to return "str"  [no-any-return]
+ homeassistant/components/bthome/coordinator.py:48: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/androidtv_remote/helpers.py:30: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/xiaomi_ble/coordinator.py:70: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/unifiprotect/data.py:96: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/unifiprotect/data.py:101: error: Returning Any from function declared to return "int"  [no-any-return]
+ homeassistant/components/shelly/utils.py:454: error: Returning Any from function declared to return "int"  [no-any-return]
+ homeassistant/components/mikrotik/coordinator.py:86: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/mikrotik/coordinator.py:91: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/bthome/device_trigger.py:73: error: Returning Any from function declared to return "list[str]"  [no-any-return]
+ homeassistant/components/squeezebox/media_player.py:290: error: Returning Any from function declared to return "int"  [no-any-return]
+ homeassistant/components/shelly/coordinator.py:166: error: Returning Any from function declared to return "int"  [no-any-return]

@cdce8p
Copy link
Collaborator Author

cdce8p commented Jul 15, 2025

@hauntsaninja hauntsaninja merged commit b546953 into python:master Jul 16, 2025
20 checks passed
@hauntsaninja
Copy link
Collaborator

Thank you!

@cdce8p cdce8p deleted the sync-typeshed branch July 16, 2025 08:50
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