Skip to content

Sync typeshed #18930

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Sync typeshed #18930

wants to merge 9 commits into from

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Apr 16, 2025

Source commit:
python/typeshed@45c0e52

Typeshed has dropped support for Python 3.8 now! Merge only when mypy can drop support for --python-version 3.8 as well.

cdce8p and others added 9 commits April 16, 2025 12:50
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 marked this pull request as draft April 16, 2025 11:10
Copy link
Contributor

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

vision (https://github.com/pytorch/vision)
+ torchvision/datasets/utils.py:215: 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
+ torchvision/datasets/utils.py:215: 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
+ torchvision/datasets/utils.py:215: note:     def open(cls, name: str | bytes | PathLike[str] | PathLike[bytes] | Buffer | None, mode: Literal['w|gz', 'w|bz2'], 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 = ..., compresslevel: int = ...) -> TarFile

trio (https://github.com/python-trio/trio)
+ src/trio/_repl.py:26: error: Unused "type: ignore" comment  [unused-ignore]

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/filesystems.py:162: error: Value of type variable "_StrPathT" of "copytree" cannot be "Optional[str]"  [type-var]
- src/prefect/filesystems.py:162: error: Argument 2 to "copytree" has incompatible type "Optional[str]"; expected "Union[str, PathLike[str]]"  [arg-type]

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['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|gz', 'w|bz2'], 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 = ..., compresslevel: int = ...) -> TarFile

spark (https://github.com/apache/spark)
+ python/pyspark/sql/session.py:166: error: Signature of "__get__" incompatible with supertype "property"  [override]
+ python/pyspark/sql/session.py:166: note:      Superclass:
+ python/pyspark/sql/session.py:166: note:          @overload
+ python/pyspark/sql/session.py:166: note:          def __get__(self, None, type, /) -> classproperty
+ python/pyspark/sql/session.py:166: note:          @overload
+ python/pyspark/sql/session.py:166: note:          def __get__(self, Any, type | None = ..., /) -> Any
+ python/pyspark/sql/session.py:166: note:      Subclass:
+ python/pyspark/sql/session.py:166: note:          def __get__(self, instance: Any, owner: Any = ...) -> Builder

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_decorators.py:199: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], ReturnType] | Any", expected "PydanticDescriptorProxy[ReturnType]")  [return-value]
+ pydantic/_internal/_decorators.py:199: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], ReturnType] | Any | property", expected "PydanticDescriptorProxy[ReturnType]")  [return-value]

@cdce8p
Copy link
Collaborator Author

cdce8p commented Apr 16, 2025

@cdce8p cdce8p marked this pull request as ready for review April 16, 2025 15:39
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