[ty] Preserve intersection receivers during attribute lookup#25626
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 92.16%. The percentage of expected errors that received a diagnostic held steady at 87.31%. The number of fully passing files held steady at 92/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
14 | 6 | 6 |
invalid-return-type |
3 | 4 | 7 |
invalid-assignment |
3 | 6 | 3 |
no-matching-overload |
2 | 5 | 0 |
unresolved-attribute |
2 | 2 | 2 |
not-iterable |
1 | 1 | 1 |
unsupported-operator |
3 | 0 | 0 |
unused-type-ignore-comment |
0 | 1 | 0 |
| Total | 28 | 25 | 19 |
Raw diff (72 changes)
Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/commands/slash.py:1458:22 error[invalid-assignment] Object of type `Self@CommandInteractionOption` is not assignable to `AutocompleteInteractionOption | None`
+ tanjun/commands/slash.py:1464:38 error[unresolved-attribute] Attribute `name` is not defined on `None` in union `AutocompleteInteractionOption | None`
+ tanjun/commands/slash.py:1466:45 error[unresolved-attribute] Attribute `name` is not defined on `None` in union `AutocompleteInteractionOption | None`
apprise (https://github.com/caronc/apprise)
- apprise/plugins/fortysixelks.py:161:23 error[invalid-assignment] Object of type `list[LiteralString | None]` is not assignable to `Iterable[str] | None`
+ apprise/plugins/fortysixelks.py:161:23 error[invalid-assignment] Object of type `list[str | None]` is not assignable to `Iterable[str] | None`
- apprise/plugins/pushover.py:844:13 error[no-matching-overload] No overload of bound method `MutableMapping.update` matches arguments
archinstall (https://github.com/archlinux/archinstall)
+ archinstall/tui/components.py:742:37 error[invalid-argument-type] Argument is incorrect: Expected `Self@MenuItem`, found `MenuItem & ~AlwaysFalsy`
bokeh (https://github.com/bokeh/bokeh)
- src/bokeh/util/serialization.py:367:17 error[invalid-argument-type] Argument to bound method `MaskedArray.filled` is incorrect: Argument type `MaskedArray[tuple[object, ...], dtype[object]]` does not satisfy upper bound `MaskedArray[_ShapeT_co@MaskedArray, _DTypeT_co@MaskedArray]` of type variable `Self`
+ src/bokeh/util/serialization.py:367:17 error[invalid-argument-type] Argument to bound method `MaskedArray.filled` is incorrect: Argument type `ndarray[tuple[Any, ...], dtype[Any]] & MaskedArray[tuple[object, ...], dtype[object]]` does not satisfy upper bound `MaskedArray[_ShapeT_co@MaskedArray, _DTypeT_co@MaskedArray]` of type variable `Self`
+ src/bokeh/util/serialization.py:367:17 error[invalid-argument-type] Argument to bound method `MaskedArray.filled` is incorrect: Argument type `ndarray[tuple[Any, ...], dtype[floating[Any]]] & MaskedArray[tuple[object, ...], dtype[object]]` does not satisfy upper bound `MaskedArray[_ShapeT_co@MaskedArray, _DTypeT_co@MaskedArray]` of type variable `Self`
core (https://github.com/home-assistant/core)
- homeassistant/components/asuswrt/helpers.py:42: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:42: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:42:17 error[no-matching-overload] No overload of bound method `dict.get` matches arguments
discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/core.py:921:23 error[invalid-argument-type] Argument to bound method `Cog.cog_before_invoke` is incorrect: Expected `Cog`, found `CogT@Command`
- discord/ext/commands/core.py:941:23 error[invalid-argument-type] Argument to bound method `Cog.cog_after_invoke` is incorrect: Expected `Cog`, found `CogT@Command`
+ discord/ui/container.py:143:24 error[invalid-argument-type] Argument to bound method `Item.copy` is incorrect: Argument type `((Self@_init_children, Interaction[Any], Any, /) -> Coroutine[Any, Any, Any]) & Item[object]` does not satisfy upper bound `Item[V@Item]` of type variable `Self`
+ discord/ui/section.py:190:9 error[invalid-argument-type] Argument to bound method `Item._update_view` is incorrect: Argument type `str & Item[object]` does not satisfy upper bound `Item[V@Item]` of type variable `Self`
+ discord/ui/view.py:264:24 error[invalid-argument-type] Argument to bound method `Item.copy` is incorrect: Argument type `((Any, Interaction[Any], Any, /) -> Coroutine[Any, Any, Any]) & Item[object]` does not satisfy upper bound `Item[V@Item]` of type variable `Self`
django-modern-rest (https://github.com/wemake-services/django-modern-rest)
- dmr/streaming/controller.py:38:16 error[invalid-argument-type] Argument to bound method `StreamingController.to_stream` is incorrect: Argument type `StreamingController[object]` does not satisfy upper bound `StreamingController[_SerializerT_co@StreamingController]` of type variable `Self`
+ dmr/streaming/controller.py:38:16 error[invalid-argument-type] Argument to bound method `StreamingController.to_stream` is incorrect: Argument type `Controller[BaseSerializer] & StreamingController[object]` does not satisfy upper bound `StreamingController[_SerializerT_co@StreamingController]` of type variable `Self`
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/third_party/beartype.py:125:9 error[invalid-assignment] Object of type `(bound method _T@validates_with_beartype.__init__() -> None) & (Overload[(o: object, /) -> None, (name: str, bases: tuple[type, ...], dict: dict[str, Any], /, **kwds: Any) -> None])` is not assignable to attribute `__init__` on type `_T@validates_with_beartype & type`
+ src/hydra_zen/third_party/beartype.py:125:9 error[invalid-assignment] Object of type `(bound method _T@validates_with_beartype & type.__init__() -> None) & (Overload[(o: object, /) -> None, (name: str, bases: tuple[type, ...], dict: dict[str, Any], /, **kwds: Any) -> None])` is not assignable to attribute `__init__` on type `_T@validates_with_beartype & type`
jax (https://github.com/google/jax)
+ jax/_src/numpy/lax_numpy.py:3134:20 error[not-iterable] Object of type `(Sequence[int] & tuple[object, ...]) | Array | ndarray[tuple[Any, ...], dtype[Any]] | ... omitted 11 union elements` may not be iterable
mypy (https://github.com/python/mypy)
- mypy/checkmember.py:1520:12 error[invalid-return-type] Return type does not match returned value: expected `F@bind_self_fast`, found `CallableType`
pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/algorithms.py:586:12 error[no-matching-overload] No overload of bound method `ndarray.any` matches arguments
- pandas/core/arrays/boolean.py:264:12 error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[tuple[Any, ...], dtype[Any]], ndarray[tuple[Any, ...], dtype[Any]]]`, found `tuple[(Unknown & ndarray[tuple[object, ...], dtype[object]]) | ndarray[tuple[int], dtype[Any]], Unknown | ndarray[Unknown, dtype[Any]] | None | ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]] | ndarray[tuple[Any, ...], dtype[Any]]]`
+ pandas/core/arrays/boolean.py:264:12 error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[tuple[Any, ...], dtype[Any]], ndarray[tuple[Any, ...], dtype[Any]]]`, found `tuple[(Unknown & ndarray[tuple[object, ...], dtype[object]] & ~BooleanArray) | ndarray[tuple[int], dtype[Any]], Unknown | ndarray[Unknown, dtype[Any]] | None | ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]] | ndarray[tuple[Any, ...], dtype[Any]]]`
- pandas/core/arrays/datetimes.py:3103:21 error[invalid-assignment] Object of type `Timestamp` is not assignable to `_TimestampNoneT1@_maybe_normalize_endpoints`
- pandas/core/arrays/datetimes.py:3106:19 error[invalid-assignment] Object of type `Timestamp` is not assignable to `_TimestampNoneT2@_maybe_normalize_endpoints`
+ pandas/core/arrays/masked.py:1894:52 error[invalid-argument-type] Argument to bound method `BaseMaskedArray._maybe_mask_result` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[Unknown, dtype[Any]] | numpy.bool[builtins.bool] | ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]]`
- pandas/core/computation/pytables.py:190:19 error[invalid-argument-type] Argument to bound method `ndarray.ravel` is incorrect: Argument type `ndarray[tuple[object, ...], dtype[object]]` does not satisfy upper bound `ndarray[_ShapeT_co@ndarray, _DTypeT_co@ndarray]` of type variable `Self`
+ pandas/core/computation/pytables.py:190:19 error[invalid-argument-type] Argument to bound method `ndarray.ravel` is incorrect: Argument type `list[Unknown] & ndarray[tuple[object, ...], dtype[object]]` does not satisfy upper bound `ndarray[_ShapeT_co@ndarray, _DTypeT_co@ndarray]` of type variable `Self`
+ pandas/core/groupby/groupby.py:5784:16 error[invalid-return-type] Return type does not match returned value: expected `NDFrameT@GroupBy`, found `NDFrameT@GroupBy | (Self'return@_constructor & Series)`
- pandas/core/indexes/base.py:5233:13 error[unresolved-attribute] Attribute `flags` is not defined on `ExtensionArray` in union `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]`
- pandas/core/internals/blocks.py:2439:9 error[unresolved-attribute] Attribute `flags` is not defined on `ExtensionArray` in union `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]`
+ pandas/core/ops/mask_ops.py:73:17 error[unsupported-operator] Unary operator `~` is not supported for object of type `ndarray[tuple[Any, ...], dtype[Any]] | (NAType & ndarray[tuple[object, ...], dtype[object]])`
+ pandas/core/ops/mask_ops.py:78:12 error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]], ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]]]`, found `tuple[ndarray[tuple[Any, ...], dtype[Any]] | (NAType & ndarray[tuple[object, ...], dtype[object]]) | Unknown, Unknown | ndarray[tuple[Any, ...], dtype[Any]]]`
- pandas/core/resample.py:3215:12 error[invalid-return-type] Return type does not match returned value: expected `FreqIndexT@_asfreq_compat`, found `PeriodIndex | DatetimeIndex | TimedeltaIndex`
+ pandas/core/resample.py:3215:12 error[invalid-return-type] Return type does not match returned value: expected `FreqIndexT@_asfreq_compat`, found `(FreqIndexT@_asfreq_compat & ExactlySized[Literal[0, False]] & PeriodIndex) | DatetimeIndex | TimedeltaIndex`
+ pandas/core/sorting.py:373:31 error[unsupported-operator] Unary operator `-` is not supported for object of type `(ExtensionArray & ndarray[tuple[object, ...], dtype[object]]) | ndarray[tuple[Any, ...], dtype[Any]] | (Index & ndarray[tuple[object, ...], dtype[object]]) | (Series & ndarray[tuple[object, ...], dtype[object]])`
+ pandas/core/sorting.py:382:27 error[unsupported-operator] Unary operator `~` is not supported for object of type `(ExtensionArray & ndarray[tuple[object, ...], dtype[object]]) | ndarray[tuple[Any, ...], dtype[Any]] | (Index & ndarray[tuple[object, ...], dtype[object]]) | (Series & ndarray[tuple[object, ...], dtype[object]])`
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/templating/__init__.py:95: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/__init__.py:227:29 error[no-matching-overload] No overload of function `apply_values` matches arguments
- src/prefect/utilities/templating/__init__.py:235: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/__init__.py:237: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/__init__.py:426:33 error[no-matching-overload] No overload of bound method `dict.get` matches arguments
- src/prefect/utilities/templating/__init__.py:426:33 error[no-matching-overload] No overload of bound method `dict.get` matches arguments
- src/prefect/utilities/templating/__init__.py:432:17 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `T@resolve_block_document_references | dict[str, Any]` on object of type `dict[str, Any]`
- src/prefect/utilities/templating/__init__.py:432:56 error[invalid-argument-type] Argument to function `_resolve` is incorrect: Expected `T@resolve_block_document_references`, found `object`
- src/prefect/utilities/templating/__init__.py:541:20 error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, T@resolve_variables]`
+ src/prefect/utilities/templating/__init__.py:541:20 error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[Any, T@resolve_variables]`
- src/prefect/utilities/templating/__init__.py:541:41 error[invalid-argument-type] Argument to function `_resolve` is incorrect: Expected `T@resolve_variables`, found `object`
psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/_copy.py:66:9 error[invalid-assignment] Object of type `(bound method Writer & ~AlwaysFalsy.write(data: bytes | bytearray | memoryview[int]) -> None) | (bound method LibpqWriter.write(data: bytes | bytearray | memoryview[int]) -> None)` is not assignable to attribute `_write` of type `(bound method Writer.write(data: bytes | bytearray | memoryview[int]) -> None) | (bound method LibpqWriter.write(data: bytes | bytearray | memoryview[int]) -> None)`
+ psycopg/psycopg/_copy_async.py:63:9 error[invalid-assignment] Object of type `(bound method AsyncWriter & ~AlwaysFalsy.write(data: bytes | bytearray | memoryview[int]) -> CoroutineType[Any, Any, None]) | (bound method AsyncLibpqWriter.write(data: bytes | bytearray | memoryview[int]) -> CoroutineType[Any, Any, None])` is not assignable to attribute `_write` of type `(bound method AsyncWriter.write(data: bytes | bytearray | memoryview[int]) -> CoroutineType[Any, Any, None]) | (bound method AsyncLibpqWriter.write(data: bytes | bytearray | memoryview[int]) -> CoroutineType[Any, Any, None])`
pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/assertion/util.py:96:12 error[invalid-return-type] Return type does not match returned value: expected `list[str]`, found `list[LiteralString]`
+ src/_pytest/skipping.py:298:25 error[invalid-argument-type] Argument to bound method `AbstractRaises.matches` is incorrect: Argument type `object` does not satisfy upper bound `BaseException` of type variable `BaseExcT_1`
+ src/_pytest/skipping.py:298:25 error[invalid-argument-type] Argument to bound method `AbstractRaises.matches` is incorrect: Argument type `object` does not satisfy upper bound `BaseException` of type variable `BaseExcT_1`
pytest-autoprofile (https://gitlab.com/TTsangSC/pytest-autoprofile)
- src/pytest_autoprofile/importers.py:1026:20 error[invalid-return-type] Return type does not match returned value: expected `tuple[list[str], list[str]]`, found `tuple[list[str], list[LiteralString]]`
+ src/pytest_autoprofile/importers.py:1026:20 error[invalid-return-type] Return type does not match returned value: expected `tuple[list[str], list[str]]`, found `tuple[list[str], list[str] | list[LiteralString]]`
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
spark (https://github.com/apache/spark)
+ python/pyspark/mllib/feature.py:636:20 error[invalid-return-type] Return type does not match returned value: expected `Vector | RDD[Vector]`, found `RDD[Vector | RDD[Vector]]`
+ python/pyspark/mllib/feature.py:636:33 error[invalid-argument-type] Argument to bound method `RDD.map` is incorrect: Expected `(object, /) -> Vector | RDD[Vector]`, found `Overload[(document: Iterable[Hashable]) -> Vector, (document: RDD[Iterable[Hashable]]) -> RDD[Vector]]`
- python/pyspark/pandas/base.py:1065:16 error[unresolved-attribute] Object of type `IndexOpsMixin` has no attribute `rename`
+ python/pyspark/pandas/base.py:1065:16 error[unresolved-attribute] Object of type `IndexOpsLike@notnull` has no attribute `rename`
- python/pyspark/sql/session.py:1639:62 error[invalid-argument-type] Argument to bound method `ndarray.squeeze` is incorrect: Argument type `ndarray[tuple[object, ...], dtype[object]]` does not satisfy upper bound `ndarray[_ShapeT_co@ndarray, _DTypeT_co@ndarray]` of type variable `Self`
+ python/pyspark/sql/session.py:1639:62 error[invalid-argument-type] Argument to bound method `ndarray.squeeze` is incorrect: Argument type `ndarray[tuple[object, ...], dtype[object]] & ~DataFrame` does not satisfy upper bound `ndarray[_ShapeT_co@ndarray, _DTypeT_co@ndarray]` of type variable `Self`
static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/container_util.py:186:22 error[invalid-assignment] Object of type `Top[defaultdict[Unknown, Unknown]]` is not assignable to `None | Iterable[str | dtype[Any] | type | None] | dtype[Any] | type | dict[Hashable, str | dtype[Any] | type | None]`
- static_frame/core/util.py:451:22 error[not-iterable] Object of type `(int & ndarray[tuple[object, ...], dtype[object]]) | (list[int] & ndarray[tuple[object, ...], dtype[object]]) | (ndarray[Any, dtype[signedinteger[_64Bit]]] & ndarray[tuple[object, ...], dtype[object]])` is not iterable
+ static_frame/core/util.py:451:22 error[not-iterable] Object of type `(int & ndarray[tuple[object, ...], dtype[object]]) | (list[int] & ndarray[tuple[object, ...], dtype[object]]) | (ndarray[Any, dtype[signedinteger[_64Bit]]] & ndarray[tuple[object, ...], dtype[object]])` may not be iterable
sympy (https://github.com/sympy/sympy)
- sympy/polys/polyclasses.py:1308:31 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ sympy/polys/rings.py:884:20 error[invalid-argument-type] Argument to bound method `PolyElement._try_add_ground` is incorrect: Argument type `PolyElement[PolyElement[Er@PolyElement]] & ~PolyElement[Er@PolyElement]` does not satisfy upper bound `PolyElement[Er@PolyElement]` of type variable `Self`
+ sympy/polys/rings.py:944:20 error[invalid-argument-type] Argument to bound method `PolyElement._try_rsub_ground` is incorrect: Argument type `PolyElement[PolyElement[Er@PolyElement]] & ~PolyElement[Er@PolyElement]` does not satisfy upper bound `PolyElement[Er@PolyElement]` of type variable `Self`
+ sympy/polys/rings.py:1021:20 error[invalid-argument-type] Argument to bound method `PolyElement._try_mul_ground` is incorrect: Argument type `PolyElement[PolyElement[Er@PolyElement]] & ~AlwaysFalsy & ~PolyElement[Er@PolyElement]` does not satisfy upper bound `PolyElement[Er@PolyElement]` of type variable `Self`
vision (https://github.com/pytorch/vision)
+ torchvision/transforms/functional.py:154:32 error[no-matching-overload] No overload of bound method `ndarray.transpose` matches arguments
+ torchvision/transforms/functional.py:154:46 error[invalid-argument-type] Argument to bound method `Image.transpose` is incorrect: Expected `Transpose`, found `tuple[Literal[2], Literal[0], Literal[1]]`
xarray (https://github.com/pydata/xarray)
- 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/groupby.py:781:20 error[invalid-return-type] Return type does not match returned value: expected `T_Xarray@GroupBy`, found `DataArray`
- 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 | (T_PandasOrXarrayIndex@Indexes & xarray.core.indexes.Index & ~Top[pandas.core.indexes.base.Index[Any]])` is not assignable to `T_PandasOrXarrayIndex@Indexes`
- xarray/namedarray/core.py:1000:54 error[invalid-argument-type] Argument to bound method `_sparsearrayfunction.todense` is incorrect: Argument type `_sparsearrayfunction[object, object]` does not satisfy upper bound `_sparsearrayfunction[_ShapeType_co@_sparsearrayfunction, _DType_co@_sparsearrayfunction]` of type variable `Self`
+ xarray/namedarray/core.py:1000:54 error[invalid-argument-type] Argument to bound method `_sparsearrayfunction.todense` is incorrect: Argument type `_arrayapi[Any, _DType_co@NamedArray] & _sparsearrayfunction[object, object]` does not satisfy upper bound `_sparsearrayfunction[_ShapeType_co@_sparsearrayfunction, _DType_co@_sparsearrayfunction]` of type variable `Self`
+ xarray/namedarray/core.py:1000:54 error[invalid-argument-type] Argument to bound method `_sparsearrayfunction.todense` is incorrect: Argument type `_arrayfunction[Any, _DType_co@NamedArray] & _sparsearrayfunction[object, object]` does not satisfy upper bound `_sparsearrayfunction[_ShapeType_co@_sparsearrayfunction, _DType_co@_sparsearrayfunction]` of type variable `Self`6642459 to
4289d95
Compare
|
I used the "summarise ecosystem results" skill and this is what Codex came up with, in case it's helpful DetailsPR #25626 ecosystem summaryResultThe report contains 72 changes across 21 projects:
The changes are mechanically coherent with the PR. They reduce to preserving The ecosystem impact splits into two broad groups:
The largest actionable cluster is the second group. In particular, the new Minimized changes1.
|
|
Thanks! I had Codex do a similar analysis and concluded that these were mostly existing limitations made visible by our change. Is that your impression, at first glance? Or would you expect them to be fixed here? Tragically, I have a stack of seven additional commits / PRs that go on to improve the behavior here, with titles like...
|
|
I haven't actually looked through the analysis yet I'm afraid 😄 just set it going on it earlier and figured I'd post it in case it's useful! |
57c3a5f to
4c2ffb3
Compare
9834320 to
8b4853d
Compare
8b4853d to
98bf422
Compare
| For `Intersection[A, B]`, member lookup searches `A` and `B` separately to find the attribute. Once | ||
| found, however, descriptors and `Self` must be bound using the full `A & B` receiver. |
There was a problem hiding this comment.
Minor: would be nice to move this to the section(s) below.
| from typing import Any, TypeVar, overload | ||
| from typing_extensions import Self | ||
| from ty_extensions import Intersection | ||
|
|
||
| T = TypeVar("T") | ||
|
|
||
| class Descriptor: | ||
| @overload | ||
| def __get__(self, instance: None, owner: type, /) -> Self: ... | ||
| @overload | ||
| def __get__(self, instance: T, owner: type | None = None, /) -> T: ... | ||
| def __get__(self, instance: object, owner: type | None = None, /) -> Any: ... | ||
|
|
||
| class A: | ||
| desc = Descriptor() | ||
|
|
||
| class B: ... | ||
|
|
||
| def _(a_and_b: Intersection[A, B]): | ||
| reveal_type(a_and_b.desc) # revealed: A & B |
There was a problem hiding this comment.
Minor: The instance: None overload is irrelevant/distracting here?
| from typing import Any, TypeVar, overload | |
| from typing_extensions import Self | |
| from ty_extensions import Intersection | |
| T = TypeVar("T") | |
| class Descriptor: | |
| @overload | |
| def __get__(self, instance: None, owner: type, /) -> Self: ... | |
| @overload | |
| def __get__(self, instance: T, owner: type | None = None, /) -> T: ... | |
| def __get__(self, instance: object, owner: type | None = None, /) -> Any: ... | |
| class A: | |
| desc = Descriptor() | |
| class B: ... | |
| def _(a_and_b: Intersection[A, B]): | |
| reveal_type(a_and_b.desc) # revealed: A & B | |
| from typing import TypeVar | |
| from typing_extensions import Self | |
| from ty_extensions import Intersection | |
| T = TypeVar(name="T") | |
| class Descriptor: | |
| def __get__(self, instance: T, owner: type | None = None, /) -> T: | |
| return instance | |
| class A: | |
| desc = Descriptor() | |
| class B: ... | |
| def _(a_and_b: Intersection[A, B]): | |
| reveal_type(a_and_b.desc) # revealed: A & B |
|
|
||
| def test(x: Intersection[X, Y]) -> None: | ||
| reveal_type(x.f) # revealed: (bound method X.f() -> int) & (bound method Y.f() -> int) | ||
| reveal_type(x.f) # revealed: bound method X & Y.f() -> int |
There was a problem hiding this comment.
These display types are very unfortunate. Can we make this (X & Y).f() -> int?
| the underlying function object. A protocol refinement of the bound method must not be used as the | ||
| receiver for that underlying-function fallback: |
There was a problem hiding this comment.
I don't understand this. Why should we make an exception here?
There was a problem hiding this comment.
method = C().f is a bound method. When you evaluate method.__globals__, if it doesn't exist on method, then CPython tries method.__func__.__globals__. When we narrow with a protocol, only the bound method gets refined, and not the fallback __func__ -- if we apply the intersection to method.__func__ too, then method.__globals__ becomes Unknown.
I don't know if it's really an exception, IIUC lookup is being done on a different object so we need to respect the receivers.
There was a problem hiding this comment.
lookup is being done on a different object so we need to respect the receivers.
Thank you, that makes sense to me!
| Standard `partial` attributes like `.func`, `.args`, and `.keywords` should be accessible. Runtime | ||
| protocol narrowing can add a refinement to the concrete `partial` object, but attributes provided by | ||
| `partial` must remain precise when looked up through that intersection. |
There was a problem hiding this comment.
Similar question here: what makes partial special? Why should it be excluded from the behavior implemented in this PR?
There was a problem hiding this comment.
I think you're right that this isn't special, I think it was leftover from a prior workaround during a refactor, my bad.
|
Fixed in #25819, thank you. |
## Summary This follows up on [the post-merge review](#25626 (review)) of #25626. `functools.partial` now preserves the full intersection receiver when delegating member lookup to its nominal `partial[T]` view. Bound-method fallback still resets the receiver when lookup switches to the separate underlying function object; the implementation and regression coverage now make that distinction explicit. This also parenthesizes compound bound-method receivers in displayed types and clarifies and relocates the related intersection receiver documentation and tests.
Summary
When looking up an attribute on an intersection, we search each positive element independently. We previously also used that individual element as the receiver when binding descriptors and
Self, which meant we lost constraints:This change separates (1) the type whose members are searched from (2) the receiver used to bind the resulting attribute. We continue searching each intersection element independently, but bind descriptors and Self using the full intersection:
Closes astral-sh/ty#3565.
Closes astral-sh/ty#3600.