[ty] Add support for functional TypedDict(...)#24092
[ty] Add support for functional TypedDict(...)#24092charliermarsh wants to merge 1 commit intomainfrom
TypedDict(...)#24092Conversation
Typing conformance resultsThe percentage of diagnostics emitted that were expected errors decreased from 85.38% to 85.34%. The percentage of expected errors that received a diagnostic increased from 78.70% to 78.98%. The number of fully passing files improved from 64/132 to 65/132. 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 breakdown4 files altered
True positives added (3)3 diagnostics
False positives added (1)1 diagnostic
Optional Diagnostics Added (1)1 diagnostic
Optional Diagnostics Removed (1)1 diagnostic
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
0 | 40 | 0 |
invalid-argument-type |
32 | 3 | 3 |
invalid-key |
11 | 3 | 0 |
missing-typed-dict-key |
12 | 1 | 0 |
unused-type-ignore-comment |
0 | 13 | 0 |
unresolved-attribute |
0 | 7 | 0 |
invalid-assignment |
5 | 0 | 0 |
invalid-method-override |
5 | 0 | 0 |
invalid-return-type |
1 | 3 | 0 |
no-matching-overload |
1 | 0 | 0 |
| Total | 67 | 70 | 3 |
Large timing changes:
| Project | Old Time | New Time | Change |
|---|---|---|---|
cibuildwheel |
0.07s | 0.11s | +53% |
Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.
Raw diff (98 changes)
alerta (https://github.com/alerta/alerta)
+ alerta/utils/logging.py:48:25 error[invalid-key] Unknown key "()" for TypedDict `_FormatterConfigurationTypedDict`
+ alerta/utils/logging.py:57:25 error[invalid-key] Unknown key "()" for TypedDict `_FormatterConfigurationTypedDict`
+ alerta/utils/logging.py:60:25 error[invalid-key] Unknown key "()" for TypedDict `_FormatterConfigurationTypedDict`
+ alerta/utils/logging.py:61:25 error[invalid-key] Unknown key "facility" for TypedDict `_FormatterConfigurationTypedDict`
dragonchain (https://github.com/dragonchain/dragonchain)
+ dragonchain/lib/dto/api_key_model.py:175:9 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `permissions_doc`, found `permissions_doc | dict[str, str | bool | dict[Unknown, Unknown]]`
+ dragonchain/lib/dto/api_key_model.py:209:9 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `permissions_doc`, found `permissions_doc | dict[str, str | bool | dict[Unknown, Unknown]]`
+ dragonchain/transaction_processor/level_3_actions_utest.py:247:86 error[invalid-argument-type] Argument to function `verify_blocks` is incorrect: Expected `L1Headers`, found `dict[str, str]`
+ dragonchain/webserver/helpers_utest.py:169:47 error[invalid-argument-type] Argument to function `verify_custom_indexes_options` is incorrect: Expected `Iterable[custom_index]`, found `list[dict[str, str]]`
+ dragonchain/webserver/helpers_utest.py:169:48 error[missing-typed-dict-key] Missing required key 'options' in TypedDict `custom_index` constructor
+ dragonchain/webserver/helpers_utest.py:172:47 error[invalid-argument-type] Argument to function `verify_custom_indexes_options` is incorrect: Expected `Iterable[custom_index]`, found `list[dict[str, str]]`
+ dragonchain/webserver/helpers_utest.py:172:48 error[missing-typed-dict-key] Missing required key 'options' in TypedDict `custom_index` constructor
+ dragonchain/webserver/helpers_utest.py:175:47 error[invalid-argument-type] Argument to function `verify_custom_indexes_options` is incorrect: Expected `Iterable[custom_index]`, found `list[dict[str, str]]`
+ dragonchain/webserver/helpers_utest.py:175:48 error[missing-typed-dict-key] Missing required key 'options' in TypedDict `custom_index` constructor
+ dragonchain/webserver/lib/api_keys_utest.py:48:66 error[invalid-argument-type] Argument to function `create_api_key_v1` is incorrect: Expected `permissions_doc | None`, found `dict[str, str]`
+ dragonchain/webserver/lib/api_keys_utest.py:48:87 error[missing-typed-dict-key] Missing required key 'default_allow' in TypedDict `permissions_doc` constructor
+ dragonchain/webserver/lib/api_keys_utest.py:48:87 error[missing-typed-dict-key] Missing required key 'permissions' in TypedDict `permissions_doc` constructor
+ dragonchain/webserver/lib/api_keys_utest.py:48:87 error[missing-typed-dict-key] Missing required key 'version' in TypedDict `permissions_doc` constructor
+ dragonchain/webserver/lib/api_keys_utest.py:48:88 error[invalid-key] Unknown key "wind" for TypedDict `permissions_doc`
+ dragonchain/webserver/lib/api_keys_utest.py:91:59 error[invalid-argument-type] Argument to function `update_api_key_v1` is incorrect: Expected `permissions_doc | None`, found `dict[str, str]`
+ dragonchain/webserver/lib/api_keys_utest.py:91:59 error[missing-typed-dict-key] Missing required key 'default_allow' in TypedDict `permissions_doc` constructor
+ dragonchain/webserver/lib/api_keys_utest.py:91:59 error[missing-typed-dict-key] Missing required key 'permissions' in TypedDict `permissions_doc` constructor
+ dragonchain/webserver/lib/api_keys_utest.py:91:59 error[missing-typed-dict-key] Missing required key 'version' in TypedDict `permissions_doc` constructor
+ dragonchain/webserver/lib/api_keys_utest.py:91:60 error[invalid-key] Unknown key "definitely" for TypedDict `permissions_doc`
+ dragonchain/lib/database/redisearch_utest.py:71:55 error[invalid-argument-type] Argument to function `create_transaction_index` is incorrect: Expected `Iterable[custom_index] | None`, found `list[dict[str, str]]`
+ dragonchain/lib/database/redisearch_utest.py:71:56 error[missing-typed-dict-key] Missing required key 'options' in TypedDict `custom_index` constructor
+ dragonchain/transaction_processor/level_4_actions_utest.py:73:63 error[invalid-argument-type] Argument to function `verify_blocks` is incorrect: Expected `L1Headers`, found `dict[str, int | str]`
+ dragonchain/transaction_processor/level_4_actions_utest.py:73:73 error[invalid-argument-type] Invalid argument to key "dc_id" with declared type `str` on TypedDict `L1Headers`: value of type `Literal[123]`
+ dragonchain/transaction_processor/level_4_actions_utest.py:73:90 error[invalid-argument-type] Invalid argument to key "block_id" with declared type `str` on TypedDict `L1Headers`: value of type `Literal[124]`
graphql-core (https://github.com/graphql-python/graphql-core)
- tests/utilities/test_build_client_schema.py:90:53 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/utilities/test_build_client_schema.py:498:54 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/utilities/test_build_client_schema.py:673:44 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/utilities/test_build_client_schema.py:682:42 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/utilities/test_build_client_schema.py:987:60 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/utilities/test_build_client_schema.py:1002:55 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/wrapper/_implementations.py:1572:89 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
isort (https://github.com/pycqa/isort)
- isort/output.py:587:25 error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `@Todo(Functional TypedDicts) | None | list[Unknown]`
+ isort/output.py:587:25 error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `Any | None | list[Unknown]`
- isort/output.py:597:25 error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `@Todo(Functional TypedDicts) | None | list[Unknown]`
+ isort/output.py:597:25 error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `Any | None | list[Unknown]`
- isort/output.py:605:29 error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `@Todo(Functional TypedDicts) | None | list[Unknown]`
+ isort/output.py:605:29 error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `Any | None | list[Unknown]`
meson (https://github.com/mesonbuild/meson)
- mesonbuild/cargo/manifest.py:330:16 error[missing-typed-dict-key] Missing required key 'workspace' in TypedDict `FromWorkspace` constructor
- mesonbuild/cargo/manifest.py:330:17 error[invalid-key] Unknown key "version" for TypedDict `FromWorkspace`
- mesonbuild/cargo/manifest.py:542:40 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `LibTarget`, found `dict[Unknown, Unknown]`
- mesonbuild/cargo/manifest.py:557:54 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `BuildTarget`, found `dict[str, str]`
- mesonbuild/cargo/manifest.py:563:54 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `BuildTarget`, found `dict[str, str]`
+ mesonbuild/cargo/manifest.py:336:22 error[no-matching-overload] No overload of function `_depv_to_dep` matches arguments
+ unittests/cargotests.py:332:40 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:333:33 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, dict[str, str] | FromWorkspace]`
+ unittests/cargotests.py:333:45 error[missing-typed-dict-key] Missing required key 'version' in TypedDict `Package` constructor
+ unittests/cargotests.py:340:33 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, dict[str, str]]`
+ unittests/cargotests.py:340:45 error[missing-typed-dict-key] Missing required key 'version' in TypedDict `Package` constructor
+ unittests/cargotests.py:350:40 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:364:40 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:400:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:417:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:441:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:457:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:497:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:504:38 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:515:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:549:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
+ unittests/cargotests.py:569:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `Manifest`, found `dict[str, object]`
- unittests/cargotests.py:379:68 error[invalid-key] Unknown key "optional" for TypedDict `FromWorkspace`
+ unittests/cargotests.py:379:48 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `FromWorkspace | Dependency | str`, found `dict[str, bool]`
- unittests/cargotests.py:387:62 error[invalid-key] Unknown key "features" for TypedDict `FromWorkspace`
+ unittests/cargotests.py:387:42 error[invalid-argument-type] Argument to bound method `from_raw` is incorrect: Expected `FromWorkspace | Dependency | str`, found `dict[str, bool | list[str]]`
operator (https://github.com/canonical/operator)
+ ops/_private/harness.py:1640:9 error[invalid-assignment] Invalid subscript assignment with key of type `tuple[str | None, int | None]` and value of type `dict[str, list[dict[str, str | list[dict[str, str]]]] | list[str]]` on object of type `dict[tuple[str | None, int | None], _NetworkDict]`
+ ops/_private/harness.py:3355:38 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | LayerDict | None`, found `str | (LayerDict & Top[dict[Unknown, Unknown]]) | (Layer & Top[dict[Unknown, Unknown]])`
- ops/model.py:3738:40 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ ops/model.py:3737:16 error[invalid-return-type] Return type does not match returned value: expected `_StatusDict`, found `dict[str, str]`
- ops/pebble.py:630:58 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- ops/pebble.py:720:58 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- ops/pebble.py:789:58 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- ops/pebble.py:1170:40 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- ops/pebble.py:1188:40 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ ops/pebble.py:884:9 error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `object.__eq__`
+ ops/pebble.py:946:9 error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `object.__eq__`
+ ops/pebble.py:963:28 error[invalid-assignment] Object of type `(ServiceDict & ~AlwaysFalsy) | dict[Unknown, Unknown]` is not assignable to `ServiceDict`
+ ops/pebble.py:1033:9 error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `object.__eq__`
+ ops/pebble.py:1101:26 error[invalid-assignment] Object of type `(CheckDict & ~AlwaysFalsy) | dict[Unknown, Unknown]` is not assignable to `CheckDict`
+ ops/pebble.py:1148:9 error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `object.__eq__`
+ ops/pebble.py:1171:27 error[invalid-key] TypedDict `ExecDict` can only be subscripted with a string literal key, got key of type `str`.
+ ops/pebble.py:1173:27 error[invalid-key] TypedDict `ExecDict` can only be subscripted with a string literal key, got key of type `str & ~Literal["environment"]`.
+ ops/pebble.py:1189:27 error[invalid-key] TypedDict `HttpDict` can only be subscripted with a string literal key, got key of type `str`.
+ ops/pebble.py:1191:27 error[invalid-key] TypedDict `HttpDict` can only be subscripted with a string literal key, got key of type `str & ~Literal["headers"]`.
+ ops/pebble.py:1204:22 error[invalid-key] TypedDict `TcpDict` can only be subscripted with a string literal key, got key of type `str`.
+ ops/pebble.py:1262:30 error[invalid-assignment] Object of type `(LogTargetDict & ~AlwaysFalsy) | dict[Unknown, Unknown]` is not assignable to `LogTargetDict`
+ ops/pebble.py:1286:9 error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `object.__eq__`
+ ops/pebble.py:2103:23 error[invalid-argument-type] Invalid argument to key "access" with declared type `Literal["untrusted", "metrics", "read", "admin"]` on TypedDict `IdentityDict`: value of type `str`
+ ops/pebble.py:2556:36 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | LayerDict | None`, found `(LayerDict & Top[dict[Unknown, Unknown]]) | (Layer & Top[dict[Unknown, Unknown]])`
ppb-vector (https://github.com/ppb/ppb-vector)
- tests/test_length.py:41:20 error[unresolved-attribute] Object of type `int | float` has no attribute `length`
- tests/test_project.py:50:8 error[unresolved-attribute] Object of type `int | float` has no attribute `isclose`
- tests/test_scalar_multiplication.py:10:28 error[unresolved-attribute] Object of type `int | float` has no attribute `x`
- tests/test_scalar_multiplication.py:11:28 error[unresolved-attribute] Object of type `int | float` has no attribute `y`
- tests/test_scalar_multiplication.py:19:12 error[unresolved-attribute] Object of type `int | float` has no attribute `isclose`
- tests/test_scalar_multiplication.py:24:12 error[unresolved-attribute] Object of type `int | float` has no attribute `isclose`
- tests/test_scalar_multiplication.py:32:20 error[unresolved-attribute] Object of type `int | float` has no attribute `length`
- ppb_vector/__init__.py:567:16 error[invalid-return-type] Return type does not match returned value: expected `Vector`, found `int | float`
- ppb_vector/__init__.py:588:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[Vector, Vector]`, found `tuple[int | float, Vector]`
rotki (https://github.com/rotki/rotki)
+ rotkehlchen/logging.py:210:23 error[invalid-argument-type] Invalid argument to key "formatters" with declared type `dict[str, _FormatterConfigurationTypedDict | dict[str, Any]]` on TypedDict `_DictConfigArgs`: value of type `dict[str, dict[str, str]]`8eafd25 to
bc66412
Compare
34f9e2b to
758a457
Compare
758a457 to
9d2bc1d
Compare
|
Closing in favor of this stack: #24174 |
Summary
Closes astral-sh/ty#3095.