Skip to content

[ty] Simplify intersections with bounded covariant generics - #27243

Draft
sharkdp wants to merge 1 commit into
mainfrom
david/bounded-covariant-subtyping
Draft

[ty] Simplify intersections with bounded covariant generics#27243
sharkdp wants to merge 1 commit into
mainfrom
david/bounded-covariant-subtyping

Conversation

@sharkdp

@sharkdp sharkdp commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Recognize that a gradual specialization of a bounded covariant generic is a subtype of its own upper bound. For example, Bounded[Any] & ~Bounded[UpperBound] simplifies to Never when Bounded is covariant and its type variable has a declared upper bound.

Related to astral-sh/ty#4103.

Test Plan

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jul 28, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 96.84%. The percentage of expected errors that received a diagnostic held steady at 92.11%. The number of fully passing files held steady at 99/133.

@astral-sh-bot

astral-sh-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
unresolved-attribute 0 4 0
invalid-argument-type 0 0 1
no-matching-overload 0 1 0
Total 0 5 1

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Raw diff:

colour (https://github.com/colour-science/colour)
- colour/continuous/multi_signals.py:1492:44 error[invalid-argument-type] Argument to `Signal.__init__` is incorrect: Argument type `(_SupportsArray[dtype[Any]] & Top[Series[Any]] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]]) | (_NestedSequence[_SupportsArray[dtype[Any]]] & Top[Series[Any]] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]]) | (DataFrame & Top[Series[Any]] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]]) | (Sequence[Unknown] & Top[Series[Any]] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]]) | (Series[Any] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]])` does not satisfy upper bound `Signal` of type variable `Self`
+ colour/continuous/multi_signals.py:1492:44 error[invalid-argument-type] Argument to `Signal.__init__` is incorrect: Argument type `(DataFrame & Top[Series[Any]] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]]) | (Sequence[Unknown] & Top[Series[Any]] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]]) | (Series[Any] & ~Signal & ~MultiSignals & ~tuple[object, ...] & ~Top[list[Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Iterator[object] & ~ValuesView[object] & ~Top[dict[Unknown, Unknown]])` does not satisfy upper bound `Signal` of type variable `Self`

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/array_algos/take.py:124:16 error[no-matching-overload] No overload of bound method `ndarray.take` matches arguments

xarray (https://github.com/pydata/xarray)
- xarray/core/variable.py:963:30 error[unresolved-attribute] Attribute `shape` is not defined on `_SupportsArray[dtype[Any]]`, `_NestedSequence[_SupportsArray[dtype[Any]]]` in union `(T_DuckArray@_copy & ~None) | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]`
- xarray/core/variable.py:965:35 error[unresolved-attribute] Attribute `shape` is not defined on `_SupportsArray[dtype[Any]]`, `_NestedSequence[_SupportsArray[dtype[Any]]]` in union `(T_DuckArray@_copy & ~None) | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]`
- xarray/core/variable.py:2920:30 error[unresolved-attribute] Attribute `shape` is not defined on `_SupportsArray[dtype[Any]]`, `_NestedSequence[_SupportsArray[dtype[Any]]]` in union `(T_DuckArray@copy & ~None) | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]`
- xarray/core/variable.py:2922:35 error[unresolved-attribute] Attribute `shape` is not defined on `_SupportsArray[dtype[Any]]`, `_NestedSequence[_SupportsArray[dtype[Any]]]` in union `(T_DuckArray@copy & ~None) | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]`

Full report with detailed diff (timing results)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant