[ty] Preserve bounded typevar identity during member lookup#23471
[ty] Preserve bounded typevar identity during member lookup#23471Hugo-Polloli wants to merge 1 commit intoastral-sh:mainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.90%. The percentage of expected errors that received a diagnostic held steady at 83.08%. The number of fully passing files held steady at 78/133. |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
trio
sphinx
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
1 | 101 | 1 |
no-matching-overload |
0 | 23 | 0 |
invalid-return-type |
3 | 1 | 12 |
invalid-assignment |
5 | 6 | 1 |
possibly-missing-attribute |
1 | 5 | 4 |
possibly-missing-implicit-call |
2 | 0 | 0 |
unresolved-attribute |
1 | 0 | 1 |
not-iterable |
0 | 1 | 0 |
unsupported-operator |
0 | 1 | 0 |
unused-type-ignore-comment |
0 | 1 | 0 |
| Total | 13 | 139 | 19 |
Raw diff (171 changes)
aiohttp (https://github.com/aio-libs/aiohttp)
- aiohttp/client.py:1542:15 error[invalid-argument-type] Argument to bound method `__aexit__` is incorrect: Argument type `_RetType_co@_BaseRequestContextManager` does not satisfy upper bound `ClientWebSocketResponse[_DecodeText@ClientWebSocketResponse]` of type variable `Self`
- aiohttp/client.py:1542:15 error[invalid-argument-type] Argument to bound method `__aexit__` is incorrect: Expected `ClientResponse`, found `_RetType_co@_BaseRequestContextManager`
- aiohttp/client.py:1534:22 error[invalid-argument-type] Argument to bound method `__aenter__` is incorrect: Argument type `_RetType_co@_BaseRequestContextManager` does not satisfy upper bound `ClientWebSocketResponse[_DecodeText@ClientWebSocketResponse]` of type variable `Self`
- aiohttp/client.py:1534:22 error[invalid-argument-type] Argument to bound method `__aenter__` is incorrect: Expected `ClientResponse`, found `_RetType_co@_BaseRequestContextManager`
beartype (https://github.com/beartype/beartype)
+ beartype/_util/api/standard/utilfunctools.py:308:24 error[unresolved-attribute] Object of type `BeartypeableT@beartype_functools_lru_cache & Top[(...) -> object]` has no attribute `cache_parameters`
+ beartype/_decor/_nontype/_decordescriptor.py:153:9 error[invalid-argument-type] Argument to function `beartype_func` is incorrect: Argument type `((Any, /) -> Any) | None` does not satisfy upper bound `((...) -> Any) | classmethod[Unknown, (...), Unknown] | property` of type variable `BeartypeableT`
core (https://github.com/home-assistant/core)
- homeassistant/components/asuswrt/helpers.py:44:16 error[invalid-return-type] Return type does not match returned value: expected `T@translate_to_legacy`, found `dict[Unknown, object]`
+ homeassistant/components/asuswrt/helpers.py:44:16 error[invalid-return-type] Return type does not match returned value: expected `T@translate_to_legacy`, found `dict[str, Any]`
- homeassistant/components/asuswrt/helpers.py:44:17 error[no-matching-overload] No overload of bound method `get` matches arguments
+ homeassistant/components/sonos/helpers.py:84:42 warning[possibly-missing-attribute] Attribute `soco` may be missing on object of type `_T@wrapper`
discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/core.py:680:52 warning[possibly-missing-attribute] Attribute `cog_command_error` may be missing on object of type `CogT@Command & ~None`
- discord/ext/commands/core.py:919:47 warning[possibly-missing-attribute] Attribute `cog_before_invoke` may be missing on object of type `CogT@Command & ~None`
- discord/ext/commands/core.py:921:23 error[invalid-argument-type] Argument to bound method `cog_before_invoke` is incorrect: Expected `Cog`, found `CogT@Command`
- discord/ext/commands/core.py:939:47 warning[possibly-missing-attribute] Attribute `cog_after_invoke` may be missing on object of type `CogT@Command & ~None`
- discord/ext/commands/core.py:941:23 error[invalid-argument-type] Argument to bound method `cog_after_invoke` is incorrect: Expected `Cog`, found `CogT@Command`
- discord/ext/commands/core.py:1312:58 warning[possibly-missing-attribute] Attribute `cog_check` may be missing on object of type `CogT@Command & ~None`
hydpy (https://github.com/hydpy-dev/hydpy)
- hydpy/auxs/calibtools.py:2145:13 error[invalid-argument-type] Argument to bound method `apply_value` is incorrect: Expected `Add`, found `TypeRule1@CalibrationInterface`
- hydpy/auxs/calibtools.py:2145:13 error[invalid-argument-type] Argument to bound method `apply_value` is incorrect: Expected `MultiplyIUH`, found `TypeRule1@CalibrationInterface`
- hydpy/auxs/calibtools.py:2145:13 error[invalid-argument-type] Argument to bound method `apply_value` is incorrect: Expected `Multiply`, found `TypeRule1@CalibrationInterface`
- hydpy/auxs/calibtools.py:2145:13 error[invalid-argument-type] Argument to bound method `apply_value` is incorrect: Expected `ReplaceIUH`, found `TypeRule1@CalibrationInterface`
- hydpy/auxs/calibtools.py:2145:13 error[invalid-argument-type] Argument to bound method `apply_value` is incorrect: Expected `Replace`, found `TypeRule1@CalibrationInterface`
- hydpy/auxs/calibtools.py:2159:13 error[invalid-argument-type] Argument to bound method `reset_parameters` is incorrect: Expected `RuleIUH`, found `TypeRule1@CalibrationInterface`
+ hydpy/auxs/iuhtools.py:520:16 error[invalid-return-type] Return type does not match returned value: expected `VectorFloatFlex@__call__`, found `ndarray[tuple[int], Unknown]`
- hydpy/auxs/iuhtools.py:516:13 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[float64]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[float64]], (key: str, /) -> ndarray[tuple[int] | tuple[Any, ...], dtype[Any]], (key: list[str], /) -> ndarray[tuple[int] | tuple[Any, ...], Unknown]]` cannot be called with key of type `bool` on object of type `VectorFloatFlex@__call__`
- hydpy/auxs/iuhtools.py:516:13 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[float64]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[float64]], (key: str, /) -> ndarray[tuple[int] | tuple[Any, ...], dtype[Any]], (key: list[str], /) -> ndarray[tuple[int] | tuple[Any, ...], Unknown]]` cannot be called with key of type `ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]]` on object of type `VectorFloatFlex@__call__`
+ hydpy/auxs/iuhtools.py:516:13 warning[possibly-missing-implicit-call] Method `__getitem__` of type `VectorFloatFlex@__call__` may be missing
+ hydpy/auxs/iuhtools.py:516:13 warning[possibly-missing-implicit-call] Method `__getitem__` of type `VectorFloatFlex@__call__` may be missing
+ hydpy/auxs/iuhtools.py:516:13 error[invalid-assignment] Object of type `Any | ndarray[tuple[Any, ...], dtype[float64]]` is not assignable to `VectorFloatFlex@__call__`
koda-validate (https://github.com/keithasaurus/koda-validate)
- koda_validate/generic.py:312:20 error[invalid-argument-type] Argument to bound method `strip` is incorrect: Expected `bytes`, found `StrOrBytes@NotBlank`
- koda_validate/generic.py:312:20 error[no-matching-overload] No overload of bound method `strip` matches arguments
- koda_validate/generic.py:290:16 error[invalid-argument-type] Argument to bound method `startswith` is incorrect: Expected `bytes`, found `StrOrBytes@StartsWith`
- koda_validate/generic.py:290:16 error[invalid-argument-type] Argument to bound method `startswith` is incorrect: Expected `str`, found `StrOrBytes@StartsWith`
- koda_validate/generic.py:298:16 error[invalid-argument-type] Argument to bound method `endswith` is incorrect: Expected `bytes`, found `StrOrBytes@EndsWith`
- koda_validate/generic.py:298:16 error[invalid-argument-type] Argument to bound method `endswith` is incorrect: Expected `str`, found `StrOrBytes@EndsWith`
- koda_validate/generic.py:321:16 error[invalid-return-type] Return type does not match returned value: expected `StrOrBytes@Strip`, found `Unknown | bytes`
+ koda_validate/generic.py:321:16 error[invalid-return-type] Return type does not match returned value: expected `StrOrBytes@Strip`, found `str | bytes`
- koda_validate/generic.py:321:16 error[invalid-argument-type] Argument to bound method `strip` is incorrect: Expected `bytes`, found `StrOrBytes@Strip`
- koda_validate/generic.py:321:16 error[no-matching-overload] No overload of bound method `strip` matches arguments
- koda_validate/generic.py:330:16 error[invalid-return-type] Return type does not match returned value: expected `StrOrBytes@UpperCase`, found `Unknown | bytes`
+ koda_validate/generic.py:330:16 error[invalid-return-type] Return type does not match returned value: expected `StrOrBytes@UpperCase`, found `str | bytes`
- koda_validate/generic.py:330:16 error[invalid-argument-type] Argument to bound method `upper` is incorrect: Expected `bytes`, found `StrOrBytes@UpperCase`
- koda_validate/generic.py:330:16 error[no-matching-overload] No overload of bound method `upper` matches arguments
- koda_validate/generic.py:336:16 error[invalid-return-type] Return type does not match returned value: expected `StrOrBytes@LowerCase`, found `Unknown | bytes`
+ koda_validate/generic.py:336:16 error[invalid-return-type] Return type does not match returned value: expected `StrOrBytes@LowerCase`, found `str | bytes`
- koda_validate/generic.py:336:16 error[invalid-argument-type] Argument to bound method `lower` is incorrect: Expected `bytes`, found `StrOrBytes@LowerCase`
- koda_validate/generic.py:336:16 error[no-matching-overload] No overload of bound method `lower` matches arguments
operator (https://github.com/canonical/operator)
- ops/pebble.py:567:19 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> LiteralString, (key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str]) | (Overload[(key: SupportsIndex, /) -> int, (key: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> bytes])` cannot be called with key of type `slice[Any, Any, Any]` on object of type `AnyStr@ExecError`
pandas (https://github.com/pandas-dev/pandas)
- pandas/core/algorithms.py:223:12 error[no-matching-overload] No overload of bound method `astype` matches arguments
- pandas/core/algorithms.py:223:12 error[no-matching-overload] No overload of bound method `astype` matches arguments
+ pandas/core/algorithms.py:223:12 error[invalid-return-type] Return type does not match returned value: expected `ArrayLikeT@_reconstruct_data`, found `ndarray[tuple[Any, ...], dtype[Any]] | ndarray[tuple[Any, ...], Unknown]`
- pandas/core/arrays/datetimes.py:3153:21 error[invalid-assignment] Object of type `Timestamp` is not assignable to `_TimestampNoneT1@_maybe_normalize_endpoints`
- pandas/core/arrays/datetimes.py:3156:19 error[invalid-assignment] Object of type `Timestamp` is not assignable to `_TimestampNoneT2@_maybe_normalize_endpoints`
- pandas/core/dtypes/cast.py:388:16 error[invalid-return-type] Return type does not match returned value: expected `NumpyIndexT@maybe_upcast_numeric_to_64bit`, found `Unknown | Index`
+ pandas/core/dtypes/cast.py:388:16 error[invalid-return-type] Return type does not match returned value: expected `NumpyIndexT@maybe_upcast_numeric_to_64bit`, found `ndarray[tuple[Any, ...], Unknown] | Index`
- pandas/core/dtypes/cast.py:388:16 error[invalid-argument-type] Argument to bound method `astype` is incorrect: Expected `Index`, found `NumpyIndexT@maybe_upcast_numeric_to_64bit`
- pandas/core/dtypes/cast.py:388:16 error[no-matching-overload] No overload of bound method `astype` matches arguments
- pandas/core/dtypes/cast.py:390:16 error[invalid-return-type] Return type does not match returned value: expected `NumpyIndexT@maybe_upcast_numeric_to_64bit`, found `Unknown | Index`
+ pandas/core/dtypes/cast.py:390:16 error[invalid-return-type] Return type does not match returned value: expected `NumpyIndexT@maybe_upcast_numeric_to_64bit`, found `ndarray[tuple[Any, ...], Unknown] | Index`
- pandas/core/dtypes/cast.py:390:16 error[invalid-argument-type] Argument to bound method `astype` is incorrect: Expected `Index`, found `NumpyIndexT@maybe_upcast_numeric_to_64bit`
- pandas/core/dtypes/cast.py:390:16 error[no-matching-overload] No overload of bound method `astype` matches arguments
- pandas/core/dtypes/cast.py:392:16 error[invalid-return-type] Return type does not match returned value: expected `NumpyIndexT@maybe_upcast_numeric_to_64bit`, found `Unknown | Index`
+ pandas/core/dtypes/cast.py:392:16 error[invalid-return-type] Return type does not match returned value: expected `NumpyIndexT@maybe_upcast_numeric_to_64bit`, found `ndarray[tuple[Any, ...], Unknown] | Index`
- pandas/core/dtypes/cast.py:392:16 error[invalid-argument-type] Argument to bound method `astype` is incorrect: Expected `Index`, found `NumpyIndexT@maybe_upcast_numeric_to_64bit`
- pandas/core/dtypes/cast.py:392:16 error[no-matching-overload] No overload of bound method `astype` matches arguments
- pandas/core/resample.py:3208:12 error[invalid-return-type] Return type does not match returned value: expected `FreqIndexT@_asfreq_compat`, found `PeriodIndex | DatetimeIndex | TimedeltaIndex`
+ pandas/core/resample.py:3208:12 error[invalid-return-type] Return type does not match returned value: expected `FreqIndexT@_asfreq_compat`, found `Unknown | DatetimeIndex | TimedeltaIndex`
pip (https://github.com/pypa/pip)
- src/pip/_vendor/rich/progress.py:294:16 error[invalid-argument-type] Argument to bound method `__enter__` is incorrect: Expected `BinaryIO`, found `_I@_ReadContext`
- src/pip/_vendor/rich/progress.py:294:16 error[invalid-argument-type] Argument to bound method `__enter__` is incorrect: Expected `TextIO`, found `_I@_ReadContext`
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/templating.py:92:47 error[invalid-argument-type] Argument to function `find_placeholders` is incorrect: Argument type `object` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/utilities/templating.py:224:29 error[no-matching-overload] No overload of function `apply_values` matches arguments
- src/prefect/utilities/templating.py:232:17 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `Unknown & ~<class 'NotSet'>` on object of type `dict[str, Any]`
- src/prefect/utilities/templating.py:234:17 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `object` on object of type `dict[str, Any]`
- src/prefect/utilities/templating.py:330:29 error[no-matching-overload] No overload of bound method `get` matches arguments
- src/prefect/utilities/templating.py:339:13 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `Unknown` on object of type `dict[str, Any]`
- src/prefect/utilities/templating.py:216:36 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@apply_values | Unknown`
+ src/prefect/utilities/templating.py:216:36 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@apply_values`
- src/prefect/utilities/templating.py:216:36 error[no-matching-overload] No overload of bound method `replace` matches arguments
+ src/prefect/utilities/templating.py:216:36 error[invalid-assignment] Object of type `str` is not assignable to `T@apply_values`
- src/prefect/utilities/templating.py:218:32 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@apply_values | Unknown`
+ src/prefect/utilities/templating.py:218:32 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@apply_values`
- src/prefect/utilities/templating.py:218:32 error[no-matching-overload] No overload of bound method `replace` matches arguments
+ src/prefect/utilities/templating.py:218:32 error[invalid-assignment] Object of type `str` is not assignable to `T@apply_values`
- src/prefect/utilities/templating.py:451:36 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@resolve_variables | Unknown`
+ src/prefect/utilities/templating.py:451:36 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@resolve_variables`
- src/prefect/utilities/templating.py:451:36 error[no-matching-overload] No overload of bound method `replace` matches arguments
+ src/prefect/utilities/templating.py:451:36 error[invalid-assignment] Object of type `str` is not assignable to `T@resolve_variables`
- src/prefect/utilities/templating.py:453:36 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@resolve_variables | Unknown`
+ src/prefect/utilities/templating.py:453:36 warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `T@resolve_variables`
- src/prefect/utilities/templating.py:453:36 error[no-matching-overload] No overload of bound method `replace` matches arguments
+ src/prefect/utilities/templating.py:453:36 error[invalid-assignment] Object of type `str` is not assignable to `T@resolve_variables`
- src/prefect/utilities/templating.py:456:16 error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, Unknown]`
+ src/prefect/utilities/templating.py:456:16 error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[Any, Unknown]`
pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/aglib/heap/ptmalloc.py:1202:74 error[invalid-argument-type] Argument to bound method `keys` is incorrect: Expected `Type`, found `TheType@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1279:22 error[invalid-argument-type] Method `__getitem__` of type `(bound method TheValue@GlibcMemoryAllocator.__getitem__(idx: int | str) -> Value) | (bound method TheValue@GlibcMemoryAllocator.__getitem__(key: str) -> Value)` cannot be called with key of type `Literal["num_slots"]` on object of type `TheValue@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1281:22 error[invalid-argument-type] Method `__getitem__` of type `(bound method TheValue@GlibcMemoryAllocator.__getitem__(idx: int | str) -> Value) | (bound method TheValue@GlibcMemoryAllocator.__getitem__(key: str) -> Value)` cannot be called with key of type `Literal["counts"]` on object of type `TheValue@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1282:19 error[invalid-argument-type] Method `__getitem__` of type `(bound method TheValue@GlibcMemoryAllocator.__getitem__(idx: int | str) -> Value) | (bound method TheValue@GlibcMemoryAllocator.__getitem__(key: str) -> Value)` cannot be called with key of type `Literal["entries"]` on object of type `TheValue@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1292:40 warning[possibly-missing-attribute] Attribute `address` may be missing on object of type `TheValue@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1109:24 error[invalid-argument-type] Method `__getitem__` of type `(bound method TheValue@GlibcMemoryAllocator.__getitem__(idx: int | str) -> Value) | (bound method TheValue@GlibcMemoryAllocator.__getitem__(key: str) -> Value)` cannot be called with key of type `Literal["tcache_small_bins"]` on object of type `TheValue@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1111:24 error[invalid-argument-type] Method `__getitem__` of type `(bound method TheValue@GlibcMemoryAllocator.__getitem__(idx: int | str) -> Value) | (bound method TheValue@GlibcMemoryAllocator.__getitem__(key: str) -> Value)` cannot be called with key of type `Literal["tcache_bins"]` on object of type `TheValue@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1211:16 error[invalid-argument-type] Argument to bound method `keys` is incorrect: Expected `Type`, found `TheType@GlibcMemoryAllocator`
- pwndbg/aglib/heap/ptmalloc.py:1301:48 error[invalid-argument-type] Method `__getitem__` of type `(bound method TheValue@GlibcMemoryAllocator.__getitem__(idx: int | str) -> Value) | (bound method TheValue@GlibcMemoryAllocator.__getitem__(key: str) -> Value)` cannot be called with key of type `Literal["tcache_count"]` on object of type `TheValue@GlibcMemoryAllocator`
pylint (https://github.com/pycqa/pylint)
- pylint/checkers/unicode.py:175:39 error[invalid-argument-type] Argument to bound method `endswith` is incorrect: Expected `bytes`, found `_StrLike@_map_positions_to_result`
- pylint/checkers/unicode.py:175:39 error[invalid-argument-type] Argument to bound method `endswith` is incorrect: Expected `str`, found `_StrLike@_map_positions_to_result`
- pylint/checkers/unicode.py:181:15 error[invalid-argument-type] Argument to bound method `find` is incorrect: Expected `bytes`, found `_StrLike@_map_positions_to_result`
- pylint/checkers/unicode.py:181:15 error[invalid-argument-type] Argument to bound method `find` is incorrect: Expected `str`, found `_StrLike@_map_positions_to_result`
- pylint/checkers/unicode.py:188:19 error[invalid-argument-type] Argument to bound method `find` is incorrect: Expected `bytes`, found `_StrLike@_map_positions_to_result`
- pylint/checkers/unicode.py:188:19 error[invalid-argument-type] Argument to bound method `find` is incorrect: Expected `str`, found `_StrLike@_map_positions_to_result`
rich (https://github.com/Textualize/rich)
- rich/progress.py:294:16 error[invalid-argument-type] Argument to bound method `__enter__` is incorrect: Expected `BinaryIO`, found `_I@_ReadContext`
- rich/progress.py:294:16 error[invalid-argument-type] Argument to bound method `__enter__` is incorrect: Expected `TextIO`, found `_I@_ReadContext`
rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/decoding/decoder.py:323:21 error[invalid-argument-type] Argument to bound method `get_or_query_db_id` is incorrect: Expected `EvmTransaction`, found `T_Transaction@TransactionDecoder`
- rotkehlchen/chain/decoding/decoder.py:323:21 error[invalid-argument-type] Argument to bound method `get_or_query_db_id` is incorrect: Expected `SolanaTransaction`, found `T_Transaction@TransactionDecoder`
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/metadata/__init__.py:89:24 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `object`
+ src/scikit_build_core/metadata/__init__.py:89:35 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `str | list[str] | dict[str, str]`
- src/scikit_build_core/metadata/__init__.py:89:35 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `object`
- src/scikit_build_core/metadata/__init__.py:107:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[object, dict[str, str]]`
+ src/scikit_build_core/metadata/__init__.py:107:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[str, dict[str, str]]`
- src/scikit_build_core/metadata/__init__.py:108:51 error[unresolved-attribute] Object of type `object` has no attribute `items`
+ src/scikit_build_core/metadata/__init__.py:108:51 error[unresolved-attribute] Attribute `items` is not defined on `str`, `list[str]` in union `str | list[str] | dict[str, str]`
- src/scikit_build_core/metadata/__init__.py:117:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[object, list[str]]`
+ src/scikit_build_core/metadata/__init__.py:117:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[str, list[str]]`
- src/scikit_build_core/metadata/__init__.py:117:40 error[not-iterable] Object of type `object` is not iterable
scrapy (https://github.com/scrapy/scrapy)
- scrapy/http/headers.py:45:30 error[invalid-argument-type] Argument to bound method `title` is incorrect: Expected `bytes`, found `AnyStr@normkey`
- scrapy/http/headers.py:45:30 error[no-matching-overload] No overload of bound method `title` matches arguments
- scrapy/utils/datatypes.py:113:47 error[invalid-argument-type] Argument to bound method `lower` is incorrect: Expected `bytes`, found `AnyStr@__getitem__`
- scrapy/utils/datatypes.py:113:47 error[no-matching-overload] No overload of bound method `lower` matches arguments
- scrapy/utils/datatypes.py:118:36 error[invalid-argument-type] Argument to bound method `lower` is incorrect: Expected `bytes`, found `AnyStr@__setitem__`
- scrapy/utils/datatypes.py:118:36 error[no-matching-overload] No overload of bound method `lower` matches arguments
- scrapy/utils/datatypes.py:123:20 error[invalid-argument-type] Argument to bound method `lower` is incorrect: Expected `bytes`, found `AnyStr@__setitem__`
- scrapy/utils/datatypes.py:123:20 error[no-matching-overload] No overload of bound method `lower` matches arguments
- scrapy/utils/datatypes.py:127:37 error[invalid-argument-type] Argument to bound method `lower` is incorrect: Expected `bytes`, found `AnyStr@__delitem__`
- scrapy/utils/datatypes.py:127:37 error[no-matching-overload] No overload of bound method `lower` matches arguments
- scrapy/utils/datatypes.py:132:16 error[invalid-argument-type] Argument to bound method `lower` is incorrect: Expected `bytes`, found `AnyStr@__contains__`
- scrapy/utils/datatypes.py:132:16 error[no-matching-overload] No overload of bound method `lower` matches arguments
- scrapy/utils/datatypes.py:76:16 error[invalid-return-type] Return type does not match returned value: expected `AnyStr@normkey`, found `Unknown | bytes`
+ scrapy/utils/datatypes.py:76:16 error[invalid-return-type] Return type does not match returned value: expected `AnyStr@normkey`, found `str | bytes`
- scrapy/utils/datatypes.py:76:16 error[invalid-argument-type] Argument to bound method `lower` is incorrect: Expected `bytes`, found `AnyStr@normkey`
- scrapy/utils/datatypes.py:76:16 error[no-matching-overload] No overload of bound method `lower` matches arguments
setuptools (https://github.com/pypa/setuptools)
- setuptools/_distutils/util.py:154:43 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> LiteralString, (key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str]) | (Overload[(key: SupportsIndex, /) -> int, (key: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> bytes])` cannot be called with key of type `slice[Literal[1], None, None]` on object of type `AnyStr@change_root`
spack (https://github.com/spack/spack)
- lib/spack/spack/vendor/markupsafe/__init__.py:248:13 error[invalid-assignment] Invalid subscript assignment with key of type `Any` and value of type `Markup` on object of type `_ListOrDict@_escape_argspec`
static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/node_values.py:128:59 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/node_values.py:275:20 error[invalid-return-type] Return type does not match returned value: expected `TVContainer_co@func`, found `@Todo | IndexHierarchy | Series[Any, Any] | Index[Any]`
sympy (https://github.com/sympy/sympy)
- sympy/polys/domains/domain.py:1033:40 error[invalid-argument-type] Argument to bound method `map` is incorrect: Argument type `Iterable[int | Er@Domain]` does not satisfy upper bound `RingElement` of type variable `Er`
xarray (https://github.com/pydata/xarray)
- xarray/computation/rolling.py:199:9 error[unsupported-operator] Operator `/=` is not supported between objects of type `T_Xarray@Rolling` and `Unknown`
- xarray/computation/rolling.py:1216:20 error[invalid-return-type] Return type does not match returned value: expected `T_Xarray@Coarsen`, found `DataArray`
- xarray/core/coordinates.py:1214:69 error[invalid-argument-type] Method `__getitem__` of type `(bound method T_Xarray@assert_coordinate_consistent.__getitem__(key: Any) -> T_Xarray@assert_coordinate_consistent) | (Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_Xarray@assert_coordinate_consistent])` cannot be called with key of type `Unknown` on object of type `T_Xarray@assert_coordinate_consistent`
- xarray/core/coordinates.py:1217:51 error[invalid-argument-type] Method `__getitem__` of type `(bound method T_Xarray@assert_coordinate_consistent.__getitem__(key: Any) -> T_Xarray@assert_coordinate_consistent) | (Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_Xarray@assert_coordinate_consistent])` cannot be called with key of type `Unknown` on object of type `T_Xarray@assert_coordinate_consistent`
- xarray/core/groupby.py:688:25 error[invalid-argument-type] Argument to bound method `transpose` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:688:25 error[invalid-argument-type] Argument to bound method `transpose` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/groupby.py:712:27 error[invalid-argument-type] Argument to bound method `isel` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:712:27 error[invalid-argument-type] Argument to bound method `isel` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/groupby.py:770:22 error[invalid-argument-type] Argument to bound method `_to_temp_dataset` is incorrect: Expected `DataArray`, found `T_Xarray@GroupBy`
- xarray/core/groupby.py:776:20 error[invalid-argument-type] Argument to bound method `_shuffle` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:776:20 error[invalid-argument-type] Argument to bound method `_shuffle` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/groupby.py:781:20 error[invalid-argument-type] Argument to bound method `_from_temp_dataset` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:843:16 error[invalid-argument-type] Argument to bound method `isel` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:843:16 error[invalid-argument-type] Argument to bound method `isel` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/groupby.py:871:23 error[invalid-argument-type] Argument to bound method `isel` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:871:23 error[invalid-argument-type] Argument to bound method `isel` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/groupby.py:963:24 error[invalid-argument-type] Method `__getitem__` of type `(bound method T_Xarray@GroupBy.__getitem__(key: Any) -> T_Xarray@GroupBy) | (Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_Xarray@GroupBy])` cannot be called with key of type `Unknown` on object of type `T_Xarray@GroupBy`
- xarray/core/groupby.py:964:35 error[invalid-argument-type] Method `__getitem__` of type `(bound method T_Xarray@GroupBy.__getitem__(key: Any) -> T_Xarray@GroupBy) | (Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_Xarray@GroupBy])` cannot be called with key of type `Unknown` on object of type `T_Xarray@GroupBy`
- xarray/core/groupby.py:1148:13 error[invalid-argument-type] Argument to bound method `drop_vars` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:1148:13 error[invalid-argument-type] Argument to bound method `drop_vars` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/groupby.py:1227:15 error[invalid-argument-type] Argument to bound method `transpose` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:1227:15 error[invalid-argument-type] Argument to bound method `transpose` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/indexes.py:1929:23 error[invalid-assignment] Object of type `Index` is not assignable to `T_PandasOrXarrayIndex@Indexes`
+ xarray/core/indexes.py:1929:23 error[invalid-assignment] Object of type `PandasIndex | Unknown` is not assignable to `T_PandasOrXarrayIndex@Indexes`
- xarray/core/resample.py:107:16 error[invalid-argument-type] Argument to bound method `drop_vars` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/resample.py:107:16 error[invalid-argument-type] Argument to bound method `drop_vars` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/resample.py:129:23 error[invalid-argument-type] Argument to bound method `drop_vars` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/resample.py:129:23 error[invalid-argument-type] Argument to bound method `drop_vars` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/resample.py:151:16 error[invalid-argument-type] Argument to bound method `reindex` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/resample.py:151:16 error[invalid-argument-type] Argument to bound method `reindex` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/resample.py:178:16 error[invalid-argument-type] Argument to bound method `reindex` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/resample.py:178:16 error[invalid-argument-type] Argument to bound method `reindex` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/resample.py:206:16 error[invalid-argument-type] Argument to bound method `reindex` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/resample.py:206:16 error[invalid-argument-type] Argument to bound method `reindex` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/resample.py:245:16 error[invalid-argument-type] Argument to bound method `interp` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/resample.py:245:16 error[invalid-argument-type] Argument to bound method `interp` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/plot/facetgrid.py:172:43 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:173:43 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:184:24 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:185:24 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:200:26 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:231:26 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:232:26 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:236:44 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:760:48 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:760:62 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:761:17 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Hashable` on object of type `T_DataArrayOrSet@FacetGrid`
- xarray/plot/facetgrid.py:861:38 error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Hashable) -> DataArray, (key: Iterable[Hashable]) -> T_DataArrayOrSet@FacetGrid]) | (bound method T_DataArrayOrSet@FacetGrid.__getitem__(key: Any) -> T_DataArrayOrSet@FacetGrid)` cannot be called with key of type `Any` on object of type `T_DataArrayOrSet@FacetGrid`| // Prepending `self` as an argument can produce spurious self-bound errors for | ||
| // union-bounded or constrained typevars; bake `self` into overloads instead. | ||
| let should_bake_bound_self = match self_instance { | ||
| Type::TypeVar(bound_typevar) => { | ||
| match bound_typevar.typevar(db).bound_or_constraints(db) { | ||
| Some(TypeVarBoundOrConstraints::UpperBound(bound)) => { | ||
| matches!(bound.resolve_type_alias(db), Type::Union(_)) | ||
| } | ||
| Some(TypeVarBoundOrConstraints::Constraints(_)) => true, | ||
| None => false, | ||
| } | ||
| } | ||
| _ => false, | ||
| }; |
There was a problem hiding this comment.
I don't have the full context here, but could you please explain why we need to special-case typevars in particular? Would it be wrong to call bake_bound_type_into_overloads in all cases? If so, why?
There was a problem hiding this comment.
This is what I did initially, but it dropped this diagnostic:
class C:
def __call__(self: int) -> int:
return 1
c = C()
c() # error: Expected int, found C <- dropped this(pre-existing mdtest from crates/ty_python_semantic/resources/mdtest/call/callable_instance.md)
tbh at the time I just had Codex dig into it to explain why. Turns out baking everywhere removes self before call checking, so the checker no longer compared the receiver c (type C, i.e. C.__call__(c)) against the annotated self type int, so c() stopped producing that diagnostic.
I chose to only bake for the known-broken case (union/constrained typevars) and keep the normal path elsewhere to avoid regressions.
Ideally we could always bake for argument matching and add a separate explicit receiver compability check, but that was a bit of a broader change and I preferred to keep it small.
There was a problem hiding this comment.
I see. Do we risk dropping a similar diagnostic in a case with a union-bounded TypeVar then?
There was a problem hiding this comment.
Yes, we risk dropping that diagnostic in union-bounded TypeVar atm. That's a trade-off for fixing astral-sh/ty#2585 that I found acceptable, since the case we're talking about is already pathological in its own right (typing self with int)
The pre-existing mdtest I mentioned has an old TODO about it
class C:
# TODO this definition should also be an error; `C` must be assignable to type of `self`
def __call__(self: int) -> int:
return 1There was a problem hiding this comment.
There are non-pathological scenarios along those lines, though — you sometimes get scenarios where a method on a base class has self annotated to indicate that the method can only be called on some subclasses of that class, not on others. That's not uncommon on overloads, in fact
There was a problem hiding this comment.
Yepppppp...
I've just pushed a commit with such a test case that properly raises on main, and fails to raise on my branch
I'm re-drafting this PR, back to the drawing board 😅
(If anyone has a lead on a cleaner implem I'll take it! if not, no problem I'll figure it out)
There was a problem hiding this comment.
Pushed a new fix that covers the new test case :)
Also I checked ecosystem/mypy on the new code and things seem good !
f390542 to
4de0787
Compare
4de0787 to
f342898
Compare
sharkdp
left a comment
There was a problem hiding this comment.
Thank you for the update.
Suppressing errors in a limited number of cases does not seem like the right fix to me. There is a more fundamental issue here. Consider for example this variation of the original issue, which still fails on your branch: https://play.ty.dev/47980c50-3e8a-4ad4-bb10-25107e0fb1b6
Similarly, if you call type(x).callMe(x) instead of x.callMe(), we also still emit this diagnostic.
I believe that solving this would maybe require an approach similar to what @carljm described here. When accessing an attribute on T: A | B, we may need to narrow T to a new typevar with a narrower bound, depending on which path we take in the A | B union. That is: when we access x.attr on x: T, we would create a new T1: A to stand in for the type of self when accessing the attr attribute on A. And similarly, create T2: B for accessing attr on B. Then, we union the two results (while merging T1 | T2 back into T? I haven't really thought about how that part should work).
f342898 to
97df46f
Compare
TypeVars6260be7 to
5222e1c
Compare
5222e1c to
ffb44ff
Compare
ffb44ff to
b2efe1e
Compare
554fead to
266af9f
Compare
266af9f to
aba9bd5
Compare
Summary
Shared method lookup on bounded type variables was not preserving one coherent receiver occurrence.
On
main, that showed up in a few ways:x.call_me()andtype(x).call_me(x)could fail forT: A | Beven when both bound variants define the methodx.call_me.__self__lost bound-method semantics on the narrowed pathT | Nonecould degrade toA | B | NoneFixes astral-sh/ty#2585
This PR fixes that by resolving member lookup per viable bound arm, while preserving the original bounded typevar occurrence on the resulting method object. Bound methods now keep the exposed
__self__separately from the narrower receiver used for call binding, so attribute access still sees the originalTwhile calls and returns stay correlated per arm. The same member-lookup handling also applies after narrowing shapes likeT & ~None.Explicit
self-typed overloads still reject unsupported receivers, and methods that are missing from some bound variants still reportpossibly-missing-attribute.Test Plan
T = TypeVar(..., bound=A | B):x.call_me()succeeds and preserves a union of per-arm return typesT = TypeVar(..., bound=A | B):type(x).call_me(x)succeedsT = TypeVar(..., bound=A | B):x.call_me.__self__reveals the original bounded typevar occurrence, andx.call_me.__func__still resolves correctlyT = TypeVar(..., bound=A | B):return x.maybe()stays assignable toT | Nonewhen each bound arm returns its own receiver typeT = TypeVar(..., bound=list[Any] | None): narrowing awayNonemakesx.append(...)resolve cleanlyT = TypeVar(..., bound=C | D): calling a method present on only one variant still reportspossibly-missing-attributeself-typed overloads still reportno-matching-overloadfor unsupported bounded and constrained receivers