Skip to content

Conversation

@cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Oct 16, 2024

The automatic sync failed.

Source commit:
python/typeshed@2370b8b

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@cdce8p
Copy link
Collaborator Author

cdce8p commented Oct 16, 2024

Mypy primer analysis

@JelleZijlstra
Copy link
Member

This one might get reverted soon

I just merged the revert.

cdce8p and others added 5 commits October 16, 2024 16:36
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
Copy link
Collaborator Author

cdce8p commented Oct 16, 2024

This one might get reverted soon

I just merged the revert.

Rebased and did a new sync. The diff https://github.com/python/mypy/compare/68c34dafd187e0552a4b970c4c27b4ce164fc66c..b328845f848ba1f19a625acd5f6a2c976118f039

@github-actions
Copy link
Contributor

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

mypy_primer (https://github.com/hauntsaninja/mypy_primer)
+ mypy_primer/utils.py:173: error: Unused "type: ignore" comment  [unused-ignore]

operator (https://github.com/canonical/operator)
- ops/pebble.py:1878: error: Argument 1 of "write" is incompatible with supertype "BufferedIOBase"; supertype defines the argument type as "Buffer"  [override]
+ ops/pebble.py:1878: error: Argument 1 of "write" is incompatible with supertype "_BufferedIOBase"; supertype defines the argument type as "Buffer"  [override]
- ops/pebble.py:1902: error: Return type "str | bytes" of "read" incompatible with return type "bytes" in supertype "BufferedIOBase"  [override]
+ ops/pebble.py:1902: error: Return type "str | bytes" of "read" incompatible with return type "bytes" in supertype "_BufferedIOBase"  [override]
- ops/pebble.py:1902: error: Argument 1 of "read" is incompatible with supertype "BufferedIOBase"; supertype defines the argument type as "int | None"  [override]
+ ops/pebble.py:1902: error: Argument 1 of "read" is incompatible with supertype "_BufferedIOBase"; supertype defines the argument type as "int | None"  [override]
- ops/pebble.py:1935: error: Return type "str | bytes" of "read1" incompatible with return type "bytes" in supertype "BufferedIOBase"  [override]
+ ops/pebble.py:1935: error: Return type "str | bytes" of "read1" incompatible with return type "bytes" in supertype "_BufferedIOBase"  [override]

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/http2/connection.py:143: error: Signature of "putheader" incompatible with supertype "HTTPConnection"  [override]
+ src/urllib3/http2/connection.py:143: note:      Superclass:
+ src/urllib3/http2/connection.py:143: note:          def putheader(self, header: str | bytes, *values: Buffer | str | int) -> None
+ src/urllib3/http2/connection.py:143: note:      Subclass:
+ src/urllib3/http2/connection.py:143: note:          def putheader(self, header: str | bytes, *values: str | bytes) -> None

pip (https://github.com/pypa/pip)
+ src/pip/_internal/utils/unpacking.py:179: error: No overload variant of "open" matches argument types "str", "str", "str"  [call-overload]
+ src/pip/_internal/utils/unpacking.py:179: note: Possible overload variants:
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., mode: Literal['r', 'r:*', 'r:', 'r:gz', 'r:bz2', 'r:xz'] = ..., fileobj: IO[bytes] | 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
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None, mode: Literal['x', 'x:', 'a', 'a:', 'w', 'w:'], 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
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: Literal['x', 'x:', 'a', 'a:', 'w', 'w:'], 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
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None, mode: Literal['x:gz', 'x:bz2', '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
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: Literal['x:gz', 'x:bz2', '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
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None, mode: Literal['x:xz', '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 = ..., preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...) -> TarFile
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: Literal['x:xz', '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 = ..., preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...) -> TarFile
+ src/pip/_internal/utils/unpacking.py:179: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: str, fileobj: IO[bytes] | 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 = ..., preset: int | None = ...) -> TarFile

paasta (https://github.com/yelp/paasta)
- paasta_tools/cli/cmds/local_run.py:980: error: Argument 1 to "write" of "TextIOBase" has incompatible type "Union[str, bytes]"; expected "str"  [arg-type]
+ paasta_tools/cli/cmds/local_run.py:980: error: Argument 1 to "write" of "_TextIOBase" has incompatible type "Union[str, bytes]"; expected "str"  [arg-type]

comtypes (https://github.com/enthought/comtypes)
- comtypes/typeinfo.py:511: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/typeinfo.py:511: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:511: note: Possible overload variants:
+ comtypes/typeinfo.py:511: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:511: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/typeinfo.py:830: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
- comtypes/typeinfo.py:842: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
- comtypes/typeinfo.py:868: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
- comtypes/typeinfo.py:1036: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
+ comtypes/typeinfo.py:830: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:830: note: Possible overload variants:
+ comtypes/typeinfo.py:830: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:830: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/typeinfo.py:842: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:842: note: Possible overload variants:
+ comtypes/typeinfo.py:842: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:842: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/typeinfo.py:868: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:868: note: Possible overload variants:
+ comtypes/typeinfo.py:868: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:868: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/typeinfo.py:1036: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:1036: note: Possible overload variants:
+ comtypes/typeinfo.py:1036: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:1036: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/typeinfo.py:1102: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/typeinfo.py:1102: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:1102: note: Possible overload variants:
+ comtypes/typeinfo.py:1102: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:1102: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/safearray.py:70: error: Unused "type: ignore" comment  [unused-ignore]
- comtypes/errorinfo.py:13: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/errorinfo.py:13: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/errorinfo.py:13: note: Possible overload variants:
+ comtypes/errorinfo.py:13: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/errorinfo.py:13: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/errorinfo.py:24: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/errorinfo.py:24: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/errorinfo.py:24: note: Possible overload variants:
+ comtypes/errorinfo.py:24: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/errorinfo.py:24: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/errorinfo.py:42: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/errorinfo.py:42: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/errorinfo.py:42: note: Possible overload variants:
+ comtypes/errorinfo.py:42: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/errorinfo.py:42: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/unknwn.py:503: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
+ comtypes/_post_coinit/unknwn.py:503: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/unknwn.py:503: note: Possible overload variants:
+ comtypes/_post_coinit/unknwn.py:503: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/unknwn.py:503: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:51: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/_post_coinit/misc.py:51: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:51: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:51: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:51: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:80: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
- comtypes/_post_coinit/misc.py:81: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/_post_coinit/misc.py:80: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:80: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:80: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:80: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/_post_coinit/misc.py:81: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:81: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:81: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:81: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:188: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/_post_coinit/misc.py:188: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:188: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:188: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:188: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:242: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
- comtypes/_post_coinit/misc.py:245: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
+ comtypes/_post_coinit/misc.py:242: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:242: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:242: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:242: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/_post_coinit/misc.py:245: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:245: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:245: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:245: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]

vision (https://github.com/pytorch/vision)
+ torchvision/datasets/utils.py:215: error: No overload variant of "open" matches argument types "str | Path", "str"  [call-overload]
+ torchvision/datasets/utils.py:215: note: Possible overload variants:
+ torchvision/datasets/utils.py:215: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., mode: Literal['r', 'r:*', 'r:', 'r:gz', 'r:bz2', 'r:xz'] = ..., fileobj: IO[bytes] | 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(name: str | bytes | PathLike[str] | PathLike[bytes] | None, mode: Literal['x', 'x:', 'a', 'a:', 'w', 'w:'], 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(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: Literal['x', 'x:', 'a', 'a:', 'w', 'w:'], 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(name: str | bytes | PathLike[str] | PathLike[bytes] | None, mode: Literal['x:gz', 'x:bz2', '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
+ torchvision/datasets/utils.py:215: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: Literal['x:gz', 'x:bz2', '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
+ torchvision/datasets/utils.py:215: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None, mode: Literal['x:xz', '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 = ..., preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...) -> TarFile
+ torchvision/datasets/utils.py:215: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: Literal['x:xz', '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 = ..., preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...) -> TarFile
+ torchvision/datasets/utils.py:215: note:     def open(name: str | bytes | PathLike[str] | PathLike[bytes] | None = ..., *, mode: str, fileobj: IO[bytes] | 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 = ..., preset: int | None = ...) -> TarFile

werkzeug (https://github.com/pallets/werkzeug)
- tests/test_wsgi.py:159: error: Argument 1 to "load" has incompatible type "LimitedStream"; expected "SupportsRead[str | bytes]"  [arg-type]
- tests/test_wsgi.py:159: note: Following member(s) of "LimitedStream" have conflicts:
- tests/test_wsgi.py:159: note:     Expected:
- tests/test_wsgi.py:159: note:         def read(self, int = ..., /) -> str | bytes
- tests/test_wsgi.py:159: note:     Got:
- tests/test_wsgi.py:159: note:         def read(self, int = ..., /) -> bytes | None

@hauntsaninja hauntsaninja merged commit 946c1bf into python:master Oct 17, 2024
18 checks passed
@hauntsaninja
Copy link
Collaborator

Thank you!

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.

4 participants