[ty] Restrict length narrowing to types that encode their length#25840
Conversation
Typing conformance resultsThe percentage of diagnostics emitted that were expected errors held steady at 94.36%. The percentage of expected errors that received a diagnostic held steady at 88.82%. The number of fully passing files held steady at 93/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 (
True positives changed (3)3 diagnostics
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
trio
sphinx
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
29 | 1 | 30 |
unresolved-attribute |
35 | 0 | 16 |
not-subscriptable |
39 | 5 | 3 |
invalid-assignment |
14 | 0 | 1 |
unsupported-operator |
1 | 0 | 8 |
not-iterable |
3 | 0 | 1 |
invalid-return-type |
0 | 0 | 2 |
redundant-cast |
2 | 0 | 0 |
unused-type-ignore-comment |
0 | 2 | 0 |
invalid-method-override |
1 | 0 | 0 |
| Total | 124 | 8 | 61 |
Raw diff (193 changes)
Expression (https://github.com/cognitedata/Expression)
- tests/test_array.py:102:44 error[invalid-argument-type] Argument to function `pipe` is incorrect: Expected `(TypedArray[int16] & ExactlySized[Literal[3]], /) -> (TypedArray[int16] & ExactlySized[Literal[3]]) | _A'return@curry_flip`, found `(_A'return@curry_flip, /) -> _A'return@curry_flip`
+ tests/test_array.py:102:44 error[invalid-argument-type] Argument to function `pipe` is incorrect: Expected `(TypedArray[int16], /) -> TypedArray[int16] | _A'return@curry_flip`, found `(_A'return@curry_flip, /) -> _A'return@curry_flip`
alerta (https://github.com/alerta/alerta)
+ alerta/utils/api.py:139:39 error[not-iterable] Object of type `None` is not iterable
apprise (https://github.com/caronc/apprise)
+ tests/test_api.py:198:18 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[str]`
+ tests/test_api.py:210:18 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `tuple[Literal["ntfys://user:pass@host/test"], Literal["json://localhost"]]`
+ tests/test_api.py:214:18 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `set[str]`
+ tests/test_api.py:237:18 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `AppriseAsset | None`, found `str`
+ tests/test_api.py:259:13 error[invalid-method-override] Invalid override of method `send`: Definition is incompatible with `NotifyBase.send`
+ tests/test_api.py:505:22 error[invalid-argument-type] Argument to `AppriseAsset.__init__` is incorrect: Expected `str | bytes | None`, found `Literal[42]`
+ tests/test_api.py:521:16 error[unresolved-attribute] Attribute `url_id` is not defined on `None` in union `NotifyBase | None`
+ tests/test_api.py:524:28 error[invalid-argument-type] Argument to function `Apprise.instantiate` is incorrect: Expected `str | dict[Unknown, Unknown]`, found `<class 'object'>`
+ tests/test_apprise_attachments.py:113:19 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `tuple[str, str, AttachBase | None]`
+ tests/test_apprise_attachments.py:158:28 error[invalid-argument-type] Argument to `AppriseAttachment.__init__` is incorrect: Expected `str | list[str | AttachBase | AppriseAttachment] | None`, found `tuple[str, str, AttachBase | None]`
+ tests/test_apprise_attachments.py:169:9 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `AttachBase | None`
+ tests/test_apprise_attachments.py:174:9 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `AttachBase | None`
+ tests/test_apprise_attachments.py:182:9 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `AttachBase | None`
+ tests/test_apprise_attachments.py:194:9 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `AttachBase | None`
+ tests/test_apprise_attachments.py:201:9 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `AttachBase | None`
+ tests/test_apprise_attachments.py:202:51 error[invalid-argument-type] Argument to function `AppriseAttachment.instantiate` is incorrect: Expected `int | None`, found `Literal["invalid"]`
+ tests/test_apprise_attachments.py:213:19 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `None`
+ tests/test_apprise_attachments.py:214:19 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `object`
+ tests/test_apprise_attachments.py:215:19 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `Literal[42]`
+ tests/test_apprise_attachments.py:229:19 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `tuple[None, object, Literal[42], Literal["garbage://"]]`
+ tests/test_apprise_attachments.py:247:12 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `tuple[None, object, Literal[42], Literal["garbage://"]]`
+ tests/test_apprise_attachments.py:258:12 error[invalid-argument-type] Argument to bound method `AppriseAttachment.add` is incorrect: Expected `str | AttachBase | AppriseAttachment | list[str | AttachBase | AppriseAttachment]`, found `tuple[None, object, Literal[42], Literal["garbage://"]]`
+ tests/test_apprise_cli.py:2397:13 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/test_apprise_cli.py:2400:19 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/test_apprise_config.py:623:18 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `object`
+ tests/test_apprise_config.py:624:18 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object]`
- tests/test_apprise_config.py:1323:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `ExactlySized[Literal[2]]`
+ tests/test_apprise_config.py:1323:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `object`
- tests/test_apprise_config.py:1325:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected], [email protected] \t"]` and `ExactlySized[Literal[2]]`
+ tests/test_apprise_config.py:1325:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected], [email protected] \t"]` and `object`
- tests/test_apprise_config.py:1359:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `ExactlySized[Literal[3]]`
+ tests/test_apprise_config.py:1359:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `object`
- tests/test_apprise_config.py:1360:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `ExactlySized[Literal[3]]`
+ tests/test_apprise_config.py:1360:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `object`
- tests/test_apprise_config.py:1361:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `ExactlySized[Literal[3]]`
+ tests/test_apprise_config.py:1361:12 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["[email protected]"]` and `object`
+ tests/test_apprise_utils.py:2740:9 error[not-subscriptable] Cannot delete subscript on object of type `None` with no `__delitem__` method
+ tests/test_apprise_utils.py:2767:9 error[not-subscriptable] Cannot delete subscript on object of type `None` with no `__delitem__` method
+ tests/test_apprise_utils.py:2768:9 error[not-subscriptable] Cannot delete subscript on object of type `None` with no `__delitem__` method
+ tests/test_apprise_utils.py:2792:9 error[not-subscriptable] Cannot delete subscript on object of type `None` with no `__delitem__` method
+ tests/test_apprise_utils.py:2838:9 error[not-subscriptable] Cannot delete subscript on object of type `None` with no `__delitem__` method
+ tests/test_apprise_utils.py:2839:9 error[not-subscriptable] Cannot delete subscript on object of type `None` with no `__delitem__` method
+ tests/test_apprise_utils.py:2840:9 error[not-subscriptable] Cannot delete subscript on object of type `None` with no `__delitem__` method
+ tests/test_attach_file.py:270:12 error[unresolved-attribute] Attribute `download` is not defined on `None` in union `AttachBase | None`
+ tests/test_attach_file.py:272:9 error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `cache` on type `AttachBase | None`
+ tests/test_attach_file.py:274:24 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `AttachBase | None`
- tests/test_config_base.py:522:22 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object] & ExactlySized[Literal[4]]`
+ tests/test_config_base.py:522:22 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object]`
- tests/test_config_base.py:1466:22 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object] & ExactlySized[Literal[4]]`
+ tests/test_config_base.py:1466:22 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object]`
- tests/test_config_base.py:1581:22 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object] & ExactlySized[Literal[4]]`
+ tests/test_config_base.py:1581:22 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object]`
+ tests/test_plugin_africas_talking.py:207:12 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_africas_talking.py:213:26 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_africas_talking.py:231:9 error[unresolved-attribute] Attribute `notify` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_bulksms.py:246:12 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_bulksms.py:254:26 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_bulkvs.py:217:12 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_bulkvs.py:221:26 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_fortysixelks.py:160:12 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_httpsms.py:200:12 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_sms_manager.py:193:12 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_sms_manager.py:199:26 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `NotifyBase | None`
+ tests/test_plugin_sms_manager.py:213:9 error[unresolved-attribute] Attribute `notify` is not defined on `None` in union `NotifyBase | None`
- tests/test_plugin_title_maxlen.py:84:14 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object] & ExactlySized[Literal[2]]`
+ tests/test_plugin_title_maxlen.py:84:14 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object]`
- tests/test_plugin_title_maxlen.py:135:14 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object] & ExactlySized[Literal[2]]`
+ tests/test_plugin_title_maxlen.py:135:14 error[invalid-argument-type] Argument to bound method `Apprise.add` is incorrect: Expected `str | dict[Unknown, Unknown] | NotifyBase | ... omitted 3 union elements`, found `list[object]`
artigraph (https://github.com/artigraph/artigraph)
- src/arti/types/python.py:158:83 error[invalid-argument-type] Argument is incorrect: Expected `frozenset[Any]`, found `tuple[Any, ...] & ~ExactlySized[Literal[0, False]]`
+ src/arti/types/python.py:158:83 error[invalid-argument-type] Argument is incorrect: Expected `frozenset[Any]`, found `tuple[Any, ...]`
beartype (https://github.com/beartype/beartype)
- beartype/_util/hint/pep/proposal/pep484/pep484604union.py:298:45 error[invalid-argument-type] Argument to function `make_hint_pep484_union` is incorrect: Expected `tuple[TypeForm[Any], ...]`, found `(Sequence[TypeForm[Any]] & tuple[object, ...] & ~AlwaysFalsy & ~ExactlySized[Literal[1, True]]) | tuple[TypeForm[Any], ...]`
+ beartype/_util/hint/pep/proposal/pep484/pep484604union.py:298:45 error[invalid-argument-type] Argument to function `make_hint_pep484_union` is incorrect: Expected `tuple[TypeForm[Any], ...]`, found `(Sequence[TypeForm[Any]] & tuple[object, ...] & ~AlwaysFalsy) | tuple[TypeForm[Any], ...]`
colour (https://github.com/colour-science/colour)
- colour/io/uprtek_sekonic.py:421:33 error[invalid-argument-type] Argument to constructor `float.__new__` is incorrect: Expected `str | Buffer | SupportsFloat | SupportsIndex`, found `str | (list[str] & ~ExactlySized[Literal[1, True]])`
+ colour/io/uprtek_sekonic.py:421:33 error[invalid-argument-type] Argument to constructor `float.__new__` is incorrect: Expected `str | Buffer | SupportsFloat | SupportsIndex`, found `str | list[str]`
- colour/io/uprtek_sekonic.py:421:33 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `str | (list[str] & ~ExactlySized[Literal[1, True]])`
+ colour/io/uprtek_sekonic.py:421:33 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `str | list[str]`
dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/_trace/utils_botocore/span_pointers/dynamodb.py:480:25 warning[redundant-cast] Value is already of type `_DynamoDBDeleteRequestWriteRequest`
+ ddtrace/_trace/utils_botocore/span_pointers/dynamodb.py:551:34 warning[redundant-cast] Value is already of type `_DynamoDBTransactUpdateItem`
+ tests/telemetry/test_dependency.py:110:20 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:136:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:145:20 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:146:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:228:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:229:20 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:248:20 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:257:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:269:20 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:282:43 error[not-iterable] Object of type `list[ReachabilityMetadata] | None` may not be iterable
+ tests/telemetry/test_dependency.py:658:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/telemetry/test_dependency.py:674:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/testing/internal/pytest/test_pytest_efd.py:73:16 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
- tests/testing/internal/pytest/test_pytest_efd.py:74:16 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
- tests/testing/internal/pytest/test_pytest_efd.py:75:16 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
+ tests/tracer/runtime/test_metric_collectors.py:111:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/tracer/runtime/test_metric_collectors.py:112:27 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/tracer/test_encoders.py:935:20 error[unresolved-attribute] Object of type `MsgpackEncoderV05 & ExactlySized[Literal[1, True]]` has no attribute `flush`
+ tests/tracer/test_encoders.py:935:20 error[unresolved-attribute] Object of type `MsgpackEncoderV05` has no attribute `flush`
ibis (https://github.com/ibis-project/ibis)
- ibis/backends/polars/__init__.py:299:20 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
- ibis/backends/polars/__init__.py:301:54 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Iterable[str | Path] & ~ExactlySized[Literal[1, True]] & ~str & ~Path) | (Unknown & ~str & ~Path)`
+ ibis/backends/polars/__init__.py:301:54 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Iterable[str | Path] & ~str & ~Path) | (Unknown & ~str & ~Path)`
- ibis/backends/polars/__init__.py:311:39 error[invalid-argument-type] Argument to function `normalize_filename` is incorrect: Expected `str | Path`, found `str | Path | (Iterable[str | Path] & ~ExactlySized[Literal[1, True]]) | Unknown`
+ ibis/backends/polars/__init__.py:311:39 error[invalid-argument-type] Argument to function `normalize_filename` is incorrect: Expected `str | Path`, found `Iterable[str | Path] | Path | Unknown`
jax (https://github.com/google/jax)
- jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:2493:9 error[invalid-argument-type] Argument is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]] | Array | None`, found `(P & ExactlySized[Literal[2]]) | None`
+ jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:2493:9 error[invalid-argument-type] Argument is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]] | Array | None`, found `P | None`
- jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:2494:9 error[invalid-argument-type] Argument is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]] | Array | None`, found `(P & ExactlySized[Literal[2]]) | None`
+ jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:2494:9 error[invalid-argument-type] Argument is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]] | Array | None`, found `P | None`
- jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:2495:9 error[invalid-argument-type] Argument is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]] | Array | None`, found `(P & ExactlySized[Literal[2]]) | None`
+ jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:2495:9 error[invalid-argument-type] Argument is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]] | Array | None`, found `P | None`
meson (https://github.com/mesonbuild/meson)
+ mesonbuild/backend/vs2010backend.py:1246:44 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ mesonbuild/backend/vs2010backend.py:1247:53 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ mesonbuild/backend/vs2010backend.py:1248:16 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `ImmutableListProtocol[str] | None`
+ mesonbuild/backend/vs2010backend.py:1253:49 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ mesonbuild/backend/vs2010backend.py:1254:55 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- mesonbuild/backend/vs2010backend.py:1240:51 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(ImmutableListProtocol[str] & ~ExactlySized[Literal[1, True]]) | None`
+ mesonbuild/backend/vs2010backend.py:1240:51 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `ImmutableListProtocol[str] | None`
mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ test/mitmproxy/test_eventsequence.py:43:16 error[unresolved-attribute] Attribute `messages` is not defined on `None` in union `WebSocketData | None`
+ test/mitmproxy/test_eventsequence.py:45:16 error[unresolved-attribute] Attribute `messages` is not defined on `None` in union `WebSocketData | None`
optuna (https://github.com/optuna/optuna)
- optuna/storages/_rdb/alembic/versions/v3.0.0.a.py:193:34 error[invalid-argument-type] Argument to function `persist` is incorrect: Expected `list[BaseDistribution]`, found `(list[TrialParamModel] & ExactlySized[Literal[5000]]) | (list[Unknown] & ExactlySized[Literal[5000]])`
+ optuna/storages/_rdb/alembic/versions/v3.0.0.a.py:193:34 error[invalid-argument-type] Argument to function `persist` is incorrect: Expected `list[BaseDistribution]`, found `list[TrialParamModel] | list[Unknown]`
+ tests/storages_tests/rdb_tests/test_storage.py:297:30 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/storages_tests/rdb_tests/test_storage.py:298:29 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/study_tests/test_study.py:1522:47 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/study_tests/test_study.py:1528:48 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
packaging (https://github.com/pypa/packaging)
+ src/packaging/version.py:786:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_epoch` of type `int`
+ src/packaging/version.py:787:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_release` of type `tuple[int, ...]`
+ src/packaging/version.py:788:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_pre` of type `tuple[Literal["a", "b", "rc"], int] | None`
+ src/packaging/version.py:789:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_post` of type `tuple[Literal["post"], int] | None`
+ src/packaging/version.py:790:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_dev` of type `tuple[Literal["dev"], int] | None`
+ src/packaging/version.py:791:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_local` of type `tuple[int | str, ...] | None`
pandas (https://github.com/pandas-dev/pandas)
- pandas/core/indexers/utils.py:575:23 error[unresolved-attribute] Attribute `to_numpy` is not defined on `ndarray[tuple[Any, ...], dtype[Unknown]]` in union `(Any & ~tuple[object, ...]) | (ExtensionArray & ~ExactlySized[Literal[0, False]]) | ndarray[tuple[Any, ...], dtype[Unknown]]`
+ pandas/core/indexers/utils.py:575:23 error[unresolved-attribute] Attribute `to_numpy` is not defined on `ndarray[tuple[Any, ...], dtype[Unknown]]` in union `(Any & ~tuple[object, ...]) | ExtensionArray | ndarray[tuple[Any, ...], dtype[Unknown]]`
- pandas/core/indexes/multi.py:599:54 error[invalid-argument-type] Argument to function `tuples_to_object_array` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[object_]]`, found `(Collection[tuple[Hashable, ...]] & ndarray[tuple[object, ...], dtype[object]] & ~ExactlySized[Literal[0, False]] & ~Index) | ndarray[tuple[Any, ...], dtype[Any]]`
+ pandas/core/indexes/multi.py:599:54 error[invalid-argument-type] Argument to function `tuples_to_object_array` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[object_]]`, found `(Collection[tuple[Hashable, ...]] & ndarray[tuple[object, ...], dtype[object]] & ~Index) | ndarray[tuple[Any, ...], dtype[Any]]`
- pandas/core/indexes/multi.py:4789:49 error[invalid-argument-type] Argument to bound method `MultiIndex.from_tuples` is incorrect: Expected `Iterable[tuple[Hashable, ...]]`, found `(Unknown & ~Generator[object, None, None] & ~ExactlySized[Literal[0, False]] & ~MultiIndex) | (list[object] & ~ExactlySized[Literal[0, False]] & ~MultiIndex)`
+ pandas/core/indexes/multi.py:4789:49 error[invalid-argument-type] Argument to bound method `MultiIndex.from_tuples` is incorrect: Expected `Iterable[tuple[Hashable, ...]]`, found `(Unknown & ~Generator[object, None, None] & ~MultiIndex) | (list[object] & ~MultiIndex)`
- pandas/core/indexes/range.py:1066:12 error[unresolved-attribute] Object of type `Index & ~ExactlySized[Literal[0, False]] & ~ExactlySized[Literal[1, True]]` has no attribute `step`
+ pandas/core/indexes/range.py:1066:12 error[unresolved-attribute] Object of type `Index` has no attribute `step`
- pandas/core/indexes/range.py:1073:18 error[unresolved-attribute] Object of type `Index & ~ExactlySized[Literal[0, False]] & ~ExactlySized[Literal[1, True]]` has no attribute `_range`
+ pandas/core/indexes/range.py:1073:18 error[unresolved-attribute] Object of type `Index` has no attribute `_range`
- pandas/core/indexes/range.py:1087:16 error[unresolved-attribute] Object of type `Index & ~ExactlySized[Literal[0, False]] & ~ExactlySized[Literal[1, True]]` has no attribute `step`
+ pandas/core/indexes/range.py:1087:16 error[unresolved-attribute] Object of type `Index` has no attribute `step`
- 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/resample.py:3215:12 error[invalid-return-type] Return type does not match returned value: expected `FreqIndexT@_asfreq_compat`, found `(FreqIndexT@_asfreq_compat & PeriodIndex) | DatetimeIndex | TimedeltaIndex`
- pandas/core/reshape/concat.py:814:29 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Iterable[Series | DataFrame] & ~ExactlySized[Literal[0, False]]) | (Mapping[HashableT@_clean_keys_and_objs, Series | DataFrame] & ~ExactlySized[Literal[0, False]])`
+ pandas/core/reshape/concat.py:814:29 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Iterable[Series | DataFrame] | Mapping[HashableT@_clean_keys_and_objs, Series | DataFrame]`
- pandas/core/reshape/concat.py:818:66 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Iterable[Series | DataFrame] & ~ExactlySized[Literal[0, False]]) | (Mapping[HashableT@_clean_keys_and_objs, Series | DataFrame] & ~ExactlySized[Literal[0, False]])`
+ pandas/core/reshape/concat.py:818:66 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Iterable[Series | DataFrame] | Mapping[HashableT@_clean_keys_and_objs, Series | DataFrame]`
- pandas/core/reshape/merge.py:1936:16 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Hashable & ~None) | (Unknown & ~ExactlySized[Literal[0, False]]) | None`
+ pandas/core/reshape/merge.py:1936:16 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Hashable & ~None) | Unknown | None`
- pandas/core/reshape/merge.py:1936:33 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Hashable & ~None) | (Unknown & ~ExactlySized[Literal[0, False]]) | None`
+ pandas/core/reshape/merge.py:1936:33 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Hashable & ~None) | Unknown | None`
+ pandas/plotting/_matplotlib/boxplot.py:338:14 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ pandas/tests/frame/constructors/test_from_records.py:295:16 error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal["index"]` and `tuple[str, str] | None`
- pandas/tests/indexes/datetimes/test_setops.py:368:16 error[unresolved-attribute] Object of type `Index & ExactlySized[Literal[0, False]]` has no attribute `freq`
+ pandas/tests/indexes/datetimes/test_setops.py:368:16 error[unresolved-attribute] Object of type `Index` has no attribute `freq`
pip (https://github.com/pypa/pip)
+ src/pip/_vendor/packaging/version.py:787:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_epoch` of type `int`
+ src/pip/_vendor/packaging/version.py:788:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_release` of type `tuple[int, ...]`
+ src/pip/_vendor/packaging/version.py:789:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_pre` of type `tuple[Literal["a", "b", "rc"], int] | None`
+ src/pip/_vendor/packaging/version.py:790:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_post` of type `tuple[Literal["post"], int] | None`
+ src/pip/_vendor/packaging/version.py:791:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_dev` of type `tuple[Literal["dev"], int] | None`
+ src/pip/_vendor/packaging/version.py:792:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_local` of type `tuple[int | str, ...] | None`
ppb-vector (https://github.com/ppb/ppb-vector)
+ ppb_vector/__init__.py:189:26 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> SupportsFloat, (index: slice[int | None, int | None, int | None], /) -> Sequence[SupportsFloat]]` cannot be called with key of type `Literal["x"]` on object of type `Sequence[SupportsFloat]`
+ ppb_vector/__init__.py:189:26 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[Mapping[Unknown, object]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["x"]` on object of type `Top[Mapping[Unknown, object]]`
+ ppb_vector/__init__.py:189:45 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> SupportsFloat, (index: slice[int | None, int | None, int | None], /) -> Sequence[SupportsFloat]]` cannot be called with key of type `Literal["y"]` on object of type `Sequence[SupportsFloat]`
+ ppb_vector/__init__.py:189:45 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[Mapping[Unknown, object]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["y"]` on object of type `Top[Mapping[Unknown, object]]`
prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-aws/tests/test_s3.py:932:16 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
+ src/integrations/prefect-dbt/tests/core/test_cloud_executor.py:269:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ src/integrations/prefect-dbt/tests/core/test_cloud_executor.py:270:16 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- src/integrations/prefect-gcp/prefect_gcp/cloud_storage.py:2051:21 error[not-iterable] Object of type `(list[Unknown] & ~ExactlySized[Literal[0, False]]) | (Coroutine[Any, Any, list[Unknown]] & ~ExactlySized[Literal[0, False]])` may not be iterable
+ src/integrations/prefect-gcp/prefect_gcp/cloud_storage.py:2051:21 error[not-iterable] Object of type `list[Unknown] | Coroutine[Any, Any, list[Unknown]]` may not be iterable
+ src/integrations/prefect-sqlalchemy/tests/test_database.py:529:20 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `dict[str, CursorResult[Unknown]] | None`
pytest (https://github.com/pytest-dev/pytest)
+ testing/test_stash.py:59:9 error[invalid-assignment] Object of type `Literal["nope"]` is not assignable to attribute `foo` on type `Stash & ~AlwaysTruthy & ~AlwaysFalsy`
rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/aggregator.py:761:37 error[invalid-argument-type] Argument to bound method `ChainsAggregator.query_eth_balances` is incorrect: Expected `Sequence[ChecksumAddress]`, found `(tuple[BTCAddress, ...] & ~ExactlySized[Literal[0, False]]) | (tuple[ChecksumAddress, ...] & ~ExactlySized[Literal[0, False]]) | (tuple[SubstrateAddress, ...] & ~ExactlySized[Literal[0, False]]) | ... omitted 5 union elements`
+ rotkehlchen/chain/aggregator.py:761:37 error[invalid-argument-type] Argument to bound method `ChainsAggregator.query_eth_balances` is incorrect: Expected `Sequence[ChecksumAddress]`, found `tuple[BTCAddress, ...] | tuple[ChecksumAddress, ...] | tuple[SubstrateAddress, ...] | ... omitted 5 union elements`
+ rotkehlchen/tests/external_apis/test_yearn.py:105:12 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ rotkehlchen/tests/external_apis/test_yearn.py:116:12 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ rotkehlchen/tests/unit/decoders/test_beefy_finance.py:1241:9 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/datasets/_samples_generator.py:876:39 error[not-iterable] Object of type `Literal[100]` is not iterable
scipy (https://github.com/scipy/scipy)
+ scipy/sparse/_base.py:101:20 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
scrapy (https://github.com/scrapy/scrapy)
+ tests/test_pqueues.py:34:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:35:16 error[unresolved-attribute] Attribute `priority` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:69:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:70:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:72:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:73:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:75:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:76:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:95:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:96:16 error[unresolved-attribute] Attribute `priority` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:123:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:125:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:127:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:152:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:153:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:155:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:156:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:158:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
+ tests/test_pqueues.py:159:16 error[unresolved-attribute] Attribute `url` is not defined on `None` in union `Request | None`
setuptools (https://github.com/pypa/setuptools)
- setuptools/_vendor/packaging/version.py:268:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[Literal["a", "b", "rc"], int] | None`, found `tuple[object, ...] & ExactlySized[Literal[2]]`
+ setuptools/_vendor/packaging/version.py:268:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[Literal["a", "b", "rc"], int] | None`, found `tuple[object, object]`
spack (https://github.com/spack/spack)
- lib/spack/spack/graph.py:132:31 error[unsupported-operator] Operator `in` is not supported between objects of type `Unknown & ExactlySized[Literal[1, True]]` and `None | list[list[Unknown]]`
+ lib/spack/spack/graph.py:132:31 error[unsupported-operator] Operator `in` is not supported between objects of type `Unknown` and `None | list[list[Unknown]]`
+ lib/spack/spack/test/cmd/uninstall.py:126:36 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ lib/spack/spack/test/cmd/uninstall.py:129:36 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ lib/spack/spack/test/cmd/uninstall.py:132:36 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ lib/spack/spack/test/cmd/uninstall.py:135:36 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
sympy (https://github.com/sympy/sympy)
- sympy/integrals/heurisch.py:200:22 error[invalid-argument-type] Argument to bound method `list.append` is incorrect: Expected `tuple[Unknown, Boolean]`, found `tuple[Unknown, Literal[True]]`
- sympy/matrices/tests/test_eigen.py:201:12 error[unresolved-attribute] Object of type `dict[Expr, int] & ExactlySized[Literal[3]]` has no attribute `count`
+ sympy/matrices/tests/test_eigen.py:201:12 error[unresolved-attribute] Object of type `dict[Expr, int]` has no attribute `count`
- sympy/matrices/tests/test_eigen.py:202:12 error[unresolved-attribute] Object of type `dict[Expr, int] & ExactlySized[Literal[3]]` has no attribute `count`
+ sympy/matrices/tests/test_eigen.py:202:12 error[unresolved-attribute] Object of type `dict[Expr, int]` has no attribute `count`
- sympy/polys/tests/test_polymatrix.py:60:17 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `MutablePolyDenseMatrix & ExactlySized[Literal[2]]`
+ sympy/polys/tests/test_polymatrix.py:60:17 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `MutablePolyDenseMatrix`
- sympy/polys/tests/test_polymatrix.py:70:17 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `MutablePolyDenseMatrix & ExactlySized[Literal[2]]`
+ sympy/polys/tests/test_polymatrix.py:70:17 error[invalid-argument-type] Argument to `list.__init__` is incorrect: Expected `Iterable[Unknown]`, found `MutablePolyDenseMatrix`
- sympy/sets/sets.py:2514:17 error[unresolved-attribute] Attribute `args` is not defined on `dict[Any, Any] & ExactlySized[Literal[1, True]] & ~AlwaysFalsy` in union `(Any & ExactlySized[Literal[1, True]] & ~AlwaysFalsy) | (dict[Any, Any] & ExactlySized[Literal[1, True]] & ~AlwaysFalsy)`
+ sympy/sets/sets.py:2514:17 error[unresolved-attribute] Attribute `args` is not defined on `dict[Any, Any] & ~AlwaysFalsy` in union `(Any & ~AlwaysFalsy) | (dict[Any, Any] & ~AlwaysFalsy)`
- sympy/solvers/decompogen.py:74:16 error[unsupported-operator] Operator `+` is not supported between objects of type `list[Unknown]` and `None | Unknown | list[Unknown]`
+ sympy/solvers/decompogen.py:74:16 error[unsupported-operator] Operator `+` is not supported between objects of type `list[Unknown]` and `None | Unknown`
- sympy/stats/stochastic_process_types.py:668:26 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Union & ~ExactlySized[Literal[1, True]]`
+ sympy/stats/stochastic_process_types.py:668:26 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Union`
- sympy/tensor/array/tests/test_immutable_ndim_array.py:150:16 error[unresolved-attribute] Object of type `ImmutableSparseNDimArray & ExactlySized[Literal[4]]` has no attribute `_sparse_array`
+ sympy/tensor/array/tests/test_immutable_ndim_array.py:150:16 error[unresolved-attribute] Object of type `ImmutableSparseNDimArray` has no attribute `_sparse_array`
- sympy/tensor/array/tests/test_immutable_ndim_array.py:160:16 error[unresolved-attribute] Object of type `ImmutableSparseNDimArray & ExactlySized[Literal[4]]` has no attribute `_sparse_array`
+ sympy/tensor/array/tests/test_immutable_ndim_array.py:160:16 error[unresolved-attribute] Object of type `ImmutableSparseNDimArray` has no attribute `_sparse_array`
- sympy/tensor/array/tests/test_immutable_ndim_array.py:162:16 error[unresolved-attribute] Object of type `ImmutableSparseNDimArray & ExactlySized[Literal[4]]` has no attribute `_sparse_array`
+ sympy/tensor/array/tests/test_immutable_ndim_array.py:162:16 error[unresolved-attribute] Object of type `ImmutableSparseNDimArray` has no attribute `_sparse_array`
- sympy/tensor/array/tests/test_mutable_ndim_array.py:147:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray & ExactlySized[Literal[4]]` has no attribute `_sparse_array`
+ sympy/tensor/array/tests/test_mutable_ndim_array.py:147:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray` has no attribute `_sparse_array`
- sympy/tensor/array/tests/test_mutable_ndim_array.py:155:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray & ExactlySized[Literal[4]]` has no attribute `_sparse_array`
+ sympy/tensor/array/tests/test_mutable_ndim_array.py:155:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray` has no attribute `_sparse_array`
- sympy/tensor/array/tests/test_mutable_ndim_array.py:162:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray & ExactlySized[Literal[4]]` has no attribute `_sparse_array`
+ sympy/tensor/array/tests/test_mutable_ndim_array.py:162:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray` has no attribute `_sparse_array`
- sympy/tensor/array/tests/test_mutable_ndim_array.py:164:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray & ExactlySized[Literal[4]]` has no attribute `_sparse_array`
+ sympy/tensor/array/tests/test_mutable_ndim_array.py:164:16 error[unresolved-attribute] Object of type `MutableSparseNDimArray` has no attribute `_sparse_array`
- sympy/vector/basisdependent.py:225:9 error[invalid-assignment] Object of type `dict[Unknown, Divergent] & ~ExactlySized[Literal[0, False]]` is not assignable to attribute `_components` on type `Expr & ~Mul`
+ sympy/vector/basisdependent.py:225:9 error[invalid-assignment] Object of type `dict[Unknown, Divergent]` is not assignable to attribute `_components` on type `Expr & ~Mul`
vision (https://github.com/pytorch/vision)
- test/test_functional_tensor.py:112:107 error[invalid-argument-type] Argument to function `rotate` is incorrect: Expected `list[int | float] | None`, found `int | (Unknown & ~ExactlySized[Literal[1, True]])`
+ test/test_functional_tensor.py:112:107 error[invalid-argument-type] Argument to function `rotate` is incorrect: Expected `list[int | float] | None`, found `int | Unknown`
- test/test_functional_tensor.py:316:105 error[invalid-argument-type] Argument to function `affine` is incorrect: Expected `list[int | float] | None`, found `int | (Unknown & ~ExactlySized[Literal[1, True]])`
+ test/test_functional_tensor.py:316:105 error[invalid-argument-type] Argument to function `affine` is incorrect: Expected `list[int | float] | None`, found `int | Unknown`
- test/test_functional_tensor.py:395:87 error[invalid-argument-type] Argument to function `perspective` is incorrect: Expected `list[int | float] | None`, found `int | (Unknown & ~ExactlySized[Literal[1, True]])`
+ test/test_functional_tensor.py:395:87 error[invalid-argument-type] Argument to function `perspective` is incorrect: Expected `list[int | float] | None`, found `int | Unknown`
werkzeug (https://github.com/pallets/werkzeug)
- tests/test_datastructures.py:690:16 error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal[42]` and `EnvironHeaders & ExactlySized[Literal[3]] & ~AlwaysFalsy`
+ tests/test_datastructures.py:690:16 error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal[42]` and `EnvironHeaders & ~AlwaysFalsy`
xarray (https://github.com/pydata/xarray)
- xarray/core/extension_array.py:195:54 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
+ xarray/core/extension_array.py:195:54 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
zulip (https://github.com/zulip/zulip)
- zerver/lib/event_schema.py:409:29 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
+ zerver/lib/event_schema.py:409:29 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- zerver/lib/event_schema.py:412:29 error[not-subscriptable] Cannot subscript object of type `ExactlySized[Literal[1, True]]` with no `__getitem__` method
+ zerver/lib/event_schema.py:412:29 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
Summary
Restrict exact
len()narrowing to types that actually encode their possible lengths, so that we don't wrongly preserve length-narrowings on types with mutable length.Closes astral-sh/ty#3710.
Test plan
Added/updated mdtests.
Ecosystem analysis
72 of the added diagnostics (48 in apprise, 19 in scrapy, plus some others) are from restoring correct reachability to code that was previously erroneously marked unreachable.
33 new diagnostics involve cases where we previously narrowed
Noneout of a type after alencall (which itself errors sinceNoneis notSized), sinceNoneis disjoint fromExactlySized. We could easily continue to do this (remove any nonSizedtypes when narrowing from alencheck), and I don't think it's wrong to do so? But it's kind of odd to narrow from a failed call, and no other type checker does it, so I haven't done it in this PR.12 new diagnostics (all in packaging, or pip from its vendored packaging) come from a case where we are length-narrowing correctly, it's just we top-materialize
isinstanceandobjectis not assignable where a value from that tuple is used. This was silenced on main because we don't support exact unpacking from an intersection at all, and we previously had an intersection withExactlySizedhere.Four new diagnostics in
ppb-vectorcome from code like this:Where retaining the intersection with
~ExactlySized[2]allowed us to rule out the "both a Sequence and a Mapping" case in the second branch (since if it were a sequence of length 2 it would have already taken the first branch). This is the only case where this PR regresses results. We could keep this by restoringExactlySizedand continuing to use it withSequenceandMappingtypes -- but that would add a lot of code for something that has a very small ecosystem impact.