[ty] Fix intersection <-> Protocol type relations#24830
Draft
AlexWaygood wants to merge 5 commits into
Draft
Conversation
b4dbafc to
2853ea3
Compare
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
19 | 0 | 4 |
unsupported-operator |
8 | 0 | 1 |
unresolved-attribute |
4 | 0 | 3 |
unused-type-ignore-comment |
0 | 4 | 0 |
call-top-callable |
2 | 0 | 0 |
invalid-assignment |
1 | 0 | 1 |
invalid-return-type |
2 | 0 | 0 |
| Total | 36 | 4 | 9 |
Raw diff (49 changes)
altair (https://github.com/vega/altair)
- altair/utils/data.py:209:28 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~None & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
+ altair/utils/data.py:209:28 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
- altair/utils/data.py:210:39 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~None & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
+ altair/utils/data.py:210:39 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
- altair/utils/data.py:416:12 error[unresolved-attribute] Attribute `write_csv` is not defined on `NativeDataFrame & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]`, `DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]`, `DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]` in union `(NativeDataFrame & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
+ altair/utils/data.py:416:12 error[unresolved-attribute] Object of type `(NativeDataFrame & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]])` has no attribute `write_csv`
beartype (https://github.com/beartype/beartype)
- beartype/_util/func/utilfunctest.py:1262:16 error[unresolved-attribute] Attribute `__name__` is not defined on `(...) -> Unknown` in union `(Any & ~MethodType) | ((...) -> Unknown)`
+ beartype/_util/func/utilfunctest.py:1262:16 error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/bot.py:1222:79 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ discord/ext/commands/cog.py:527:13 error[unresolved-attribute] Unresolved attribute `__cog_listener__` on type `(...) -> Coroutine[Any, Any, Any]`
+ discord/ext/commands/cog.py:528:33 error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, Any]` has no attribute `__name__`
+ discord/ext/commands/cog.py:530:17 error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, Any]` has no attribute `__cog_listener_names__`
+ discord/ext/commands/cog.py:532:17 error[unresolved-attribute] Unresolved attribute `__cog_listener_names__` on type `(...) -> Coroutine[Any, Any, Any]`
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_implementations.py:2555:76 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
ibis (https://github.com/ibis-project/ibis)
- ibis/common/annotations.py:653:5 error[unresolved-attribute] Unresolved attribute `__signature__` on type `_Wrapped[(...), Unknown, (...), Unknown]`
+ ibis/common/annotations.py:653:5 error[unresolved-attribute] Unresolved attribute `__signature__` on type `_Wrapped[(...), object, (...), Unknown]`
jax (https://github.com/google/jax)
+ jax/_src/lax/slicing.py:3425:21 error[invalid-argument-type] Argument to bound method `list.append` is incorrect: Expected `Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | ... omitted 4 union elements`, found `object`
+ jax/_src/lax/slicing.py:3452:21 error[invalid-argument-type] Argument to bound method `list.append` is incorrect: Expected `Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | ... omitted 4 union elements`, found `~int & ~Top[integer[Any]]`
- jax/_src/lax/slicing.py:3450:32 error[unsupported-operator] Operator `<` is not supported between objects of type `(Array & ~int & ~Top[integer[Any]]) | (ndarray[tuple[Any, ...], dtype[Any]] & ~int & ~Top[integer[Any]]) | (numpy.bool[builtins.bool] & ~int & ~Top[integer[Any]]) | ... omitted 4 union elements` and `Literal[0]`
+ jax/_src/lax/slicing.py:3450:32 error[unsupported-operator] Operator `<` is not supported between objects of type `~int & ~Top[integer[Any]]` and `Literal[0]`
+ jax/_src/lax/slicing.py:3450:39 error[unsupported-operator] Operator `+` is not supported between objects of type `~int & ~Top[integer[Any]]` and `Array`
+ jax/_src/lax/slicing.py:3450:50 error[invalid-argument-type] Argument to function `select` is incorrect: Expected `Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | ... omitted 4 union elements`, found `~int & ~Top[integer[Any]]`
psycopg (https://github.com/psycopg/psycopg)
+ psycopg_pool/psycopg_pool/pool_async.py:710:20 error[invalid-return-type] Return type does not match returned value: expected `str`, found `object`
+ psycopg_pool/psycopg_pool/pool_async.py:710:26 error[call-top-callable] Object of type `Overload[[**P, T](f: (**P) -> Awaitable[T], *args: P.args, **kwargs: P.kwargs) -> CoroutineType[Any, Any, T], [**P, T](f: (**P) -> T, *args: P.args, **kwargs: P.kwargs) -> CoroutineType[Any, Any, T]]` is not safe to call; its signature is not known
+ psycopg_pool/psycopg_pool/pool_async.py:720:20 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `object`
+ psycopg_pool/psycopg_pool/pool_async.py:720:26 error[call-top-callable] Object of type `Overload[[**P, T](f: (**P) -> Awaitable[T], *args: P.args, **kwargs: P.kwargs) -> CoroutineType[Any, Any, T], [**P, T](f: (**P) -> T, *args: P.args, **kwargs: P.kwargs) -> CoroutineType[Any, Any, T]]` is not safe to call; its signature is not known
pydantic (https://github.com/pydantic/pydantic)
+ pydantic/deprecated/decorator.py:65:25 error[invalid-argument-type] Argument to function `validate` is incorrect: Expected `(...) -> Any`, found `AnyCallableT@validate_arguments & ~AlwaysFalsy`
+ pydantic/v1/decorator.py:49:25 error[invalid-argument-type] Argument to function `validate` is incorrect: Expected `(...) -> Any`, found `AnyCallableT@validate_arguments & ~AlwaysFalsy`
scipy (https://github.com/scipy/scipy)
- scipy/sparse/_sputils.py:529:16 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `Sized`
+ scipy/sparse/_sputils.py:529:16 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `(Unknown & tuple[object, ...]) | (Unknown & Top[list[Unknown]]) | Sized`
scrapy (https://github.com/scrapy/scrapy)
+ tests/test_http_request.py:288:55 error[invalid-argument-type] Argument to `Request.__init__` is incorrect: Expected `((Unknown, /) -> Any) | None`, found `(def a_function() -> Unknown) & ((Response, /, *args: Any, **kwargs: Any) -> Any)`
spack (https://github.com/spack/spack)
+ lib/spack/spack/multimethod.py:97:38 error[invalid-argument-type] Argument to function `update_wrapper` is incorrect: Expected `(...) -> Unknown`, found `Self@register & ~<Protocol with members '__name__'>`
- lib/spack/spack/vendor/ruamel/yaml/representer.py:458:30 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `str | ((...) -> Any) | tuple[Any, ...] | (Any & ~None)`
+ lib/spack/spack/vendor/ruamel/yaml/representer.py:458:30 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `str | ((...) -> Any) | tuple[Any, ...]`
streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/elements/dialog_decorator.py:314:9 error[invalid-argument-type] Argument to function `_dialog_decorator` is incorrect: Argument type `F@dialog_decorator & ~str` does not satisfy upper bound `(...) -> Any` of type variable `F`
sympy (https://github.com/sympy/sympy)
+ sympy/polys/series/ringpython.py:189:37 error[invalid-argument-type] Argument to function `dup_add_ground` is incorrect: Argument type `Er@_useries_add_ground & ~Literal[0]` does not satisfy upper bound `RingElement` of type variable `Er`
+ sympy/polys/series/ringpython.py:216:37 error[invalid-argument-type] Argument to function `dup_sub_ground` is incorrect: Argument type `Er@_useries_sub_ground & ~Literal[0]` does not satisfy upper bound `RingElement` of type variable `Er`
+ sympy/polys/series/ringpython.py:234:41 error[invalid-argument-type] Argument to function `dup_add_ground` is incorrect: Argument type `Er@_useries_rsub_ground & ~Literal[0]` does not satisfy upper bound `RingElement` of type variable `Er`
+ sympy/polys/series/ringpython.py:266:37 error[invalid-argument-type] Argument to function `dup_mul_ground` is incorrect: Argument type `Er@_useries_mul_ground & ~Literal[0] & ~Literal[1] & ~Literal[-1]` does not satisfy upper bound `RingElement` of type variable `Er`
+ sympy/polys/series/ringpython.py:343:50 error[invalid-argument-type] Argument to function `_useries_mul_ground` is incorrect: Argument type `Ef@_useries_sqrt & ~AlwaysFalsy` does not satisfy upper bound `RingElement` of type variable `Er`
+ sympy/polys/series/ringpython.py:348:47 error[invalid-argument-type] Argument to function `_useries_mul_ground` is incorrect: Argument type `Ef@_useries_sqrt & ~AlwaysFalsy` does not satisfy upper bound `RingElement` of type variable `Er`
+ sympy/polys/densetools.py:296:9 error[unsupported-operator] Operator `*=` is not supported between objects of type `Er@dup_eval` and `Er@dup_eval & ~AlwaysFalsy`
+ sympy/polys/densetools.py:325:41 error[invalid-argument-type] Argument to function `dmp_mul_ground` is incorrect: Argument type `Er@dmp_eval & ~AlwaysFalsy` does not satisfy upper bound `RingElement` of type variable `Er`
+ sympy/polys/densetools.py:956:44 error[invalid-argument-type] Argument to function `dmp_mul_ground` is incorrect: Argument type `Er@dmp_shift & ~AlwaysFalsy` does not satisfy upper bound `RingElement` of type variable `Er`
- sympy/polys/domains/domain.py:590:51 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- sympy/polys/domains/domain.py:599:55 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ sympy/polys/domains/domain.py:618:38 error[invalid-argument-type] Argument to bound method `Domain.convert_from` is incorrect: Argument type `(Es@convert & DomainElement & ~Er@Domain & ~MPZ & ~int & ~float & ~complex) | (Expr & DomainElement & ~Er@Domain & ~MPZ)` does not satisfy upper bound `RingElement` of type variable `Es`
+ sympy/polys/rings.py:2201:13 error[unsupported-operator] Operator `+` is not supported between objects of type `Er@PolyElement` and `Er@PolyElement & ~AlwaysFalsy`
+ sympy/polys/rings.py:2226:13 error[unsupported-operator] Operator `-` is not supported between objects of type `Er@PolyElement` and `Er@PolyElement & ~AlwaysFalsy`
+ sympy/polys/rings.py:2251:26 error[unsupported-operator] Operator `*` is not supported between objects of type `Er@PolyElement` and `Er@PolyElement & ~AlwaysFalsy`
+ sympy/polys/rings.py:2550:13 error[unsupported-operator] Operator `*=` is not supported between objects of type `Er@PolyElement` and `(Er@PolyElement & ~AlwaysFalsy) | (int & ~AlwaysFalsy)`
+ sympy/polys/rings.py:3049:44 error[unsupported-operator] Operator `*` is not supported between objects of type `Er@PolyElement` and `Er@PolyElement & ~AlwaysFalsy`
+ sympy/polys/rings.py:3493:21 error[unsupported-operator] Operator `+=` is not supported between objects of type `Er@PolyElement` and `Er@PolyElement & ~AlwaysFalsy`
xarray (https://github.com/pydata/xarray)
- xarray/core/common.py:1702:22 error[invalid-assignment] Object of type `(type[Any] & Top[Mapping[Unknown, object]]) | (str & Top[Mapping[Unknown, object]]) | (tuple[Any, SupportsIndex | Sequence[SupportsIndex]] & Top[Mapping[Unknown, object]]) | ... omitted 5 union elements` is not assignable to `Mapping[Any, dtype[Any] | None | type[Any] | ... omitted 6 union elements]`
+ xarray/core/common.py:1702:22 error[invalid-assignment] Object of type `(_HasDType[dtype[Any]] & Top[Mapping[Unknown, object]]) | (str & Top[Mapping[Unknown, object]]) | (tuple[Any, SupportsIndex | Sequence[SupportsIndex]] & Top[Mapping[Unknown, object]]) | ... omitted 4 union elements` is not assignable to `Mapping[Any, dtype[Any] | None | type[Any] | ... omitted 6 union elements]`
+ xarray/namedarray/core.py:203:33 error[invalid-argument-type] Argument to `NamedArray.__init__` is incorrect: Expected `_arrayfunction[Any, Unknown] | _arrayapi[Any, Unknown]`, found `(_SupportsArray[dtype[Any]] & MaskedArray[tuple[object, ...], dtype[object]] & ~NamedArray[object, object]) | (_arrayapi[_ShapeType@from_array, _DType@from_array] & MaskedArray[tuple[object, ...], dtype[object]] & ~NamedArray[object, object]) | (_Buffer & MaskedArray[tuple[object, ...], dtype[object]] & ~NamedArray[object, object]) | ... omitted 6 union elements`
+ xarray/namedarray/core.py:206:33 error[invalid-argument-type] Argument to `NamedArray.__init__` is incorrect: Expected `_arrayfunction[Any, Unknown] | _arrayapi[Any, Unknown]`, found `(_SupportsArray[dtype[Any]] & _arrayfunction[object, object] & ~NamedArray[object, object] & ~MaskedArray[tuple[object, ...], dtype[object]] & ~generic[object]) | (_arrayapi[_ShapeType@from_array, _DType@from_array] & ~NamedArray[object, object] & ~MaskedArray[tuple[object, ...], dtype[object]] & ~generic[object]) | (_Buffer & _arrayfunction[object, object] & ~NamedArray[object, object] & ~MaskedArray[tuple[object, ...], dtype[object]] & ~generic[object]) | ... omitted 9 union elements`
+ xarray/namedarray/core.py:836:25 error[invalid-assignment] Object of type `(_arrayfunction[Any, _DType_co@NamedArray] & ~ExplicitlyIndexed) | (_arrayapi[Any, _DType_co@NamedArray] & ~ExplicitlyIndexed)` is not assignable to `_arrayfunction[Any, Any] | _arrayapi[Any, Any]`
Merging this PR will degrade performance by 5.88%
Performance Changes
Comparing Footnotes
|
e67985b to
2544414
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes astral-sh/ty#3612
Test Plan
mdtests updated and extended