[ty] support implicit recursive union type aliases - #22238
Conversation
Typing conformance results improved 🎉The percentage of diagnostics emitted that were expected errors increased from 88.79% to 88.87%. The percentage of expected errors that received a diagnostic increased from 84.63% to 85.29%. The number of fully passing files held steady at 84/134. SummaryHow are test cases classified?Each test case represents one expected error annotation or a group of annotations sharing a tag. Counts are per test case, not per diagnostic — multiple diagnostics on the same line count as one. Required annotations (
Test file breakdown1 file altered
True positives added (7)7 diagnostics
True positives changed (11)11 diagnostics
False positives changed (1)1 diagnostic
|
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
218 | 47 | 2,749 |
invalid-key |
4 | 4 | 1,834 |
invalid-assignment |
12 | 5 | 210 |
unresolved-attribute |
25 | 1 | 141 |
no-matching-overload |
113 | 0 | 0 |
invalid-return-type |
20 | 2 | 90 |
type-assertion-failure |
24 | 0 | 77 |
not-subscriptable |
3 | 0 | 52 |
unsupported-operator |
4 | 0 | 41 |
invalid-context-manager |
0 | 0 | 42 |
not-iterable |
2 | 3 | 19 |
unused-type-ignore-comment |
6 | 8 | 0 |
invalid-type-form |
0 | 0 | 9 |
invalid-yield |
0 | 0 | 8 |
assert-type-unspellable-subtype |
0 | 0 | 3 |
conflicting-declarations |
0 | 0 | 3 |
redundant-cast |
0 | 0 | 3 |
invalid-await |
0 | 0 | 2 |
invalid-parameter-default |
0 | 0 | 2 |
invalid-typed-dict-field |
0 | 0 | 2 |
missing-typed-dict-key |
0 | 2 | 0 |
invalid-declaration |
0 | 0 | 1 |
possibly-missing-attribute |
0 | 1 | 0 |
| Total | 431 | 73 | 5,288 |
Showing a random sample of 135 of 5792 changes. See the HTML report for the full diff.
Raw diff sample (135 of 5792 changes)
altair (https://github.com/vega/altair)
- tests/vegalite/v6/test_renderers.py:112:10 error[invalid-context-manager] Object of type `PluginEnabler[(...) -> dict[str, Any] | tuple[dict[str, Any], dict[str, Any]], dict[str, Any] | tuple[dict[str, Any], dict[str, Any]]]` cannot be used with `with` because it does not correctly implement `__exit__`
+ tests/vegalite/v6/test_renderers.py:112:10 error[invalid-context-manager] Object of type `PluginEnabler[(...) -> MimeBundleType, MimeBundleType]` cannot be used with `with` because it does not correctly implement `__exit__`
apprise (https://github.com/caronc/apprise)
- apprise/plugins/mastodon.py:1118:21 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `str | None`
+ apprise/plugins/mastodon.py:1118:21 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `ConvertibleToInt`, found `str | None`
bokeh (https://github.com/bokeh/bokeh)
- src/bokeh/models/annotations/html/labels.py:85:34 error[invalid-argument-type] Argument to `Property.__init__` is incorrect: Expected `Property[Unknown] | tuple[Property[Unknown], Property[Unknown], Property[Unknown], Property[Unknown]] | Corners[Property[Unknown]] | UndefinedType | IntrinsicType`, found `Literal[0]`
+ src/bokeh/models/annotations/html/labels.py:85:34 error[invalid-argument-type] Argument to `Property.__init__` is incorrect: Expected `BorderRadiusType | UndefinedType | IntrinsicType`, found `Literal[0]`
- src/bokeh/plotting/_figure.py:222:13 error[invalid-argument-type] Argument to function `process_active_tools` is incorrect: Expected `list[InspectTool] | InspectTool | str | None`, found `Nullable[Any | str]`
+ src/bokeh/plotting/_figure.py:222:13 error[invalid-argument-type] Argument to function `process_active_tools` is incorrect: Expected `ActiveInspect`, found `Nullable[Any | str]`
- src/bokeh/plotting/_plot.py:98:32 error[invalid-argument-type] Argument to `Range1d.__init__` is incorrect: Expected `int | float | datetime | timedelta`, found `int | float | (Unknown & ~None) | str | IntrinsicType`
+ src/bokeh/plotting/_plot.py:98:32 error[invalid-argument-type] Argument to `Range1d.__init__` is incorrect: Expected `Value`, found `int | float | (Unknown & ~None) | str | IntrinsicType`
- src/bokeh/transform.py:159:13 error[invalid-argument-type] Argument to `EqHistColorMapper.__init__` is incorrect: Expected `str | tuple[int, int, int] | tuple[int, int, int, int | float] | None`, found `str | Color | tuple[int, int, int] | tuple[int, int, int, int | float] | None`
+ src/bokeh/transform.py:159:13 error[invalid-argument-type] Argument to `EqHistColorMapper.__init__` is incorrect: Expected `Color | None`, found `ColorLike | None`
- src/bokeh/transform.py:373:13 error[invalid-argument-type] Argument to `LinearColorMapper.__init__` is incorrect: Expected `str | tuple[int, int, int] | tuple[int, int, int, int | float] | None`, found `str | Color | tuple[int, int, int] | tuple[int, int, int, int | float] | None`
+ src/bokeh/transform.py:373:13 error[invalid-argument-type] Argument to `LinearColorMapper.__init__` is incorrect: Expected `Color | None`, found `ColorLike | None`
cloud-init (https://github.com/canonical/cloud-init)
- cloudinit/config/cc_ntp.py:360:23 error[invalid-argument-type] Argument to function `exists` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `Unknown | None`
+ cloudinit/config/cc_ntp.py:360:23 error[invalid-argument-type] Argument to function `exists` is incorrect: Expected `FileDescriptorOrPath`, found `Unknown | None`
colour (https://github.com/colour-science/colour)
- colour/geometry/primitives.py:227:9 error[invalid-argument-type] Argument to function `zeros` is incorrect: Expected `type[signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | ... omitted 8 types] | None`, found `list[tuple[str, type[floating[_16Bit] | floating[_32Bit] | float64], int]]`
- colour/plotting/models.py:319:9 error[invalid-argument-type] Argument to function `zeros` is incorrect: Expected `type[signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | ... omitted 8 types] | None`, found `list[tuple[str, type[floating[_16Bit] | floating[_32Bit] | float64], int]]`
cryptography (https://github.com/pyca/cryptography)
- tests/hazmat/primitives/test_hkdf.py:250:25 error[invalid-argument-type] Argument to bound method `HKDFExpand.derive` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `Literal["first"]`
+ tests/hazmat/primitives/test_hkdf.py:250:25 error[invalid-argument-type] Argument to bound method `HKDFExpand.derive` is incorrect: Expected `Buffer`, found `Literal["first"]`
- tests/hazmat/primitives/test_hmac.py:36:22 error[invalid-argument-type] Argument to bound method `HMAC.update` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `Literal["ü"]`
+ tests/hazmat/primitives/test_hmac.py:36:22 error[invalid-argument-type] Argument to bound method `HMAC.update` is incorrect: Expected `Buffer`, found `Literal["ü"]`
- tests/hazmat/primitives/test_padding.py:171:29 error[invalid-argument-type] Argument to bound method `PaddingContext.update` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `Literal["abc"]`
+ tests/hazmat/primitives/test_padding.py:171:29 error[invalid-argument-type] Argument to bound method `PaddingContext.update` is incorrect: Expected `Buffer`, found `Literal["abc"]`
- tests/x509/test_x509_ext.py:2297:28 error[invalid-argument-type] Argument to `IPAddress.__init__` is incorrect: Expected `IPv4Address | IPv6Address | IPv4Network | IPv6Network`, found `float`
+ tests/x509/test_x509_ext.py:2297:28 error[invalid-argument-type] Argument to `IPAddress.__init__` is incorrect: Expected `_IPAddressTypes`, found `float`
cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/checker.py:141:62 error[invalid-argument-type] Argument to function `can_assign_src_to_sink` is incorrect: Expected `int | str | float | ... omitted 6 union elements`, found `~Literal["null"]`
+ cwltool/checker.py:141:62 error[invalid-argument-type] Argument to function `can_assign_src_to_sink` is incorrect: Expected `SinkType | None`, found `~Literal["null"]`
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- tests/ci_visibility/test_encoder.py:511:41 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `str | None`
+ tests/ci_visibility/test_encoder.py:511:41 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `ConvertibleToInt`, found `str | None`
- tests/ci_visibility/test_encoder.py:574:39 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `str | None`
+ tests/ci_visibility/test_encoder.py:574:39 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `ConvertibleToInt`, found `str | None`
- tests/profiling/collector/test_threading.py:1950:66 error[unresolved-attribute] Object of type `LockType | RLock | Semaphore | Condition` has no attribute `is_internal`
+ tests/profiling/collector/test_threading.py:1950:66 error[unresolved-attribute] Object of type `LockTypeInst` has no attribute `is_internal`
- tests/profiling/collector/test_threading.py:1956:17 error[unresolved-attribute] Object of type `LockType | RLock | Semaphore | Condition` has no attribute `_cond`
+ tests/profiling/collector/test_threading.py:1956:17 error[unresolved-attribute] Object of type `LockTypeInst` has no attribute `_cond`
freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/data/metrics.py:265:9 error[invalid-argument-type] Argument is incorrect: Expected `Timestamp`, found `str | bytes | date | ... omitted 9 union elements`
+ freqtrade/data/metrics.py:265:9 error[invalid-argument-type] Argument is incorrect: Expected `Timestamp`, found `Scalar`
- freqtrade/plot/plotting.py:188:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[[ScalarT](idx: tuple[int | str | Timestamp | tuple[str | bytes | date | ... omitted 9 union elements, ...] | ((DataFrame, /) -> ScalarT), int | str | tuple[str | bytes | date | ... omitted 9 union elements, ...]]) -> str | bytes | date | ... omitted 9 union elements, [ScalarT, HashableT](idx: ((DataFrame, /) -> ScalarT) | tuple[slice[Any, Any, Any] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | Index[Any] | ... omitted 8 union elements, ScalarT | None] | None) -> Series[Any], (idx: str | bytes | date | ... omitted 9 union elements) -> Series[Any] | DataFrame, (idx: tuple[str | bytes | date | ... omitted 9 union elements, slice[Any, Any, Any]] | tuple[slice[Any, Any, Any], tuple[str | bytes | date | ... omitted 9 union elements, ...]]) -> Series[Any] | DataFrame, [HashableT](key: slice[Any, Any, Any] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | Index[Any] | ... omitted 8 union elements) -> DataFrame]` cannot be called with key of type `tuple[datetime, Literal["cum_profit"]]` on object of type `_LocIndexerFrame[DataFrame]`
+ freqtrade/plot/plotting.py:188:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[[ScalarT](idx: tuple[int | StrLike | Timestamp | tuple[Scalar, ...] | ((DataFrame, /) -> ScalarT), int | StrLike | tuple[Scalar, ...]]) -> Scalar, [ScalarT, HashableT](idx: ((DataFrame, /) -> ScalarT) | tuple[slice[Any, Any, Any] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | Index[Any] | ... omitted 8 union elements, ScalarT | None] | None) -> Series[Any], (idx: Scalar) -> Series[Any] | DataFrame, (idx: tuple[Scalar, slice[Any, Any, Any]] | tuple[slice[Any, Any, Any], tuple[Scalar, ...]]) -> Series[Any] | DataFrame, [HashableT](key: slice[Any, Any, Any] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | Index[Any] | ... omitted 8 union elements) -> DataFrame]` cannot be called with key of type `tuple[datetime, Literal["cum_profit"]]` on object of type `_LocIndexerFrame[DataFrame]`
- freqtrade/rpc/rpc.py:794:46 error[invalid-argument-type] Argument to function `read_sql` is incorrect: Expected `str | ConnectionEventsTarget | sqlite3.Connection`, found `Engine | sqlalchemy.engine.base.Connection | None`
+ freqtrade/rpc/rpc.py:794:46 error[invalid-argument-type] Argument to function `read_sql` is incorrect: Expected `_SQLConnection`, found `Engine | Connection | None`
hydpy (https://github.com/hydpy-dev/hydpy)
- hydpy/core/testtools.py:2796:39 error[invalid-argument-type] Argument to bound method `HydPy.update_devices` is incorrect: Expected `Element | Iterable[Element | str] | None`, found `tuple[Device, Device, Device, Device, Device, Device, Device]`
+ hydpy/core/testtools.py:2796:39 error[invalid-argument-type] Argument to bound method `HydPy.update_devices` is incorrect: Expected `ElementsConstrArg | None`, found `tuple[Device, Device, Device, Device, Device, Device, Device]`
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- tests/annotations/declarations.py:366:59 error[invalid-key] Unknown key "a" for TypedDict `EmptyDict`
- tests/annotations/declarations.py:944:5 error[type-assertion-failure] Type `PBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 15 union elements]`
+ tests/annotations/declarations.py:944:5 error[type-assertion-failure] Type `PBuilds[Unknown]` does not match asserted type `PBuilds[SupportedPrimitive]`
jax (https://github.com/google/jax)
- jax/_src/core.py:3288:26 error[invalid-argument-type] Argument to bound method `HiType.dec_rank` is incorrect: Expected `int | None`, found `int | Tracer[Unknown] | Var`
+ jax/_src/core.py:3288:26 error[invalid-argument-type] Argument to bound method `HiType.dec_rank` is incorrect: Expected `int | None`, found `AxisSize`
- jax/_src/nn/functions.py:1248:22 error[invalid-argument-type] Argument to function `reshape` is incorrect: Expected `Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | ... omitted 4 union elements`, found `Unknown | tuple[Unknown, Array]`
+ jax/_src/nn/functions.py:1248:22 error[invalid-argument-type] Argument to function `reshape` is incorrect: Expected `ArrayLike`, found `Unknown | tuple[Unknown, Array]`
meson (https://github.com/mesonbuild/meson)
- mesonbuild/backend/ninjabackend.py:1775:41 error[invalid-argument-type] Argument to bound method `Compiler.get_colorout_args` is incorrect: Expected `str`, found `str | int | list[str]`
+ mesonbuild/backend/ninjabackend.py:1775:41 error[invalid-argument-type] Argument to bound method `Compiler.get_colorout_args` is incorrect: Expected `str`, found `ElementaryOptionValues`
- mesonbuild/build.py:881:19 error[invalid-argument-type] Argument to bound method `BuildTarget.link` is incorrect: Expected `list[BuildTarget | CustomTarget | CustomTargetIndex]`, found `list[SharedLibrary | StaticLibrary | CustomTarget | CustomTargetIndex]`
+ mesonbuild/build.py:881:19 error[invalid-argument-type] Argument to bound method `BuildTarget.link` is incorrect: Expected `list[BuildTargetTypes]`, found `list[LibTypes]`
- mesonbuild/build.py:1594:41 error[invalid-argument-type] Argument to bound method `BuildTarget.process_sourcelist` is incorrect: Expected `list[File | CustomTarget | CustomTargetIndex | ... omitted 4 union elements]`, found `list[File | CustomTarget | CustomTargetIndex | GeneratedList | StructuredSources]`
+ mesonbuild/build.py:1594:41 error[invalid-argument-type] Argument to bound method `BuildTarget.process_sourcelist` is incorrect: Expected `list[SourceOutputs]`, found `list[File | GeneratedTypes | StructuredSources]`
- mesonbuild/cmdline.py:47:16 error[invalid-return-type] Return type does not match returned value: expected `list[str]`, found `list[str | bytes] | list[bytes] | list[str]`
- mesonbuild/interpreter/interpreter.py:1727:63 error[invalid-argument-type] Argument to bound method `Interpreter.find_program_fallback` is incorrect: Expected `dict[OptionKey, str | int | list[str]]`, found `dict[OptionKey, str | int | list[str]] | None`
+ mesonbuild/interpreter/interpreter.py:1727:63 error[invalid-argument-type] Argument to bound method `Interpreter.find_program_fallback` is incorrect: Expected `dict[OptionKey, ElementaryOptionValues]`, found `dict[OptionKey, ElementaryOptionValues] | None`
- mesonbuild/interpreter/interpreter.py:2821:27 error[invalid-argument-type] Argument to function `open` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `(str & ~AlwaysTruthy & ~AlwaysFalsy) | (Program & ~AlwaysTruthy & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy)`
+ mesonbuild/interpreter/interpreter.py:2821:27 error[invalid-argument-type] Argument to function `open` is incorrect: Expected `FileDescriptorOrPath`, found `(str & ~AlwaysTruthy & ~AlwaysFalsy) | (Program & ~AlwaysTruthy & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy)`
- mesonbuild/interpreter/interpreter.py:3101:52 error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `Literal["set", "prepend", "append"]`, found `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`
+ mesonbuild/interpreter/interpreter.py:3101:52 error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `Literal["set", "prepend", "append"]`, found `Sequence[TYPE_var] | int | dict[str, TYPE_elementary] | ... omitted 3 union elements`
+ unittests/cargotests.py:379:68 error[invalid-key] Unknown key "optional" for TypedDict `FromWorkspace`
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- pymongo/message.py:1669:70 error[invalid-argument-type] Argument to bound method `ClientSession._apply_to` is incorrect: Expected `Connection`, found `AsyncConnection | Connection`
+ pymongo/message.py:1669:70 error[invalid-argument-type] Argument to bound method `ClientSession._apply_to` is incorrect: Expected `Connection`, found `_AgnosticConnection`
pandas (https://github.com/pandas-dev/pandas)
- pandas/core/dtypes/cast.py:340:42 error[invalid-argument-type] Argument to function `allclose` is incorrect: Expected `_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | ... omitted 5 union elements`, found `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]`
+ pandas/core/dtypes/cast.py:340:42 error[invalid-argument-type] Argument to function `allclose` is incorrect: Expected `numpy._typing._array_like.ArrayLike`, found `pandas._typing.ArrayLike`
- pandas/core/indexes/multi.py:2871:19 error[invalid-assignment] Object of type `ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]` is not assignable to `int`
+ pandas/core/indexes/multi.py:2871:19 error[invalid-assignment] Object of type `ndarray[tuple[Any, ...], dtype[signedinteger[_NBitIntP]]]` is not assignable to `int`
- pandas/tests/groupby/methods/test_quantile.py:102:51 error[invalid-argument-type] Argument to bound method `GroupBy.quantile` is incorrect: Expected `int | float | ExtensionArray | ... omitted 3 union elements`, found `list[int | float]`
+ pandas/tests/groupby/methods/test_quantile.py:102:51 error[invalid-argument-type] Argument to bound method `GroupBy.quantile` is incorrect: Expected `int | float | AnyArrayLike`, found `list[int | float]`
- pandas/tests/indexes/datetimes/methods/test_tz_localize.py:285:49 error[invalid-argument-type] Argument to constructor `DatetimeIndex.__new__` is incorrect: Expected `Literal["infer", "NaT", "raise"] | builtins.bool | ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]]`, found `list[int]`
+ pandas/tests/indexes/datetimes/methods/test_tz_localize.py:285:49 error[invalid-argument-type] Argument to constructor `DatetimeIndex.__new__` is incorrect: Expected `TimeAmbiguous`, found `list[int]`
- pandas/tests/internals/test_internals.py:415:33 error[invalid-argument-type] Argument to bound method `NDFrame._from_mgr` is incorrect: Expected `BlockManager | SingleBlockManager`, found `DataFrame | Series`
+ pandas/tests/internals/test_internals.py:415:33 error[invalid-argument-type] Argument to bound method `NDFrame._from_mgr` is incorrect: Expected `Manager`, found `DataFrame | Series`
- pandas/tests/io/formats/style/test_style.py:987:30 error[invalid-argument-type] Argument to `DataFrame.__init__` is incorrect: Expected `ExtensionDtype | str | dtype[Any] | type | None`, found `list[str]`
+ pandas/tests/io/formats/style/test_style.py:987:30 error[invalid-argument-type] Argument to `DataFrame.__init__` is incorrect: Expected `Dtype | None`, found `list[str]`
- pandas/tests/io/formats/test_format.py:2334:23 error[invalid-argument-type] Argument to function `open` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `StringIO | Unknown | str`
+ pandas/tests/io/formats/test_format.py:2334:23 error[invalid-argument-type] Argument to function `open` is incorrect: Expected `FileDescriptorOrPath`, found `StringIO | Unknown | str`
- pandas/tests/io/parser/dtypes/test_dtypes_basic.py:358:36 error[invalid-argument-type] Argument to constructor `floating.__new__` is incorrect: Expected `SupportsFloat | SupportsIndex | str | bytes | None`, found `list[int]`
+ pandas/tests/io/parser/dtypes/test_dtypes_basic.py:358:36 error[invalid-argument-type] Argument to constructor `floating.__new__` is incorrect: Expected `_ConvertibleToFloat | None`, found `list[int]`
- pandas/tests/io/parser/test_parse_dates.py:673:49 error[invalid-argument-type] Argument to constructor `DatetimeIndex.__new__` is incorrect: Expected `str | BaseOffset | _NoDefault`, found `None`
+ pandas/tests/io/parser/test_parse_dates.py:673:49 error[invalid-argument-type] Argument to constructor `DatetimeIndex.__new__` is incorrect: Expected `Frequency | _NoDefault`, found `None`
+ pandas/tests/io/test_sql.py:4063:52 error[invalid-argument-type] Argument to bound method `NDFrame.to_sql` is incorrect: Expected `DtypeArg | None`, found `dict[str, str]`
- pandas/tests/libs/test_libalgos.py:104:18 error[not-subscriptable] Cannot subscript object of type `def backfill(old: ndarray[tuple[Any, ...], dtype[Any]], new: ndarray[tuple[Any, ...], dtype[Any]], limit=...) -> ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]]` with no `__getitem__` method
+ pandas/tests/libs/test_libalgos.py:104:18 error[not-subscriptable] Cannot subscript object of type `def backfill(old: ndarray[tuple[Any, ...], dtype[Any]], new: ndarray[tuple[Any, ...], dtype[Any]], limit=...) -> ndarray[tuple[Any, ...], dtype[signedinteger[_NBitIntP]]]` with no `__getitem__` method
- pandas/tests/series/methods/test_reindex.py:321:38 error[invalid-argument-type] Argument to bound method `Series.reindex` is incorrect: Expected `str | bytes | date | ... omitted 11 union elements`, found `Unknown | Timestamp | NaTType`
+ pandas/tests/series/methods/test_reindex.py:321:38 error[invalid-argument-type] Argument to bound method `Series.reindex` is incorrect: Expected `Scalar | None`, found `Unknown | Timestamp | NaTType`
- pandas/tests/test_algos.py:2016:32 error[invalid-argument-type] Argument to function `mode` is incorrect: Expected `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]`, found `Index`
+ pandas/tests/test_algos.py:2016:32 error[invalid-argument-type] Argument to function `mode` is incorrect: Expected `ArrayLike`, found `Index`
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
- tests/extension/decimal/array.py:258:33 error[invalid-argument-type] Argument to constructor `Decimal.__new__` is incorrect: Expected `Decimal | int | float | str | tuple[int, Sequence[int], int]`, found `object`
+ tests/extension/decimal/array.py:258:33 error[invalid-argument-type] Argument to constructor `Decimal.__new__` is incorrect: Expected `_DecimalNew`, found `object | _DecimalNew`
pip (https://github.com/pypa/pip)
- src/pip/_vendor/urllib3/_request_methods.py:269:31 error[invalid-argument-type] Argument to function `urlencode` is incorrect: Expected `Mapping[str, object] | Mapping[bytes, object] | Mapping[str | bytes, object] | Sequence[tuple[str | bytes, object]]`, found `(Sequence[tuple[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | RequestField] & ~AlwaysFalsy) | (Mapping[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] & ~AlwaysFalsy)`
+ src/pip/_vendor/urllib3/_request_methods.py:269:31 error[invalid-argument-type] Argument to function `urlencode` is incorrect: Expected `_QueryType`, found `(Sequence[tuple[str, _TYPE_FIELD_VALUE_TUPLE] | RequestField] & ~AlwaysFalsy) | (Mapping[str, _TYPE_FIELD_VALUE_TUPLE] & ~AlwaysFalsy)`
pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/aglib/elf.py:412:32 error[invalid-argument-type] Argument to function `map_inner` is incorrect: Expected `Elf32_Ehdr | Elf64_Ehdr`, found `Elf32_Ehdr | Elf64_Ehdr | None`
+ pwndbg/aglib/elf.py:412:32 error[invalid-argument-type] Argument to function `map_inner` is incorrect: Expected `Ehdr`, found `Elf32_Ehdr | Elf64_Ehdr | None`
- pwndbg/aglib/heap/structs.py:186:60 error[invalid-argument-type] Method `__getitem__` of type `bound method dict[type[c_char], Type].__getitem__(key: type[c_char], /) -> Type` cannot be called with key of type `type[_Pointer[Any]]` on object of type `dict[type[c_char], Type]`
- pwndbg/commands/flags.py:59:31 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `int | None`
+ pwndbg/commands/flags.py:59:31 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `ConvertibleToInt`, found `int | None`
pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_generate_schema.py:2862:23 error[invalid-argument-type] Argument is incorrect: Expected `<TypedDict with items 'function', 'json_schema_input_schema', 'metadata', 'ref', 'schema', 'serialization', 'type'> | Iterable[tuple[str, object]]`, found `InvalidSchema | AnySchema | NoneSchema | ... omitted 49 union elements`
+ pydantic/_internal/_generate_schema.py:2862:23 error[invalid-argument-type] Argument is incorrect: Expected `<TypedDict with items 'function', 'json_schema_input_schema', 'metadata', 'ref', 'schema', 'serialization', 'type'> | Iterable[tuple[str, object]]`, found `CoreSchema`
- pydantic/_internal/_generate_schema.py:2862:23 error[invalid-argument-type] Argument is incorrect: Expected `<TypedDict with items 'ge', 'gt', 'le', 'lt', 'metadata', 'multiple_of', 'ref', 'serialization', 'strict', 'type'> | Iterable[tuple[str, object]]`, found `InvalidSchema | AnySchema | NoneSchema | ... omitted 49 union elements`
+ pydantic/_internal/_generate_schema.py:2862:23 error[invalid-argument-type] Argument is incorrect: Expected `<TypedDict with items 'ge', 'gt', 'le', 'lt', 'metadata', 'multiple_of', 'ref', 'serialization', 'strict', 'type'> | Iterable[tuple[str, object]]`, found `CoreSchema`
- pydantic/_internal/_mock_val_ser.py:173:5 error[invalid-assignment] Object of type `MockCoreSchema` is not assignable to attribute `__pydantic_core_schema__` of type `InvalidSchema | AnySchema | NoneSchema | ... omitted 49 union elements`
+ pydantic/_internal/_mock_val_ser.py:173:5 error[invalid-assignment] Object of type `MockCoreSchema` is not assignable to attribute `__pydantic_core_schema__` of type `CoreSchema`
- pydantic/_internal/_schema_gather.py:107:34 error[invalid-key] Unknown key "definitions" for TypedDict `BytesSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:107:34 error[invalid-key] Unknown key "definitions" for TypedDict `BytesSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:111:36 error[invalid-key] Unknown key "items_schema" for TypedDict `AfterValidatorFunctionSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:111:36 error[invalid-key] Unknown key "items_schema" for TypedDict `AfterValidatorFunctionSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:114:29 error[invalid-key] Unknown key "items_schema" for TypedDict `CallableSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:114:29 error[invalid-key] Unknown key "items_schema" for TypedDict `CallableSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:114:29 error[invalid-key] Unknown key "items_schema" for TypedDict `ChainSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:114:29 error[invalid-key] Unknown key "items_schema" for TypedDict `ChainSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:120:36 error[invalid-key] Unknown key "values_schema" for TypedDict `JsonOrPythonSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:120:36 error[invalid-key] Unknown key "values_schema" for TypedDict `JsonOrPythonSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:120:36 error[invalid-key] Unknown key "values_schema" for TypedDict `TimeSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:120:36 error[invalid-key] Unknown key "values_schema" for TypedDict `TimeSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:125:25 error[invalid-key] Unknown key "choices" for TypedDict `BytesSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:125:25 error[invalid-key] Unknown key "choices" for TypedDict `BytesSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:125:25 error[invalid-key] Unknown key "choices" for TypedDict `UrlSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:125:25 error[invalid-key] Unknown key "choices" for TypedDict `UrlSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:128:28 error[invalid-key] Unknown key "steps" for TypedDict `BytesSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:128:28 error[invalid-key] Unknown key "steps" for TypedDict `BytesSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:131:32 error[invalid-key] Unknown key "lax_schema" for TypedDict `FrozenSetSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:131:32 error[invalid-key] Unknown key "lax_schema" for TypedDict `FrozenSetSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:131:32 error[invalid-key] Unknown key "lax_schema" for TypedDict `StringSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:131:32 error[invalid-key] Unknown key "lax_schema" for TypedDict `StringSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:134:32 error[invalid-key] Unknown key "json_schema" for TypedDict `TupleSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:134:32 error[invalid-key] Unknown key "json_schema" for TypedDict `TupleSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:135:32 error[invalid-key] Unknown key "python_schema" for TypedDict `ModelSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:135:32 error[invalid-key] Unknown key "python_schema" for TypedDict `ModelSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:135:32 error[invalid-key] Unknown key "python_schema" for TypedDict `TaggedUnionSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:135:32 error[invalid-key] Unknown key "python_schema" for TypedDict `TaggedUnionSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:138:36 error[invalid-key] Unknown key "extras_schema" for TypedDict `ListSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:138:36 error[invalid-key] Unknown key "extras_schema" for TypedDict `ListSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:138:36 error[invalid-key] Unknown key "extras_schema" for TypedDict `StringSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:138:36 error[invalid-key] Unknown key "extras_schema" for TypedDict `StringSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:140:29 error[invalid-key] Unknown key "computed_fields" for TypedDict `ComputedField` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:140:29 error[invalid-key] Unknown key "computed_fields" for TypedDict `ComputedField` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:140:29 error[invalid-key] Unknown key "computed_fields" for TypedDict `ListSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:140:29 error[invalid-key] Unknown key "computed_fields" for TypedDict `ListSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:142:25 error[invalid-key] Unknown key "fields" for TypedDict `MissingSentinelSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:142:25 error[invalid-key] Unknown key "fields" for TypedDict `MissingSentinelSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `ComplexSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `ComplexSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `JsonSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `JsonSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `LaxOrStrictSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `LaxOrStrictSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `TimeSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:148:25 error[invalid-key] Unknown key "fields" for TypedDict `TimeSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:151:25 error[invalid-key] Unknown key "arguments_schema" for TypedDict `IntSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:151:25 error[invalid-key] Unknown key "arguments_schema" for TypedDict `IntSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:151:25 error[invalid-key] Unknown key "arguments_schema" for TypedDict `TimedeltaSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:151:25 error[invalid-key] Unknown key "arguments_schema" for TypedDict `TimedeltaSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:154:36 error[invalid-key] Unknown key "var_args_schema" for TypedDict `BeforeValidatorFunctionSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:154:36 error[invalid-key] Unknown key "var_args_schema" for TypedDict `BeforeValidatorFunctionSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:158:25 error[invalid-key] Unknown key "arguments_schema" for TypedDict `NoneSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:158:25 error[invalid-key] Unknown key "arguments_schema" for TypedDict `NoneSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:165:32 error[invalid-key] Unknown key "return_schema" for TypedDict `DataclassSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:165:32 error[invalid-key] Unknown key "return_schema" for TypedDict `DataclassSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:168:36 error[invalid-key] Unknown key "schema" for TypedDict `CallSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:168:36 error[invalid-key] Unknown key "schema" for TypedDict `CallSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:168:36 error[invalid-key] Unknown key "schema" for TypedDict `PlainSerializerFunctionSerSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:168:36 error[invalid-key] Unknown key "schema" for TypedDict `PlainSerializerFunctionSerSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:174:36 error[invalid-key] Unknown key "return_schema" for TypedDict `UnionSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:174:36 error[invalid-key] Unknown key "return_schema" for TypedDict `UnionSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:176:36 error[invalid-key] Unknown key "json_schema_input_schema" for TypedDict `CustomErrorSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:176:36 error[invalid-key] Unknown key "json_schema_input_schema" for TypedDict `CustomErrorSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:180:36 error[invalid-key] Unknown key "return_schema" for TypedDict `BoolSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:180:36 error[invalid-key] Unknown key "return_schema" for TypedDict `BoolSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:180:36 error[invalid-key] Unknown key "return_schema" for TypedDict `MultiHostUrlSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:180:36 error[invalid-key] Unknown key "return_schema" for TypedDict `MultiHostUrlSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:182:36 error[invalid-key] Unknown key "schema" for TypedDict `PlainSerializerFunctionSerSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:182:36 error[invalid-key] Unknown key "schema" for TypedDict `PlainSerializerFunctionSerSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:184:36 error[invalid-key] Unknown key "json_schema_input_schema" for TypedDict `SimpleSerSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:184:36 error[invalid-key] Unknown key "json_schema_input_schema" for TypedDict `SimpleSerSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:184:36 error[invalid-key] Unknown key "json_schema_input_schema" for TypedDict `TypedDictSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:184:36 error[invalid-key] Unknown key "json_schema_input_schema" for TypedDict `TypedDictSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/_internal/_schema_gather.py:190:32 error[invalid-key] Unknown key "serialization" for TypedDict `SimpleSerSchema` (subscripted object has type `InvalidSchema | AnySchema | NoneSchema | ... omitted 56 union elements`)
+ pydantic/_internal/_schema_gather.py:190:32 error[invalid-key] Unknown key "serialization" for TypedDict `SimpleSerSchema` (subscripted object has type `CoreSchema | SerSchema | ComputedField`)
- pydantic/v1/env_settings.py:223:29 error[invalid-argument-type] Argument to constructor `Path.__new__` is incorrect: Expected `str | PathLike[str]`, found `str | PathLike[Unknown] | (list[str | PathLike[Unknown]] & PathLike[object]) | (tuple[str | PathLike[Unknown], ...] & PathLike[object])`
+ pydantic/v1/env_settings.py:223:29 error[invalid-argument-type] Argument to constructor `Path.__new__` is incorrect: Expected `_typeshed.StrPath`, found `pydantic.v1.typing.StrPath | str | PathLike[Unknown] | (list[pydantic.v1.typing.StrPath] & PathLike[object]) | (tuple[pydantic.v1.typing.StrPath, ...] & PathLike[object])`
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/model_selection/tests/test_validation.py:2094:5 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["error_score"]` and value of type `Literal["raise"]` on object of type `dict[str, FailingClassifier | ndarray[tuple[int], dtype[signedinteger[_64Bit]]] | None | dict[Unknown, Unknown] | int]`
+ sklearn/model_selection/tests/test_validation.py:2094:5 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["error_score"]` and value of type `Literal["raise"]` on object of type `dict[str, FailingClassifier | ndarray[tuple[int], dtype[signedinteger[_NBitIntP]]] | None | dict[Unknown, Unknown] | int]`
scipy (https://github.com/scipy/scipy)
- scipy/optimize/tests/test_differentiable_functions.py:691:49 error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array`
+ scipy/optimize/tests/test_differentiable_functions.py:691:49 error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_NumericArrayLike`, found `Unknown | csr_array`
scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/signal/test_filter_design.pyi:282:1 error[type-assertion-failure] Type `tuple[int, float64]` does not match asserted type `tuple[int, floating[_128Bit]]`
+ tests/signal/test_filter_design.pyi:282:1 error[type-assertion-failure] Type `tuple[int, float64]` does not match asserted type `tuple[int, floating[_NBitLongDouble]]`
scrapy (https://github.com/scrapy/scrapy)
- tests/test_downloadermiddleware_cookies.py:363:46 error[invalid-argument-type] Argument to `Request.__init__` is incorrect: Expected `dict[str, str] | list[VerboseCookie] | None`, found `dict[str, str | bytes]`
+ tests/test_downloadermiddleware_cookies.py:363:46 error[invalid-argument-type] Argument to `Request.__init__` is incorrect: Expected `CookiesT | None`, found `dict[str, bytes]`
- tests/test_http_request_form.py:44:75 error[invalid-argument-type] Argument to `FormRequest.__init__` is incorrect: Expected `dict[str, Iterable[str]] | list[tuple[str, Iterable[str]]] | None`, found `tuple[tuple[Literal["a"], Literal["one"]], tuple[Literal["a"], Literal["two"]], tuple[Literal["b"], Literal["2"]]]`
+ tests/test_http_request_form.py:44:75 error[invalid-argument-type] Argument to `FormRequest.__init__` is incorrect: Expected `FormdataType`, found `tuple[tuple[Literal["a"], Literal["one"]], tuple[Literal["a"], Literal["two"]], tuple[Literal["b"], Literal["2"]]]`
spack (https://github.com/spack/spack)
- lib/spack/spack/llnl/util/filesystem.py:168:5 error[invalid-assignment] Object of type `def copystat(src, dst, follow_symlinks=True) -> Unknown` is not assignable to attribute `copystat` of type `def copystat(src: str | bytes | PathLike[str] | PathLike[bytes], dst: str | bytes | PathLike[str] | PathLike[bytes], *, follow_symlinks: bool = True) -> None`
+ lib/spack/spack/llnl/util/filesystem.py:168:5 error[invalid-assignment] Object of type `def copystat(src, dst, follow_symlinks=True) -> Unknown` is not assignable to attribute `copystat` of type `def copystat(src: StrOrBytesPath, dst: StrOrBytesPath, *, follow_symlinks: bool = True) -> None`
- lib/spack/spack/test/directory_layout.py:135:70 error[invalid-argument-type] Argument to bound method `Spec.copy` is incorrect: Expected `int | str | list[str] | tuple[str, ...]`, found `SpecHashDescriptor`
+ lib/spack/spack/test/directory_layout.py:135:70 error[invalid-argument-type] Argument to bound method `Spec.copy` is incorrect: Expected `int | DepTypes`, found `SpecHashDescriptor`
- lib/spack/spack/test/stage.py:868:35 error[invalid-argument-type] Argument to function `exists` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `Unknown | None`
+ lib/spack/spack/test/stage.py:868:35 error[invalid-argument-type] Argument to function `exists` is incorrect: Expected `FileDescriptorOrPath`, found `Unknown | None`
static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/container_util.py:1773:20 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Hashable, (index: slice[int | None, int | None, int | None], /) -> Sequence[Hashable]]` cannot be called with key of type `list[int]` on object of type `Sequence[Hashable]`
+ static_frame/core/container_util.py:1773:20 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> TLabel, (index: slice[int | None, int | None, int | None], /) -> Sequence[TLabel]]` cannot be called with key of type `list[int]` on object of type `Sequence[TLabel]`
- static_frame/core/index.py:484:62 error[unresolved-attribute] Attribute `step` is not defined on `Iterable[Hashable] & ~IndexBase & ~ContainerOperand & ~str`, `Iterator[Hashable] & ~str`, `ndarray[Any, Any] & ~str` in union `(Iterable[Hashable] & ~IndexBase & ~ContainerOperand & ~str) | (Unknown & ~str) | (Iterator[Hashable] & ~str) | (ndarray[Any, Any] & ~str)`
+ static_frame/core/index.py:484:62 error[unresolved-attribute] Attribute `step` is not defined on `Iterable[TLabel] & ~IndexBase & ~ContainerOperand & ~str`, `Iterator[TLabel] & ~str`, `ndarray[Any, Any] & ~str` in union `(Iterable[TLabel] & ~IndexBase & ~ContainerOperand & ~str) | (Unknown & ~str) | (Iterator[TLabel] & ~str) | (ndarray[Any, Any] & ~str)`
- static_frame/core/yarn.py:211:39 error[invalid-assignment] Object of type `list[partial[Unknown] | <class 'IndexAutoConstructorFactory'>]` is not assignable to `((...) -> IndexBase) | type[Index[Any] | IndexAutoConstructorFactory] | None | Iterable[((...) -> IndexBase) | type[Index[Any]] | None]`
+ static_frame/core/yarn.py:211:39 error[invalid-assignment] Object of type `list[partial[Unknown] | <class 'IndexAutoConstructorFactory'>]` is not assignable to `TIndexCtorSpecifiers`
- static_frame/test/unit/test_batch.py:171:40 error[invalid-argument-type] Argument to `Batch.__init__` is incorrect: Expected `Iterator[tuple[Hashable, Frame | Series[Any, Any]]]`, found `IterNodeDelegateReducible[@Todo]`
+ static_frame/test/unit/test_batch.py:171:40 error[invalid-argument-type] Argument to `Batch.__init__` is incorrect: Expected `Iterator[tuple[TLabel, TFrameOrSeries]]`, found `IterNodeDelegateReducible[@Todo]`
- static_frame/test/unit/test_frame.py:9550:13 error[invalid-argument-type] Argument to bound method `Frame.from_delimited` is incorrect: Expected `str | PathLike[Any] | Iterator[str]`, found `list[LiteralString]`
+ static_frame/test/unit/test_frame.py:9550:13 error[invalid-argument-type] Argument to bound method `Frame.from_delimited` is incorrect: Expected `TPathSpecifierOrTextIOOrIterator`, found `list[LiteralString]`
- static_frame/test/unit/test_frame.py:9741:13 error[invalid-argument-type] Argument to bound method `Frame.from_delimited` is incorrect: Expected `str | PathLike[Any] | Iterator[str]`, found `list[LiteralString]`
+ static_frame/test/unit/test_frame.py:9741:13 error[invalid-argument-type] Argument to bound method `Frame.from_delimited` is incorrect: Expected `TPathSpecifierOrTextIOOrIterator`, found `list[LiteralString]`
- static_frame/test/unit/test_frame.py:22218:30 error[invalid-argument-type] Argument to bound method `Frame.rank_ordinal` is incorrect: Expected `bool | Sequence[bool]`, found `GeneratorType[Unknown, None, None]`
+ static_frame/test/unit/test_frame.py:22218:30 error[invalid-argument-type] Argument to bound method `Frame.rank_ordinal` is incorrect: Expected `TBoolOrBools`, found `GeneratorType[Unknown, None, None]`
- static_frame/test/unit/test_store.py:180:17 error[invalid-argument-type] Argument is incorrect: Expected `((...) -> IndexBase) | type[Index[Any] | IndexAutoConstructorFactory] | None | Iterable[((...) -> IndexBase) | type[Index[Any]] | None]`, found `int`
+ static_frame/test/unit/test_store.py:180:17 error[invalid-argument-type] Argument is incorrect: Expected `((TLabel, @Todo, /) -> @Todo) | None`, found `int`
- static_frame/test/unit/test_type_clinic.py:1966:39 error[invalid-argument-type] Argument to `LabelsOrder.__init__` is incorrect: Expected `Sequence[Hashable]`, found `EllipsisType`
+ static_frame/test/unit/test_type_clinic.py:1966:39 error[invalid-argument-type] Argument to `LabelsOrder.__init__` is incorrect: Expected `Sequence[TLabel]`, found `EllipsisType`
sympy (https://github.com/sympy/sympy)
- sympy/functions/elementary/tests/test_piecewise.py:215:25 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, Literal[-2], Literal[2]]`
+ sympy/functions/elementary/tests/test_piecewise.py:215:25 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, Literal[-2], Literal[2]]`
- sympy/geometry/tests/test_polygon.py:549:61 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, Literal[0], Literal[4]]`
+ sympy/geometry/tests/test_polygon.py:549:61 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, Literal[0], Literal[4]]`
- sympy/integrals/integrals.py:1198:40 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `Tuple`
+ sympy/integrals/integrals.py:1198:40 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `Tuple`
- sympy/integrals/tests/test_failing_integrals.py:55:45 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Symbol, Literal[0], Literal[1]]`
+ sympy/integrals/tests/test_failing_integrals.py:55:45 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Symbol, Literal[0], Literal[1]]`
- sympy/integrals/tests/test_integrals.py:1475:30 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, Literal[-1], Literal[1]]`
+ sympy/integrals/tests/test_integrals.py:1475:30 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, Literal[-1], Literal[1]]`
- sympy/integrals/tests/test_integrals.py:1669:40 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Symbol, Literal[0], Unknown]`
+ sympy/integrals/tests/test_integrals.py:1669:40 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Symbol, Literal[0], Unknown]`
- sympy/integrals/tests/test_integrals.py:1811:42 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, Literal[0], Infinity]`
+ sympy/integrals/tests/test_integrals.py:1811:42 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, Literal[0], Infinity]`
- sympy/integrals/tests/test_integrals.py:2087:29 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, int | float, Literal[1]]`
+ sympy/integrals/tests/test_integrals.py:2087:29 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, int | float, Literal[1]]`
- sympy/integrals/tests/test_integrals.py:2203:39 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, Literal[0], Any]`
+ sympy/integrals/tests/test_integrals.py:2203:39 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, Literal[0], Any]`
- sympy/printing/mathml.py:888:26 error[invalid-argument-type] Argument to bound method `Element.appendChild` is incorrect: Argument type `str` does not satisfy upper bound `Element | ProcessingInstruction | Comment | Text | DocumentFragment` of type variable `_ElementChildrenPlusFragment`
+ sympy/printing/mathml.py:888:26 error[invalid-argument-type] Argument to bound method `Element.appendChild` is incorrect: Argument type `str` does not satisfy upper bound `_ElementChildren | DocumentFragment` of type variable `_ElementChildrenPlusFragment`
- sympy/printing/mathml.py:1387:31 error[invalid-argument-type] Argument to bound method `Element.appendChild` is incorrect: Argument type `str` does not satisfy upper bound `Element | ProcessingInstruction | Comment | Text | DocumentFragment` of type variable `_ElementChildrenPlusFragment`
+ sympy/printing/mathml.py:1387:31 error[invalid-argument-type] Argument to bound method `Element.appendChild` is incorrect: Argument type `str` does not satisfy upper bound `_ElementChildren | DocumentFragment` of type variable `_ElementChildrenPlusFragment`
- sympy/printing/mathml.py:2105:23 error[invalid-argument-type] Argument to bound method `Element.appendChild` is incorrect: Argument type `str` does not satisfy upper bound `Element | ProcessingInstruction | Comment | Text | DocumentFragment` of type variable `_ElementChildrenPlusFragment`
+ sympy/printing/mathml.py:2105:23 error[invalid-argument-type] Argument to bound method `Element.appendChild` is incorrect: Argument type `str` does not satisfy upper bound `_ElementChildren | DocumentFragment` of type variable `_ElementChildrenPlusFragment`
- sympy/utilities/tests/test_wester.py:2463:41 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, Literal[0], Literal[1]]`
+ sympy/utilities/tests/test_wester.py:2463:41 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, Literal[0], Literal[1]]`
- sympy/utilities/tests/test_wester.py:2470:41 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `Expr | tuple[Expr, Expr] | tuple[Expr, Expr, Expr]`, found `tuple[Any, Literal[1], Literal[2]]`
+ sympy/utilities/tests/test_wester.py:2470:41 error[invalid-argument-type] Argument to function `integrate` is incorrect: Expected `SymbolLimits`, found `tuple[Any, Literal[1], Literal[2]]`
urllib3 (https://github.com/urllib3/urllib3)
- test/test_collections.py:311:22 error[invalid-argument-type] Argument to bound method `HTTPHeaderDict.extend` is incorrect: Expected `Mapping[str, str] | Iterable[tuple[str, str]] | HasGettableStringKeys`, found `int`
+ test/test_collections.py:311:22 error[invalid-argument-type] Argument to bound method `HTTPHeaderDict.extend` is incorrect: Expected `ValidHTTPHeaderSource`, found `int`
- test/test_collections.py:422:28 error[invalid-argument-type] Argument to `HTTPHeaderDict.__init__` is incorrect: Expected `Mapping[str, str] | Iterable[tuple[str, str]] | HasGettableStringKeys | None`, found `dict[int, int]`
+ test/test_collections.py:422:28 error[invalid-argument-type] Argument to `HTTPHeaderDict.__init__` is incorrect: Expected `ValidHTTPHeaderSource | None`, found `dict[int, int]`
- test/with_dummyserver/test_poolmanager.py:793:17 error[invalid-argument-type] Argument to function `request` is incorrect: Expected `bytes | IO[Any] | Iterable[bytes | str] | None`, found `BadBody`
+ test/with_dummyserver/test_poolmanager.py:793:17 error[invalid-argument-type] Argument to function `request` is incorrect: Expected `_TYPE_BODY | None`, found `BadBody`
xarray (https://github.com/pydata/xarray)
- asv_bench/benchmarks/dataset_io.py:411:56 error[invalid-argument-type] Argument to function `open_mfdataset` is incorrect: Expected `str | int | tuple[int, ...] | None | Mapping[Any, str | int | tuple[int, ...] | None]`, found `dict[str, int | float]`
+ asv_bench/benchmarks/dataset_io.py:411:56 error[invalid-argument-type] Argument to function `open_mfdataset` is incorrect: Expected `T_Chunks`, found `dict[str, int | float]`
yarl (https://github.com/aio-libs/yarl)
- tests/test_url_query.py:231:26 error[invalid-argument-type] Argument to bound method `URL.update_query` is incorrect: Expected `None | str | Mapping[str, Sequence[str | SupportsInt] | SupportsInt] | Sequence[tuple[str, Sequence[str | SupportsInt] | SupportsInt]]`, found `memoryview[int]`
+ tests/test_url_query.py:231:26 error[invalid-argument-type] Argument to bound method `URL.update_query` is incorrect: Expected `Query`, found `memoryview[int]`
zulip (https://github.com/zulip/zulip)
+ analytics/migrations/0001_initial.py:206:13 error[invalid-argument-type] Argument to `AlterUniqueTogether.__init__` is incorrect: Expected `_OptionTogetherT | None`, found `set[tuple[str, str, str, str]]`
+ zerver/migrations/0051_realmalias_add_allow_subdomains.py:18:13 error[invalid-argument-type] Argument to `AlterUniqueTogether.__init__` is incorrect: Expected `_OptionTogetherT | None`, found `set[tuple[str, str]]`
+ zerver/migrations/0113_default_stream_group.py:34:13 error[invalid-argument-type] Argument to `AlterUniqueTogether.__init__` is incorrect: Expected `_OptionTogetherT | None`, found `set[tuple[str, str]]`
Merging this PR will degrade performance by 9.58%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| 🆕 | Simulation | ty_micro[recursive_union_type_alias_and_protocol] |
N/A | 74.3 ms | N/A |
| ⚡ | Simulation | ty_micro[typevar_mapping_accumulation] |
370.3 ms | 316.9 ms | +16.84% |
| ❌ | Simulation | ty_micro[large_union_narrowing] |
531 ms | 587.3 ms | -9.58% |
| ⚡ | WallTime | pandas |
62.2 s | 59.5 s | +4.61% |
| ⚡ | WallTime | altair |
5.1 s | 4.6 s | +9.18% |
| 🆕 | Memory | ty_micro[recursive_union_type_alias_and_protocol] |
N/A | 16.4 MB | N/A |
| ⚡ | WallTime | multithreaded |
1.3 s | 1 s | +19.93% |
| ⚡ | WallTime | pydantic |
7.8 s | 6.9 s | +13.14% |
| ⚡ | WallTime | colour_science |
42.8 s | 36.1 s | +18.85% |
| ⚡ | Simulation | hydra-zen |
1.2 s | 1 s | +13.1% |
Comparing mtshiba:implicit-recursive-union (8127108) with main (ea4b406)
|
The codspeed (walltime) results seem to have improved in some cases and worsened in others. |
|
mypy and pyright seem to expand type aliases as much as possible, regardless of whether they are implicit or PEP-695 style (in the case of recursive type aliases, mypy seems to omit the recursive part and display it such as |
carljm
left a comment
There was a problem hiding this comment.
Reviewed the test changes here and most of the code changes. Overall this looks really good! Need to look more closely at the union-type changes, and the ecosystem impact. This will likely uncover more cases where we aren't handling Type::TypeAlias correctly, since implicit type aliases are much more used than PEP 695 ones today.
carljm
left a comment
There was a problem hiding this comment.
Thanks again for working on this, and sorry about the delay to complete my review. Lots of good stuff here, but I think we can do better than all the repeat inference we do in this PR.
Looking at the ecosystem report, the new aioredis diagnostics are false positives and a regression. It looks like we aren't resolving up the new implicit type alias type there in the generics constraint solver, so the constraint solver can't match to the formal parameter and infer typevars. I'm guessing this is a simple change to fix? (It may even be a pre-existing bug that would also show up if the same code used PEP 695 type alias, not sure.)
| // Convert eager union instances to lazy for assignments | ||
| // This enables lazy evaluation for recursive type aliases like `Foo = int | list["Foo"]` | ||
| let value_ty = if let Some(instance) = value_ty.as_union_type_instance() | ||
| && let Some(eager) = instance.as_eager(self.db()) |
There was a problem hiding this comment.
So at this point we have already created an eager UnionTypeInstance, which means we've already inferred all its elements as both value and type expressions. Then, if it's convertible to lazy, we throw all of that away and store just the definition.
I wonder a) why we need to be so eager about creating the union_type that we do it before we check if we can convert to lazy, and b) why we throw away the value types rather than storing them in the lazy variant too.
I realize that typing.Union would need to be handled differently since there we never infer elements as value expressions. But in that case it seems like we have more control (we already know it's a union before inferring any element types) -- I think we could have special handling in the assignment inference for a top-level typing.Union subscripting, where we create a lazy union instance and don't infer any of the elements at all until we need them (using the existing infer_deferred_types mechanism that is already used for elements of TypeVar etc.)
| DefinitionKind::AnnotatedAssignment(assignment) => assignment.value(&module).unwrap(), | ||
| _ => unreachable!(), | ||
| }; | ||
| let value_expression = Expression::new( |
There was a problem hiding this comment.
This means we re-infer the expression type again, potentially twice. Why do we need to do this, when we already inferred its value types in type inference? Why can't the lazy UnionTypeInstance variant, and the implicit TypeAliasType variant, both store the value types we originally inferred?
(I realize this means typing.Union would need a different path; discussed that in a different comment.)
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
trio
sphinx
prefect
|
…union # Conflicts: # crates/ruff_benchmark/benches/ty.rs # crates/ty_python_semantic/resources/mdtest/narrow/isinstance.md # crates/ty_python_semantic/resources/mdtest/snapshots/isinstance.md_-_Narrowing_for_`isins…_-_`classinfo`_is_an_in…_(eeef56c0ef87a30b).snap # crates/ty_python_semantic/resources/mdtest/snapshots/issubclass.md_-_Narrowing_for_`issub…_-_`classinfo`_is_an_in…_(7bb66a0f412caac1).snap # crates/ty_python_semantic/src/types/known_instance.rs # crates/ty_python_semantic/src/types/type_alias.rs # crates/ty_server/tests/e2e/snapshots/e2e__signature_help__works_in_function_name.snap
astral-sh#24773 (CycleDetector improvement) preserves alias names through the recursive cycle path instead of falling back to `Type::any()`. This both: - restores the alias-name view in `Node.Child` / `JsonValue` recursive examples (no more `Any` leakage), and - shortens fixpoint iteration for `infer_implicit_assignment_value_type` in deeply recursive cases, fixing the CI timeout on `external/pydantic.md` and `external/sqlmodel.md`. mdtest assertions for `implicit_type_aliases.md` updated to match the improved alias-name preservation.
This reverts commit e0b173f.
Summary
Part of astral-sh/ty#1738
This PR allows implicit (or PEP-613) union type aliases to be self-referential.
To achieve this, two new Rust structs are added:
LazyUnionTypeInstanceandImplicitTypeAliasType.As a result, the previous
UnionTypeInstanceis now calledEagerUnionTypeInstance. Also, anImplicit(ImplicitTypeAliasType)variant is added toTypeAliasType.First, a union type instance is created as
EagerUnionTypeInstance. Then, when registering a binding, it is checked whether it can be promoted toLazyUnionTypeInstance. The promotion criteria include whether it is a valid union type and whether it is a non-generic type (this should be relaxed in the future, but is marked as TODO for this PR).LazyUnionTypeInstanceis converted toImplicitTypeAliasTypein a type context.ImplicitTypeAliasTypebehaves almost identically to PEP-695 type alias (except that it doesn't have a generic context yet).There are other
KnownInstances that can be converted toImplicitTypeAliasTypein a type context, but in this PR we will focus on union type instances.Also, this change means that implicit type aliases are now shown with their name rather than their expanded type.
This is preferable, assuming there is reasonable intent behind the naming of type aliases.
Fixes astral-sh/ty#1883 (with #22241)
Fixes astral-sh/ty#1998
Performance analysis
#22238 (comment)
Ecosystem analysis
The new false positive errors appears to be due to astral-sh/ty#2015. Type aliases should basically behave the same as value types, but as in astral-sh/ty#2015, inconsistencies in behavior have been observed in implementations, which may also affect performance.
Test Plan
New corpus test
mdtest updated