Skip to content

Conversation

@cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Aug 30, 2024

The automatic sync failed due to a merge conflict.

Source commit:
python/typeshed@661fe27

cdce8p and others added 5 commits August 30, 2024 12:58
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)
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/v1/json.py:80: error: Argument 1 to "asdict" has incompatible type "DataclassInstance | type[DataclassInstance]"; expected "DataclassInstance"  [arg-type]
- pydantic/v1/json.py:80: error: No overload variant of "asdict" matches argument type "type[DataclassInstance]"  [call-overload]
- pydantic/v1/json.py:80: note: Possible overload variants:
- pydantic/v1/json.py:80: note:     def asdict(obj: DataclassInstance) -> dict[str, Any]
- pydantic/v1/json.py:80: note:     def [_T] asdict(obj: DataclassInstance, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T

pip (https://github.com/pypa/pip)
+ src/pip/_internal/network/lazy_wheel.py:162: error: Unused "type: ignore" comment  [unused-ignore]

urllib3 (https://github.com/urllib3/urllib3)
+ test/test_ssltransport.py:451: error: Unused "type: ignore" comment  [unused-ignore]
+ test/test_ssltransport.py:451: error: Argument 1 to "write" of "IO" has incompatible type "bytes"; expected "str"  [arg-type]
+ test/test_ssltransport.py:451: note: Error code "arg-type" not covered by "type: ignore" comment

koda-validate (https://github.com/keithasaurus/koda-validate)
+ koda_validate/typehints.py:119: error: Argument 1 to "DataclassValidator" has incompatible type "DataclassInstance | type[DataclassInstance]"; expected "type[Any]"  [arg-type]
+ koda_validate/signature.py:82: error: Argument 1 to "DataclassValidator" has incompatible type "DataclassInstance | type[DataclassInstance]"; expected "type[Any]"  [arg-type]
+ koda_validate/signature.py:82: error: Argument 1 to "dataclass_no_coerce" has incompatible type "DataclassInstance | type[DataclassInstance]"; expected "type[DataclassInstance]"  [arg-type]

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/commands/check.py:18: error: Unused "type: ignore" comment  [unused-ignore]

rich (https://github.com/Textualize/rich)
- rich/progress.py:179: error: Definition of "writelines" in base class "IOBase" is incompatible with definition in base class "IO"  [misc]

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/_io/pprint.py:114: error: Unused "type: ignore" comment  [unused-ignore]
+ src/_pytest/_io/pprint.py:116: error: "DataclassInstance" has no attribute "__dataclass_params__"  [attr-defined]
+ src/_pytest/_io/pprint.py:122: error: Unused "type: ignore" comment  [unused-ignore]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- 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 [R, P`2109] 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`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]]
+ src/hydra_zen/structured_configs/_implementations.py:1130: note:     def [P`2111, 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) ...

core (https://github.com/home-assistant/core)
+ homeassistant/util/frozen_dataclass_compat.py:114: error: Argument 1 to "__new__" of "object" has incompatible type "DataclassInstance | type[DataclassInstance]"; expected "type[DataclassInstance]"  [arg-type]

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/executors.py: note: In member "run_jobs" of class "SingleJobExecutor":
+ cwltool/executors.py:251:34: error: Argument "file" to "print" has incompatible type "IO[bytes] | TextIO | IO[str] | None"; expected "SupportsWrite[str] | None"  [arg-type]

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/platform/windows.py:98: error: Argument 1 to "read" has incompatible type "BufferedIOBase"; expected "IO[bytes]"  [arg-type]
+ mitmproxy/platform/windows.py:103: error: Argument 1 to "read" has incompatible type "BufferedIOBase"; expected "IO[bytes]"  [arg-type]
+ mitmproxy/platform/windows.py:112: error: Argument 2 to "write" has incompatible type "BufferedIOBase"; expected "IO[bytes]"  [arg-type]

werkzeug (https://github.com/pallets/werkzeug)
- tests/test_wrappers.py:1216: error: No overload variant of "ZipFile" matches argument types "ResponseStream", "str"  [call-overload]
- tests/test_wrappers.py:1216: note: Possible overload variants:
- tests/test_wrappers.py:1216: note:     def __init__(self, file: str | PathLike[str] | IO[bytes], mode: Literal['r'] = ..., compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: str | None) -> ZipFile
- tests/test_wrappers.py:1216: note:     def __init__(self, file: str | PathLike[str] | IO[bytes], mode: Literal['r', 'w', 'x', 'a'] = ..., compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile

xarray-dataclasses (https://github.com/astropenguin/xarray-dataclasses)
- xarray_dataclasses/typing.py:300: error: Unused "type: ignore" comment  [unused-ignore]

@cdce8p
Copy link
Collaborator Author

cdce8p commented Aug 30, 2024

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