-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Sync typeshed #19772
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 #19772
Conversation
Source commit: python/typeshed@2480d7e
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)
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
|
Diff from mypy_primer, showing the effect of this PR on open source code: beartype (https://github.com/beartype/beartype)
+ beartype/_util/hint/pep/proposal/pep484/pep484generic.py:149: error: Unused "type: ignore" comment [unused-ignore]
+ beartype/_util/hint/pep/proposal/pep484/pep484generic.py:177: error: Unused "type: ignore" comment [unused-ignore]
spack (https://github.com/spack/spack)
+ lib/spack/spack/util/url.py:91: error: Cannot assign to final name "uses_netloc" [misc]
+ lib/spack/spack/util/url.py:92: error: Cannot assign to final name "uses_relative" [misc]
+ lib/spack/spack/util/url.py:95: error: Cannot assign to final name "uses_netloc" [misc]
+ lib/spack/spack/util/url.py:96: error: Cannot assign to final name "uses_relative" [misc]
pydantic (https://github.com/pydantic/pydantic)
- pydantic/main.py:577: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "_ClassInfo" [arg-type]
- pydantic/dataclasses.py:203: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "_ClassInfo" [arg-type]
- pydantic/dataclasses.py:205: error: Incompatible types in assignment (expression has type "tuple[type[DataclassInstance], <typing special form>]", variable has type "tuple[type[DataclassInstance]]") [assignment]
+ pydantic/dataclasses.py:205: error: Incompatible types in assignment (expression has type "tuple[type[DataclassInstance], Any]", variable has type "tuple[type[DataclassInstance]]") [assignment]
psycopg (https://github.com/psycopg/psycopg)
+ tests/types/test_uuid.py:62: error: Unused "type: ignore" comment [unused-ignore]
prefect (https://github.com/PrefectHQ/prefect)
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:136: note: "__init_subclass__" of "object" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:138: note: "__init_subclass__" of "object" defined here
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:136: note: "__init_subclass__" of "object" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:138: note: "__init_subclass__" of "object" defined here
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:136: note: "__init_subclass__" of "object" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:138: note: "__init_subclass__" of "object" defined here
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:136: note: "__init_subclass__" of "object" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:138: note: "__init_subclass__" of "object" defined here
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:136: note: "__init_subclass__" of "object" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:138: note: "__init_subclass__" of "object" defined here
core (https://github.com/home-assistant/core)
+ homeassistant/components/backup/manager.py:900: error: Subclass of "dict[str, Exception]" and "BackupNotFound" cannot exist: have distinct disjoint bases [unreachable]
+ homeassistant/components/bayesian/binary_sensor.py:558: error: Subclass of "Template" and "str" cannot exist: have distinct disjoint bases [unreachable]
+ homeassistant/components/bayesian/binary_sensor.py:559: error: Statement is unreachable [unreachable]
zulip (https://github.com/zulip/zulip)
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:114: note: "SubTest" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:116: note: "SubTest" defined here
strawberry (https://github.com/strawberry-graphql/strawberry)
+ strawberry/utils/typing.py:135: error: Unused "type: ignore" comment [unused-ignore]
+ strawberry/utils/typing.py:185: error: Unused "type: ignore" comment [unused-ignore]
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:136: note: "__init_subclass__" of "object" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:138: note: "__init_subclass__" of "object" defined here
pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/raises.py:455: error: Subclass of "GenericAlias" and "Exception" cannot exist: have distinct disjoint bases [unreachable]
+ src/_pytest/raises.py:468: error: Subclass of "GenericAlias" and "type" cannot exist: have distinct disjoint bases [unreachable]
+ src/_pytest/raises.py:470: error: Subclass of "GenericAlias" and "BaseException" cannot exist: have distinct disjoint bases [unreachable]
pandas (https://github.com/pandas-dev/pandas)
- pandas/io/common.py:1050: note: def __init__(self, file: str | PathLike[str] | _ZipWritable, mode: Literal['w', 'x'] = ..., compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
+ pandas/io/common.py:1050: note: def __init__(self, file: str | PathLike[str] | _ZipWritable, mode: Literal['w', 'x'], compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
- pandas/io/common.py:1050: note: def __init__(self, file: str | PathLike[str] | _ZipReadableTellable, mode: Literal['a'] = ..., compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
+ pandas/io/common.py:1050: note: def __init__(self, file: str | PathLike[str] | _ZipReadableTellable, mode: Literal['a'], compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
- pandas/_testing/_io.py:141: note: def __init__(self, file: str | PathLike[str] | _ZipWritable, mode: Literal['w', 'x'] = ..., compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
+ pandas/_testing/_io.py:141: note: def __init__(self, file: str | PathLike[str] | _ZipWritable, mode: Literal['w', 'x'], compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
- pandas/_testing/_io.py:141: note: def __init__(self, file: str | PathLike[str] | _ZipReadableTellable, mode: Literal['a'] = ..., compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
+ pandas/_testing/_io.py:141: note: def __init__(self, file: str | PathLike[str] | _ZipReadableTellable, mode: Literal['a'], compression: int = ..., allowZip64: bool = ..., compresslevel: int | None = ..., *, strict_timestamps: bool = ..., metadata_encoding: None = ...) -> ZipFile
aioredis (https://github.com/aio-libs/aioredis)
+ aioredis/client.py:4116: error: Unused "type: ignore" comment [unused-ignore]
+ aioredis/client.py:4152: error: Unused "type: ignore" comment [unused-ignore]
discord.py (https://github.com/Rapptz/discord.py)
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/typing.pyi:1016: note: "update" of "TypedDict" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/typing.pyi:1043: note: "update" of "TypedDict" defined here
- discord/ext/commands/converter.py:1280: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "_ClassInfo" [arg-type]
ibis (https://github.com/ibis-project/ibis)
- ibis/common/collections.py:140: error: Argument 1 to "KeysView" has incompatible type "ibis.common.collections.Mapping[K, V]"; expected "typing.Mapping[K, Any]" [arg-type]
- ibis/common/collections.py:143: error: Argument 1 to "ItemsView" has incompatible type "ibis.common.collections.Mapping[K, V]"; expected "typing.Mapping[K, V]" [arg-type]
+ ibis/common/collections.py:282: error: Class "FrozenDict" has incompatible disjoint bases [misc]
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:114: note: "Any" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:116: note: "Any" defined here
+ ibis/common/tests/test_patterns.py:273: error: Class "MyString" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_patterns.py:288: error: Class "MyInt" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_patterns.py:486: error: Class "MyList" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_patterns.py:1141: error: Class "MyFloat" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_patterns.py:1211: error: Class "DoubledList" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_patterns.py:1238: error: Class "MyNegativeInt" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_grounds.py:184: error: Class "Integer" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_grounds.py:190: error: Class "Float" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_grounds.py:202: error: Class "MyInt" has incompatible disjoint bases [misc]
+ ibis/common/tests/test_grounds.py:208: error: Class "MyFloat" has incompatible disjoint bases [misc]
- ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:114: note: "__init__" of "object" defined here
+ ...venv/lib/python3.13/site-packages/mypy/typeshed/stdlib/builtins.pyi:116: note: "__init__" of "object" defined here
zope.interface (https://github.com/zopefoundation/zope.interface)
- src/zope/interface/common/collections.py:233: error: Incompatible types in assignment (expression has type "type[ItemsView[_KT_co, _VT_co]]", base class "ISet" defined the type as "type[AbstractSet[_T_co]]") [assignment]
+ src/zope/interface/common/collections.py:233: error: Incompatible types in assignment (expression has type "type[ItemsView[_KT_co, _VT_co]]", base class "IMappingView" defined the type as "type[MappingView]") [assignment]
- src/zope/interface/common/collections.py:237: error: Incompatible types in assignment (expression has type "type[KeysView[_KT_co]]", base class "ISet" defined the type as "type[AbstractSet[_T_co]]") [assignment]
+ src/zope/interface/common/collections.py:237: error: Incompatible types in assignment (expression has type "type[KeysView[_KT_co]]", base class "IMappingView" defined the type as "type[MappingView]") [assignment]
+ src/zope/interface/common/collections.py:241: error: Incompatible types in assignment (expression has type "type[ValuesView[_VT_co]]", base class "IMappingView" defined the type as "type[MappingView]") [assignment]
static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/series_mapping.py:21: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/series_mapping.py:26: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/series_mapping.py:32: error: Unused "type: ignore" comment [unused-ignore]
|
Mypy primer hits
|
|
Not necessarily merge blocking, but the ibis core pytest changes related to PEP 800 are a little worrisome to me, let's look the ibis ones just seem like false positives |
I did look at the Home Assistant errors in more detail. They are both correct. The one you mentioned is actually missing another loop. Will open a PR for it upstream tomorrow. agent_errors = {
backup_id: error
for backup_id, error_dict in zip(backup_ids, delete_results, strict=True)
+ for error in error_dict.values()
if error and not isinstance(error, BackupNotFound)
}--
As far as I see it there are two options (for this PR): either we keep it as is or I can add a patch to revert the PEP 800 changes from typeshed. If possible I'd like to move forward with it soon though so it can still be included in Personally I wouldn't mind testing it with the PEP 800 changes for now. If we discover those cause to many disruptions, we can always add a patch later. |
|
Yeah, I'm happy to merge! |
Source commit:
python/typeshed@2480d7e