[ty] Narrow TypedDicts through isinstance(..., dict)#23946
[ty] Narrow TypedDicts through isinstance(..., dict)#23946charliermarsh wants to merge 43 commits intocharlie/td-specialize-2from
Conversation
c93ef08 to
931ca14
Compare
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 86.60%. The percentage of expected errors that received a diagnostic held steady at 81.47%. The number of fully passing files held steady at 69/132. |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
AlexWaygood
left a comment
There was a problem hiding this comment.
Exciting! 😃
I know this is still in draft, just a couple of things I noticed
| if class.is_known(db, KnownClass::Dict) { | ||
| UnionType::from_two_elements(db, instance_constraint, Type::TypedDictTop) | ||
| } else { | ||
| instance_constraint | ||
| } |
There was a problem hiding this comment.
you also want to do the same here if class.is_known(db, KnownClass::MutableMapping)
18db004 to
3baa343
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
0be1f1e to
bb52eee
Compare
|
I think these changes have the behavior we want, but it's more complex than I wanted. |
AlexWaygood
left a comment
There was a problem hiding this comment.
Haven't looked through the whole patch yet because it's in draft (LMK if you want me to) -- but there are more changes to narrow.rs now than I'd have expected
crates/ty_python_semantic/resources/mdtest/narrow/isinstance.md
Outdated
Show resolved
Hide resolved
37bdc9b to
3db3377
Compare
| def f(x: dict[str, int] | list[str], y: object): | ||
| if isinstance(x, t.Dict): | ||
| reveal_type(x) # revealed: dict[str, int] | ||
| reveal_type(x) # revealed: (dict[str, int] & dict[Any, Any]) | (dict[str, int] & Top[TypedDict]) |
There was a problem hiding this comment.
this should still be dict[str, int], and this will fall out naturally if you implement what I said in #23943 (comment):
isinstance(x, dict)(orisinstance(x, typing.Dict)should add a narrowing constraint ofTop[dict[Unknown, Unknown]] | TypedDictTop- that means that the narrowed type of
xhere would be(dict[str, int] | list[str]) & (Top[dict[Unknown, Unknown]] | TypedDictTop - Due to de Morgan's rules, that simplifies to
(dict[str, int] & Top[dict[Unknown, Unknown]]) | (dict[str, int] & TypedDictTop) | (list[str] & Top[dict[Unknown, Unknown]]) | (list[str] & TypedDictTop) - And that should in turn simplify to
dict[str, int] | Never | Never | Never:dict[str, int]is a subtype ofTop[dict[Unknown, Unknown]], sodict[str, int] & Top[dict[Unknown, Unknown]]simplifies todict[str, int]TypedDictTop, and allTypedDicttypes, should be implemented as being disjoint from any non-structural type that is not a supertype ofTypedDictTop: they should be disjoint from bothdicst[str, int]andlist[str]. If you do that, then bothdict[str, int] & TypedDictTopandlist[str] & TypedDictTopwill naturally simplify toNeverin our intersection builder.dict[str, int]is already understood by ty as being disjoint fromlist[str], so that part should already naturally be simplified toNeverin our intersection builder
dict[str, int] | Never | Never | Neverwill naturally be simplified todict[str, int]by our union builder
There was a problem hiding this comment.
"Structural types" are TypedDict types (including TypedDictTop itself), Callable types and Protocol types. The only non-structural supertypes of TypedDictTop are Mapping[str, object] and all nominal supertypes of Mapping[str, object].
There was a problem hiding this comment.
When I make this change, I see the following regression:
from typing import Any, TypedDict
class TD(TypedDict):
x: int
def f(dt: dict[str, Any], key: str):
reveal_type(dt.get(key, {"x": 0})) # revealed: Any
x: TD = dt.get(key, {"x": 0})
reveal_type(x) # current: Any; after the change: UnknownTrying to figure that out.
There was a problem hiding this comment.
hmm, interesting... I can't immediately say I know why that would be. There might be an unrelated pre-existing bug somewhere? not sure
3dc84c5 to
a840e56
Compare
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
10 | 222 | 32 |
no-matching-overload |
1 | 26 | 0 |
invalid-return-type |
0 | 8 | 17 |
invalid-assignment |
5 | 16 | 3 |
unresolved-attribute |
2 | 12 | 6 |
not-subscriptable |
0 | 13 | 0 |
unsupported-operator |
0 | 7 | 0 |
not-iterable |
1 | 2 | 1 |
invalid-type-form |
0 | 0 | 2 |
invalid-yield |
0 | 1 | 0 |
redundant-cast |
1 | 0 | 0 |
too-many-positional-arguments |
0 | 1 | 0 |
unused-type-ignore-comment |
1 | 0 | 0 |
| Total | 21 | 308 | 61 |
Showing a random sample of 237 of 390 changes. See the HTML report for the full diff.
Raw diff sample (237 of 390 changes)
PyGithub (https://github.com/PyGithub/PyGithub)
- github/AdvisoryCredit.py:97:31 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["login"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryCredit.py:98:31 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryCredit.py:98:53 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryCredit.py:113:20 error[invalid-return-type] Return type does not match returned value: expected `SimpleCredit`, found `dict[str, object]`
- github/AdvisoryCredit.py:115:25 error[invalid-argument-type] Invalid argument to key "type" with declared type `str` on TypedDict `SimpleCredit`: value of type `object`
- github/AdvisoryCredit.py:115:25 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryVulnerability.py:129:59 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["package"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryVulnerability.py:129:59 error[invalid-assignment] Object of type `object` is not assignable to `SimpleAdvisoryVulnerabilityPackage`
- github/AdvisoryVulnerability.py:136:31 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["patched_versions"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryVulnerability.py:142:20 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["vulnerable_functions"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryVulnerability.py:146:31 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["vulnerable_version_range"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryVulnerability.py:158:73 error[invalid-assignment] Object of type `object` is not assignable to `SimpleAdvisoryVulnerabilityPackage`
- github/AdvisoryVulnerability.py:164:37 error[invalid-argument-type] Invalid argument to key "patched_versions" with declared type `str | None` on TypedDict `SimpleAdvisoryVulnerability`: value of type `object`
- github/AdvisoryVulnerability.py:165:41 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["vulnerable_functions"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryVulnerability.py:166:45 error[invalid-argument-type] Invalid argument to key "vulnerable_version_range" with declared type `str | None` on TypedDict `SimpleAdvisoryVulnerability`: value of type `object`
- github/AdvisoryVulnerability.py:166:45 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["vulnerable_version_range"]` on object of type `Top[dict[Unknown, Unknown]]`
- github/AdvisoryVulnerability.py:170:30 error[unresolved-attribute] Attribute `package` is not defined on `SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]` in union `(SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]) | (AdvisoryVulnerability & ~Top[dict[Unknown, Unknown]])`
- github/AdvisoryVulnerability.py:171:25 error[unresolved-attribute] Attribute `package` is not defined on `SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]` in union `(SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]) | (AdvisoryVulnerability & ~Top[dict[Unknown, Unknown]])`
- github/AdvisoryVulnerability.py:173:33 error[unresolved-attribute] Attribute `patched_versions` is not defined on `SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]` in union `(SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]) | (AdvisoryVulnerability & ~Top[dict[Unknown, Unknown]])`
- github/AdvisoryVulnerability.py:174:37 error[unresolved-attribute] Attribute `vulnerable_functions` is not defined on `SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]` in union `(SimpleAdvisoryVulnerability & ~Top[dict[Unknown, Unknown]]) | (AdvisoryVulnerability & ~Top[dict[Unknown, Unknown]])`
altair (https://github.com/vega/altair)
- altair/jupyter/jupyter_chart.py:256:29 error[no-matching-overload] No overload of bound method `get` matches arguments
- altair/utils/data.py:161:13 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `object`
- altair/utils/data.py:193:22 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/utils/data.py:193:22 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/utils/data.py:193:22 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/utils/data.py:198:36 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `object`
- altair/utils/data.py:199:36 error[invalid-argument-type] Argument to bound method `sample` is incorrect: Expected `Sequence[Unknown] | AbstractSet[Unknown]`, found `object`
- altair/utils/data.py:378:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/utils/data.py:378:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/utils/data.py:378:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/utils/data.py:209:28 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~None & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
+ altair/utils/data.py:209:28 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~None & ~DataFrame & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
- altair/utils/data.py:210:39 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~None & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
+ altair/utils/data.py:210:39 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(NativeDataFrame & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~None & ~DataFrame & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict]) | (SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
- altair/utils/data.py:416:12 error[unresolved-attribute] Attribute `write_csv` is not defined on `NativeDataFrame & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]`, `DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]`, `DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]` in union `(NativeDataFrame & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (altair.utils.core.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
+ altair/utils/data.py:416:12 error[unresolved-attribute] Attribute `write_csv` is not defined on `NativeDataFrame & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]`, `DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]`, `DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]` in union `(NativeDataFrame & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (narwhals.stable.v1.typing.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]]) | (Unknown & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict]) | (altair.utils.core.DataFrameLike & ~SupportsGeoInterface & ~DataFrame & ~Top[dict[Unknown, Unknown]])`
- altair/vegalite/v6/api.py:255:18 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/vegalite/v6/api.py:255:18 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/vegalite/v6/api.py:255:18 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/vegalite/v6/api.py:255:18 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- altair/vegalite/v6/api.py:1179:45 error[invalid-argument-type] Argument to function `_reveal_parsed_shorthand` is incorrect: Expected `Mapping[str, Any]`, found `_C@Then & Top[dict[Unknown, Unknown]]`
- altair/vegalite/v6/api.py:908:5 error[no-matching-overload] No overload of bound method `update` matches arguments
+ altair/vegalite/v6/api.py:908:22 error[invalid-argument-type] Argument to bound method `update` is incorrect: Argument type `dict[str, Any]` does not satisfy upper bound `Top[TypedDict]` of type variable `Self`
+ altair/vegalite/v6/api.py:908:22 error[invalid-argument-type] Argument to bound method `update` is incorrect: Expected `Top[TypedDict]`, found `dict[str, Any]`
- altair/vegalite/v6/api.py:909:12 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `(Mapping[str, Any] & Top[dict[Unknown, Unknown]] & ~SchemaBase) | dict[str, Any]`
+ altair/vegalite/v6/api.py:909:12 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `(Mapping[str, Any] & Top[dict[Unknown, Unknown]] & ~SchemaBase) | (Mapping[str, Any] & Top[TypedDict]) | dict[str, Any]`
apprise (https://github.com/caronc/apprise)
- apprise/config/base.py:1116:31 error[no-matching-overload] No overload of bound method `match` matches arguments
- apprise/config/base.py:1179:29 error[no-matching-overload] No overload of bound method `update` matches arguments
- apprise/config/base.py:1188:37 error[invalid-argument-type] Argument to function `_special_token_handler` is incorrect: Expected `dict[str, object]`, found `Top[dict[Unknown, Unknown]]`
artigraph (https://github.com/artigraph/artigraph)
- src/arti/internal/type_hints.py:161:25 error[invalid-type-form] Variable of type `type` is not allowed in a type expression
+ src/arti/internal/type_hints.py:161:25 error[invalid-type-form] Variable of type `type[Unknown]` is not allowed in a type expression
- src/arti/internal/type_hints.py:161:41 error[invalid-type-form] Variable of type `type` is not allowed in a type expression
+ src/arti/internal/type_hints.py:161:41 error[invalid-type-form] Variable of type `type[Unknown]` is not allowed in a type expression
- src/arti/storage/_internal.py:146:9 error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `object` on object of type `dict[str, str]`
bokeh (https://github.com/bokeh/bokeh)
- src/bokeh/core/property/bases.py:264:41 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `object` on object of type `Top[dict[Unknown, Unknown]]`
- src/bokeh/embed/standalone.py:266:76 error[invalid-argument-type] Argument to function `standalone_docs_json_and_render_items` is incorrect: Expected `Model | Document | Sequence[Model | Document]`, found `Model | Sequence[Model] | dict[str, Model]`
- src/bokeh/embed/standalone.py:265:28 error[invalid-argument-type] Argument is incorrect: Expected `Sequence[Model]`, found `Model | Sequence[Model] | dict[str, Model]`
+ src/bokeh/embed/standalone.py:265:28 error[invalid-argument-type] Argument is incorrect: Expected `Sequence[Model]`, found `(Model & ~Top[dict[Unknown, Unknown]]) | (Sequence[Model] & ~Top[dict[Unknown, Unknown]]) | list[Unknown]`
cloud-init (https://github.com/canonical/cloud-init)
- cloudinit/config/cc_ubuntu_pro.py:129:16 error[no-matching-overload] No overload of function `search` matches arguments
- cloudinit/config/cc_ubuntu_pro.py:130:48 error[invalid-argument-type] Argument to function `escape` is incorrect: Argument type `~None` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr`
- cloudinit/config/cc_ubuntu_pro.py:140:27 error[no-matching-overload] No overload of bound method `replace` matches arguments
core (https://github.com/home-assistant/core)
- homeassistant/auth/permissions/merge.py:63:43 error[invalid-argument-type] Argument to function `_merge_policies` is incorrect: Expected `list[CategoryType]`, found `list[SubCategoryType | None]`
+ homeassistant/auth/permissions/merge.py:63:43 error[invalid-argument-type] Argument to function `_merge_policies` is incorrect: Expected `list[CategoryType]`, found `list[Mapping[str, ValueType] | bool | None]`
- homeassistant/auth/permissions/util.py:113:12 error[invalid-return-type] Return type does not match returned value: expected `bool`, found `ValueType`
+ homeassistant/auth/permissions/util.py:113:12 error[invalid-return-type] Return type does not match returned value: expected `bool`, found `Mapping[str, bool] | bool | None`
- homeassistant/components/asuswrt/helpers.py:44:16 error[invalid-return-type] Return type does not match returned value: expected `T@translate_to_legacy`, found `dict[Unknown, object]`
+ homeassistant/components/asuswrt/helpers.py:44:16 error[invalid-return-type] Return type does not match returned value: expected `T@translate_to_legacy`, found `dict[Unknown, Unknown]`
- homeassistant/components/google_assistant/http.py:413:12 error[invalid-return-type] Return type does not match returned value: expected `list[str]`, found `list[object]`
cwltool (https://github.com/common-workflow-language/cwltool)
- tests/test_examples.py:327:12 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/test_examples.py:327:12 error[not-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- tests/test_examples.py:327:12 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> LiteralString, (key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str]` cannot be called with key of type `Literal["checksum"]` on object of type `str`
- tests/test_examples.py:328:12 error[invalid-argument-type] Method `__getitem__` of type `bound method MutableMapping[str, Divergent].__getitem__(key: str, /) -> Divergent` cannot be called with key of type `Literal[1]` on object of type `MutableMapping[str, Divergent]`
- tests/test_examples.py:329:12 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/test_examples.py:329:12 error[not-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method
- tests/test_examples.py:329:12 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> LiteralString, (key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str]` cannot be called with key of type `Literal["checksum"]` on object of type `str`
- tests/test_examples.py:329:12 error[invalid-argument-type] Method `__getitem__` of type `bound method MutableMapping[str, Divergent].__getitem__(key: str, /) -> Divergent` cannot be called with key of type `Literal[2]` on object of type `MutableMapping[str, Divergent]`
- tests/test_examples.py:342:12 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/test_examples.py:342:12 error[not-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method
- tests/test_examples.py:342:12 error[not-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- tests/test_examples.py:342:12 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> LiteralString, (key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str]` cannot be called with key of type `Literal["checksum"]` on object of type `str`
- tests/test_examples.py:1449:12 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Divergent, (index: slice[int | None, int | None, int | None], /) -> MutableSequence[Divergent]]` cannot be called with key of type `Literal["checksum"]` on object of type `MutableSequence[Divergent]`
- tests/test_examples.py:1449:12 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["checksum"]` on object of type `Top[dict[Unknown, Unknown]]`
- tests/test_examples.py:1694:28 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> LiteralString, (key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str]` cannot be called with key of type `Literal["location"]` on object of type `str`
- tests/test_examples.py:1694:63 error[not-iterable] Object of type `None | int | str | ... omitted 3 union elements` may not be iterable
- tests/test_secrets.py:31:41 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Divergent, (index: slice[int | None, int | None, int | None], /) -> MutableSequence[Divergent]]` cannot be called with key of type `Literal["foo"]` on object of type `MutableSequence[Divergent]`
- cwltool/job.py:180:46 error[no-matching-overload] No overload of bound method `get` matches arguments
- cwltool/job.py:181:39 error[no-matching-overload] No overload of bound method `get` matches arguments
- cwltool/process.py:314:24 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["class"]`
- cwltool/process.py:318:51 error[invalid-argument-type] Argument to function `_collectDirEntries` is incorrect: Expected `MutableMapping[str, None | int | str | ... omitted 3 union elements] | MutableSequence[MutableMapping[str, None | int | str | ... omitted 3 union elements]] | None`, found `object`
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/internal/remoteconfig/__init__.py:35:44 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `object`
- ddtrace/appsec/_asm_request_context.py:241:32 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `int`, found `Any | str | int | None`
- ddtrace/appsec/_asm_request_context.py:241:32 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Any | str | int | None`
- ddtrace/appsec/_asm_request_context.py:241:32 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Any | str | int | None`
- ddtrace/appsec/_asm_request_context.py:241:32 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Any | str | int | None`
- ddtrace/contrib/internal/botocore/services/stepfunctions.py:37:58 error[invalid-argument-type] Argument to function `dispatch` is incorrect: Expected `tuple[Any, ...]`, found `list[ExecutionContext[Unknown] | None | (Any & Top[dict[Unknown, Unknown]])]`
+ ddtrace/contrib/internal/botocore/services/stepfunctions.py:37:58 error[invalid-argument-type] Argument to function `dispatch` is incorrect: Expected `tuple[Any, ...]`, found `list[ExecutionContext[Unknown] | None | (Any & Top[dict[Unknown, Unknown]]) | (Any & Top[TypedDict])]`
- ddtrace/contrib/internal/pymongo/utils.py:146:26 error[no-matching-overload] No overload of bound method `get` matches arguments
- ddtrace/internal/remoteconfig/client.py:170:35 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `object`
- ddtrace/llmobs/_evaluators/llm_judge.py:817:50 error[invalid-argument-type] Argument to function `_format_schema_for_provider` is incorrect: Expected `dict[str, Any]`, found `(Unknown & Top[dict[Unknown, Unknown]]) | (BooleanStructuredOutput & Top[dict[Unknown, Unknown]]) | (ScoreStructuredOutput & Top[dict[Unknown, Unknown]]) | (CategoricalStructuredOutput & Top[dict[Unknown, Unknown]]) | dict[str, str | int | float | ... omitted 3 union elements]`
+ ddtrace/llmobs/_evaluators/llm_judge.py:817:50 error[invalid-argument-type] Argument to function `_format_schema_for_provider` is incorrect: Expected `dict[str, Any]`, found `(Unknown & Top[dict[Unknown, Unknown]]) | (BooleanStructuredOutput & Top[dict[Unknown, Unknown]]) | (ScoreStructuredOutput & Top[dict[Unknown, Unknown]]) | ... omitted 3 union elements`
- ddtrace/llmobs/_integrations/bedrock_agents.py:116:31 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["traceId"]`
- ddtrace/llmobs/_integrations/bedrock_agents.py:120:12 error[unresolved-attribute] Object of type `object` has no attribute `get`
- ddtrace/llmobs/_utils.py:205:16 error[no-matching-overload] No overload of bound method `get` matches arguments
freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/util/rich_tables.py:32:21 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[dict[Unknown, Unknown]]`
- freqtrade/util/rich_tables.py:32:47 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[dict[Unknown, Unknown]]`
- freqtrade/util/rich_tables.py:32:75 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> str | Unknown, (index: slice[int | None, int | None, int | None], /) -> Sequence[str | Unknown]]` cannot be called with key of type `str` on object of type `Sequence[str | Unknown]`
- freqtrade/util/rich_tables.py:32:75 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[dict[Unknown, Unknown]]`
graphql-core (https://github.com/graphql-python/graphql-core)
- src/graphql/error/graphql_error.py:213:58 error[invalid-argument-type] Argument to function `getattr` is incorrect: Expected `str`, found `~Literal["original_error"]`
- src/graphql/error/graphql_error.py:213:77 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `~Literal["original_error"]`
- src/graphql/execution/types.py:106:28 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["data"]`
- src/graphql/execution/types.py:107:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["errors"]`
- src/graphql/execution/types.py:108:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["extensions"]`
- src/graphql/execution/types.py:193:27 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["data"]`
- src/graphql/execution/types.py:194:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["errors"]`
- src/graphql/execution/types.py:196:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["hasNext"]`
- src/graphql/execution/types.py:294:28 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["hasNext"]`
- src/graphql/execution/types.py:295:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["pending"]`
- src/graphql/execution/types.py:296:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["incremental"]`
- src/graphql/execution/types.py:297:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["completed"]`
- src/graphql/execution/types.py:298:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["extensions"]`
- src/graphql/execution/types.py:412:31 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["id"]`
- src/graphql/execution/types.py:415:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["extensions"]`
- src/graphql/execution/types.py:520:31 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["id"]`
- src/graphql/execution/types.py:617:27 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["id"]`
- src/graphql/execution/types.py:618:32 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["path"]`
- src/graphql/execution/types.py:669:62 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["errors"]`
ibis (https://github.com/ibis-project/ibis)
- ibis/backends/sql/ddl.py:82:54 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[dict[Unknown, Unknown]]`
ignite (https://github.com/pytorch/ignite)
- tests/ignite/test_utils.py:49:28 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Unknown, (index: slice[int | None, int | None, int | None], /) -> Sequence[Unknown]]` cannot be called with key of type `Literal["a"]` on object of type `Sequence[Unknown]`
- tests/ignite/test_utils.py:50:28 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["b"]` on object of type `Top[dict[Unknown, Unknown]]`
jax (https://github.com/google/jax)
- jax/_src/pallas/core.py:1469:60 error[invalid-argument-type] Argument to function `debug_info` is incorrect: Expected `dict[str, Any]`, found `(Sequence[Divergent] & Top[dict[Unknown, Unknown]]) | (Mapping[str, Divergent] & Top[dict[Unknown, Unknown]]) | dict[Unknown, Unknown]`
+ jax/_src/pallas/core.py:1469:60 error[invalid-argument-type] Argument to function `debug_info` is incorrect: Expected `dict[str, Any]`, found `(Sequence[Divergent] & Top[dict[Unknown, Unknown]]) | (Mapping[str, Divergent] & Top[dict[Unknown, Unknown]]) | (Mapping[str, Divergent] & Top[TypedDict]) | dict[Unknown, Unknown]`
jinja (https://github.com/pallets/jinja)
- src/jinja2/filters.py:169:48 error[invalid-assignment] Object of type `dict_items[object, object]` is not assignable to `Iterable[tuple[str, Any]]`
meson (https://github.com/mesonbuild/meson)
- mesonbuild/modules/sourceset.py:243:29 error[no-matching-overload] No overload of bound method `get` matches arguments
- mesonbuild/modules/sourceset.py:243:50 error[too-many-positional-arguments] Too many positional arguments to bound method `get`: expected 2, got 3
- mesonbuild/build.py:436:24 error[invalid-return-type] Return type does not match returned value: expected `_T@copy_value`, found `list[Never] | dict[Never, Never] | set[Never]`
+ mesonbuild/build.py:436:24 error[invalid-return-type] Return type does not match returned value: expected `_T@copy_value`, found `list[Never] | dict[Never, Never] | Top[TypedDict] | set[Never]`
- mesonbuild/cargo/manifest.py:143:36 error[no-matching-overload] No overload of bound method `get` matches arguments
- mesonbuild/interpreter/type_checking.py:252:37 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str | list[str]] | None`, found `dict[object, str | list[str]]`
- mesonbuild/interpreterbase/helpers.py:60:54 error[invalid-argument-type] Argument to function `stringifyUserArguments` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/interpreterbase.py:615:41 error[invalid-argument-type] Argument to bound method `_holderify` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
mkdocs (https://github.com/mkdocs/mkdocs)
- mkdocs/config/config_options.py:834:49 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["name"]` on object of type `Top[dict[Unknown, Unknown]]`
- mkdocs/config/config_options.py:855:56 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["locale"]` on object of type `Top[dict[Unknown, Unknown]]`
+ mkdocs/config/config_options.py:283:9 error[invalid-assignment] Object of type `(Top[dict[Unknown, Unknown]] & ~AlwaysFalsy) | (Top[TypedDict] & ~AlwaysFalsy)` is not assignable to attribute `data` of type `dict[Unknown, Unknown]`
+ mkdocs/config/config_options.py:1007:32 error[unresolved-attribute] Attribute `popitem` is not defined on `Top[TypedDict]` in union `Top[dict[Unknown, Unknown]] | Top[TypedDict]`
+ mkdocs/config/config_options.py:139:56 error[invalid-argument-type] Argument to bound method `setdefault` is incorrect: Expected `Never`, found `str`
- mkdocs/config/config_options.py:274:20 error[invalid-return-type] Return type does not match returned value: expected `dict[str, T@DictOfItems]`, found `Top[dict[Unknown, Unknown]] & ~AlwaysTruthy`
+ mkdocs/config/config_options.py:274:20 error[invalid-return-type] Return type does not match returned value: expected `dict[str, T@DictOfItems]`, found `(Top[dict[Unknown, Unknown]] & ~AlwaysTruthy) | (Top[TypedDict] & ~AlwaysTruthy)`
- mkdocs/config/config_options.py:844:63 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["custom_dir"]` on object of type `Top[dict[Unknown, Unknown]]`
- mkdocs/config/config_options.py:846:67 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["custom_dir"]` on object of type `Top[dict[Unknown, Unknown]]`
+ mkdocs/config/config_options.py:846:13 error[invalid-assignment] Cannot assign to a subscript on an object of type `Top[TypedDict]`
- mkdocs/config/config_options.py:858:28 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `object`
+ mkdocs/config/config_options.py:858:28 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Collection[str]`, found `object`
+ mkdocs/config/config_options.py:858:28 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | None`, found `object`
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ pymongo/asynchronous/topology.py:859:57 error[invalid-argument-type] Argument to function `_is_stale_error_topology_version` is incorrect: Expected `Mapping[str, Any] | None`, found `object`
- pymongo/collation.py:225:16 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any] | None`, found `Mapping[str, Any] & Top[dict[Unknown, Unknown]]`
+ pymongo/collation.py:225:16 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any] | None`, found `(Mapping[str, Any] & Top[dict[Unknown, Unknown]]) | (Mapping[str, Any] & Top[TypedDict])`
- pymongo/errors.py:106:43 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["errorLabels"]`
- pymongo/synchronous/topology.py:855:46 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["topologyVersion"]`
mypy (https://github.com/python/mypy)
- mypy/test/test_diff_cache.py:125:42 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["/b."]` and `object`
- mypy/test/test_diff_cache.py:125:56 error[unresolved-attribute] Object of type `object` has no attribute `startswith`
- mypy/test/test_diff_cache.py:126:42 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["/c."]` and `object`
- mypy/test/test_diff_cache.py:126:56 error[unresolved-attribute] Object of type `object` has no attribute `startswith`
- mypy/test/test_diff_cache.py:127:42 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["/a."]` and `object`
- mypy/test/test_diff_cache.py:127:56 error[unresolved-attribute] Object of type `object` has no attribute `startswith`
- mypy/config_parser.py:561:25 error[unresolved-attribute] Object of type `Mapping[str, Any] & ~Top[dict[Unknown, Unknown]]` has no attribute `getboolean`
+ mypy/config_parser.py:561:25 error[unresolved-attribute] Object of type `Mapping[str, Any] & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict]` has no attribute `getboolean`
- mypy/server/astdiff.py:157:78 error[invalid-argument-type] Argument to function `compare_symbol_table_snapshots` is incorrect: Expected `dict[str, tuple[object, ...]]`, found `Top[dict[Unknown, Unknown]]`
+ mypy/server/astdiff.py:157:78 error[invalid-argument-type] Argument to function `compare_symbol_table_snapshots` is incorrect: Expected `dict[str, tuple[object, ...]]`, found `Top[dict[Unknown, Unknown]] | Top[TypedDict]`
openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/plugins/openlibrary/lists.py:125:23 error[invalid-yield] Yield type `dict[str, dict[str, ThingReferenceDict | str | AnnotatedSeedDict]]` does not match annotated yield type `AnnotatedSeedDict`
- openlibrary/plugins/upstream/utils.py:371:49 error[no-matching-overload] No overload of function `sorted` matches arguments
operator (https://github.com/canonical/operator)
- 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/_private/harness.py:3355:38 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | LayerDict | None`, found `str | (Layer & Top[dict[Unknown, Unknown]]) | LayerDict`
pandas (https://github.com/pandas-dev/pandas)
- pandas/core/frame.py:637:56 error[invalid-argument-type] Argument to function `construct_1d_arraylike_from_scalar` is incorrect: Expected `str | bytes | date | ... omitted 10 union elements`, found `(Unknown & ~DataFrame & ~BlockManager & ~None & ~Top[dict[Unknown, Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray) | (list[Unknown] & ~BlockManager & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray)`
+ pandas/core/frame.py:637:56 error[invalid-argument-type] Argument to function `construct_1d_arraylike_from_scalar` is incorrect: Expected `str | bytes | date | ... omitted 10 union elements`, found `(Unknown & ~DataFrame & ~BlockManager & ~None & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict] & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray) | (list[Unknown] & ~BlockManager & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray)`
- pandas/core/frame.py:643:21 error[invalid-argument-type] Argument to function `construct_2d_arraylike_from_scalar` is incorrect: Expected `str | bytes | date | ... omitted 10 union elements`, found `(Unknown & ~DataFrame & ~BlockManager & ~None & ~Top[dict[Unknown, Unknown]] & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray) | (list[Unknown] & ~BlockManager & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray)`
+ pandas/core/frame.py:643:21 error[invalid-argument-type] Argument to function `construct_2d_arraylike_from_scalar` is incorrect: Expected `str | bytes | date | ... omitted 10 union elements`, found `(Unknown & ~DataFrame & ~BlockManager & ~None & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict] & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray) | (list[Unknown] & ~BlockManager & ~ndarray[tuple[object, ...], dtype[object]] & ~Series & ~Index & ~ExtensionArray)`
- pandas/io/json/_json.py:1275:36 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Hashable`
- pandas/io/parsers/arrow_parser_wrapper.py:201:32 error[unresolved-attribute] Attribute `get` is not defined on `dtype[Any]`, `ExtensionDtype` in union `(Unknown & ~None) | dict[object, dtype[Any] | ExtensionDtype] | dtype[Any] | ExtensionDtype`
+ pandas/io/parsers/arrow_parser_wrapper.py:201:32 error[unresolved-attribute] Attribute `get` is not defined on `dtype[Any]`, `ExtensionDtype` in union `(Unknown & ~None) | dict[Divergent, dtype[Any] | ExtensionDtype] | dtype[Any] | ExtensionDtype`
- pandas/io/parsers/c_parser_wrapper.py:392:33 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `object` on object of type `Top[dict[Unknown, Unknown]]`
pip (https://github.com/pypa/pip)
- src/pip/_vendor/dependency_groups/_implementation.py:149:56 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `object`
- src/pip/_vendor/pkg_resources/__init__.py:2840:21 error[invalid-assignment] Object of type `dict_items[object, object]` is not assignable to `Iterable[tuple[str | None, Iterable[str]]]`
+ src/pip/_vendor/pkg_resources/__init__.py:2840:21 error[invalid-assignment] Object of type `ItemsView[Unknown, Unknown] | dict_items[str, object]` is not assignable to `Iterable[tuple[str | None, Iterable[str]]]`
porcupine (https://github.com/Akuli/porcupine)
- porcupine/plugins/filetypes.py:33:49 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `object` on object of type `Top[dict[Unknown, Unknown]]`
- porcupine/plugins/filetypes.py:33:70 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `object` on object of type `Top[dict[Unknown, Unknown]]`
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/cli/events.py:198:9 error[invalid-argument-type] Argument is incorrect: Expected `list[RelatedResource]`, found `(list[Any & Top[dict[Unknown, Unknown]]] & ~AlwaysFalsy) | (Any & Top[list[Unknown]] & ~AlwaysFalsy) | list[Unknown]`
+ src/prefect/cli/events.py:198:9 error[invalid-argument-type] Argument is incorrect: Expected `list[RelatedResource]`, found `(list[(Any & Top[dict[Unknown, Unknown]]) | (Any & Top[TypedDict])] & ~AlwaysFalsy) | (Any & Top[list[Unknown]] & ~AlwaysFalsy) | list[Unknown]`
- src/prefect/utilities/templating.py:330:29 error[no-matching-overload] No overload of bound method `get` matches arguments
- src/prefect/utilities/templating.py:339:13 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `Unknown` on object of type `dict[str, Any]`
psycopg (https://github.com/psycopg/psycopg)
- psycopg/psycopg/errors.py:514:38 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `DiagnosticField`
pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_core_metadata.py:87:54 error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | ((dict[str, Divergent], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
- pydantic/fields.py:1575:13 error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`, found `dict[str, Divergent] | dict[Never, Never] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`
+ pydantic/fields.py:1575:13 error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`, found `dict[str, Divergent] | dict[Never, Never] | Top[TypedDict] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict]) | None`
- pydantic/json_schema.py:1693:13 error[no-matching-overload] No overload of bound method `update` matches arguments
pyjwt (https://github.com/jpadilla/pyjwt)
- jwt/jwks_client.py:145:35 error[invalid-argument-type] Argument to function `from_dict` is incorrect: Expected `dict[str, Any]`, found `(PyJWKSet & Top[dict[Unknown, Unknown]]) | (Any & Top[dict[Unknown, Unknown]])`
+ jwt/jwks_client.py:145:35 error[invalid-argument-type] Argument to function `from_dict` is incorrect: Expected `dict[str, Any]`, found `(PyJWKSet & Top[dict[Unknown, Unknown]]) | (Any & Top[dict[Unknown, Unknown]]) | (Any & Top[TypedDict])`
pyproject-metadata (https://github.com/pypa/pyproject-metadata)
- pyproject_metadata/project_table.py:276:16 error[no-matching-overload] No overload of bound method `fullmatch` matches arguments
- pyproject_metadata/project_table.py:358:51 error[invalid-argument-type] Argument to function `join` is incorrect: Expected `str`, found `object`
schema_salad (https://github.com/common-workflow-language/schema_salad)
- schema_salad/avro/schema.py:802:34 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | int | ... omitted 6 union elements`, found `object`
- schema_salad/avro/schema.py:804:44 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | int | ... omitted 6 union elements`, found `object`
- schema_salad/avro/schema.py:804:44 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["names"]` on object of type `Top[dict[Unknown, Unknown]]`
- schema_salad/avro/schema.py:806:64 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["name"]`
- schema_salad/avro/schema.py:808:25 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["type"]`
- schema_salad/avro/schema.py:809:57 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | int | ... omitted 6 union elements`, found `object`
- schema_salad/avro/schema.py:810:25 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["type"]`
- schema_salad/avro/schema.py:811:38 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | int | ... omitted 6 union elements`, found `object`
- schema_salad/avro/schema.py:811:58 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | int | ... omitted 6 union elements`, found `object`
- schema_salad/avro/schema.py:812:25 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["type"]`
- schema_salad/avro/schema.py:813:38 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | int | ... omitted 6 union elements`, found `object`
- schema_salad/avro/schema.py:813:59 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["symbols"]` on object of type `Top[dict[Unknown, Unknown]]`
- schema_salad/avro/schema.py:814:57 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["type"]`
- schema_salad/avro/schema.py:817:66 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["fields"]` on object of type `Top[dict[Unknown, Unknown]]`
schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/config/_diff_base.py:44:49 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `object` on object of type `Top[dict[Unknown, Unknown]]`
- src/schemathesis/config/_diff_base.py:64:33 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `object`
- src/schemathesis/openapi/checks.py:151:31 error[invalid-argument-type] Argument to function `unbundle` is incorrect: Expected `dict[str, Any] | bool | list[dict[str, Any] | bool]`, found `dict[Unknown, Unknown] | (Unresolvable & Top[dict[Unknown, Unknown]]) | bool | dict[str, Any] | dict[object, object]`
+ src/schemathesis/openapi/checks.py:151:31 error[invalid-argument-type] Argument to function `unbundle` is incorrect: Expected `dict[str, Any] | bool | list[dict[str, Any] | bool]`, found `dict[Unknown, Unknown] | (Unresolvable & Top[dict[Unknown, Unknown]]) | bool | dict[str, Any] | dict[Unknown | str, Unknown]`
- src/schemathesis/resources/repository.py:119:32 error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]]`
+ src/schemathesis/resources/repository.py:119:32 error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]] | Top[TypedDict]`
- src/schemathesis/specs/openapi/adapter/responses.py:398:16 error[invalid-return-type] Return type does not match returned value: expected `str | None`, found `object`
- src/schemathesis/specs/openapi/adapter/responses.py:411:16 error[invalid-return-type] Return type does not match returned value: expected `str | None`, found `object`
- src/schemathesis/specs/openapi/examples.py:745:70 error[unresolved-attribute] Object of type `object` has no attribute `lower`
- src/schemathesis/specs/openapi/examples.py:758:50 error[invalid-argument-type] Argument to function `_find_matching_in_responses` is incorrect: Expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]]`
+ src/schemathesis/specs/openapi/examples.py:758:50 error[invalid-argument-type] Argument to function `_find_matching_in_responses` is incorrect: Expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]] | Top[TypedDict]`
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/_vendor/pyproject_metadata/project_table.py:276:16 error[no-matching-overload] No overload of bound method `fullmatch` matches arguments
- src/scikit_build_core/_vendor/pyproject_metadata/project_table.py:311:21 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[dict[Unknown, Unknown]]`
- src/scikit_build_core/_vendor/pyproject_metadata/project_table.py:358:51 error[invalid-argument-type] Argument to function `join` is incorrect: Expected `str`, found `object`
- src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:90:12 error[invalid-return-type] Return type does not match returned value: expected `dict[str, str] | None`, found `Top[dict[Unknown, Unknown]]`
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:90:12 error[invalid-return-type] Return type does not match returned value: expected `dict[str, str] | None`, found `Top[dict[Unknown, Unknown]] | Top[TypedDict]`
- src/scikit_build_core/metadata/__init__.py:108:51 error[unresolved-attribute] Object of type `object` has no attribute `items`
- src/scikit_build_core/metadata/__init__.py:89:35 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `object`
- src/scikit_build_core/metadata/__init__.py:107:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[object, dict[str, str]]`
+ src/scikit_build_core/metadata/__init__.py:107:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[Unknown, dict[str, str]]`
- src/scikit_build_core/metadata/__init__.py:117:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[object, list[str]]`
+ src/scikit_build_core/metadata/__init__.py:117:16 error[invalid-return-type] Return type does not match returned value: expected `T@_process_dynamic_metadata`, found `dict[Unknown, list[str]]`
- src/scikit_build_core/metadata/__init__.py:117:40 error[not-iterable] Object of type `object` is not iterable
setuptools (https://github.com/pypa/setuptools)
- setuptools/_distutils/command/build_ext.py:430:38 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["include_dirs", "library_dirs", "libraries", "extra_objects", "extra_compile_args", "extra_link_args"]`
- setuptools/_distutils/command/build_ext.py:435:55 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["rpath"]`
- setuptools/_distutils/command/build_ext.py:441:37 error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Never`, found `Literal["macros"]`
+ setuptools/_distutils/command/build_ext.py:445:30 error[not-iterable] Object of type `~AlwaysFalsy` is not iterable
- setuptools/_distutils/command/build_ext.py:418:39 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["sources"]` on object of type `Top[dict[Unknown, Unknown]]`
sockeye (https://github.com/awslabs/sockeye)
- sockeye/inference.py:410:32 error[invalid-argument-type] Argument is incorrect: Expected `RestrictLexicon | None`, found `object`
spack (https://github.com/spack/spack)
- lib/spack/spack/vendor/jinja2/filters.py:219:50 error[invalid-assignment] Object of type `dict_items[object, object]` is not assignable to `Iterable[tuple[str, Any]]`
sympy (https://github.com/sympy/sympy)
- sympy/ntheory/tests/test_factor_.py:64:16 error[unsupported-operator] Operator `%` is not supported between objects of type `~AlwaysFalsy & ~Literal[1]` and `Literal[2]`
- sympy/physics/mechanics/lagrange.py:453:23 error[not-iterable] Object of type `(Unknown & ~Top[dict[Unknown, Unknown]]) | None` may not be iterable
+ sympy/physics/mechanics/lagrange.py:453:23 error[not-iterable] Object of type `(Unknown & ~Top[dict[Unknown, Unknown]] & ~Top[TypedDict]) | None` may not be iterable
- sympy/utilities/misc.py:465:24 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `object`
tornado (https://github.com/tornadoweb/tornado)
- tornado/gen.py:516:47 error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[None | Awaitable[Unknown] | list[Awaitable[Unknown]] | dict[Any, Awaitable[Unknown]] | Future[Unknown]]`, found `dict_values[object, object] | (Sequence[None | Awaitable[Unknown] | list[Awaitable[Unknown]] | dict[Any, Awaitable[Unknown]] | Future[Unknown]] & ~Top[dict[Unknown, Unknown]]) | (Mapping[Any, None | Awaitable[Unknown] | list[Awaitable[Unknown]] | dict[Any, Awaitable[Unknown]] | Future[Unknown]] & ~Top[dict[Unknown, Unknown]])`
urllib3 (https://github.com/urllib3/urllib3)
- src/urllib3/fields.py:281:24 error[invalid-assignment] Object of type `dict_items[object, object]` is not assignable to `Iterable[tuple[str, str | bytes | None]]`
vision (https://github.com/pytorch/vision)
- torchvision/transforms/v2/_utils.py:69:41 error[invalid-argument-type] Argument to function `_convert_fill_arg` is incorrect: Expected `int | float | Sequence[int | float] | None`, found `object`
xarray (https://github.com/pydata/xarray)
- xarray/core/dataarray.py:474:9 error[invalid-assignment] Object of type `(Sequence[Sequence[Unknown] | Index[Any] | DataArray | Variable | ndarray[tuple[Any, ...], dtype[Any]]] & Top[dict[Unknown, Unknown]]) | (Mapping[Unknown, Unknown] & Top[dict[Unknown, Unknown]]) | dict[Unknown, Variable]` is not assignable to attribute `_coords` of type `dict[Any, Variable]`
+ xarray/core/dataarray.py:474:9 error[invalid-assignment] Object of type `(Sequence[Sequence[Unknown] | Index[Any] | DataArray | Variable | ndarray[tuple[Any, ...], dtype[Any]]] & Top[dict[Unknown, Unknown]]) | (Mapping[Unknown, Unknown] & Top[dict[Unknown, Unknown]]) | (Mapping[Unknown, Unknown] & Top[TypedDict]) | dict[Unknown, Variable]` is not assignable to attribute `_coords` of type `dict[Any, Variable]`
xarray-dataclasses (https://github.com/astropenguin/xarray-dataclasses)
- xarray_dataclasses/dataarray.py:187:27 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> int, (index: slice[int | None, int | None, int | None], /) -> Sequence[int]]` cannot be called with key of type `str` on object of type `Sequence[int]`
- xarray_dataclasses/dataarray.py:187:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[dict[Unknown, Unknown]]`
zulip (https://github.com/zulip/zulip)
+ zerver/decorator.py:1063:9 error[invalid-assignment] Cannot assign to a subscript on an object of type `Top[TypedDict]`
- zerver/lib/event_schema.py:385:16 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["services"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/push_notifications.py:610:29 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["apple_devices"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/push_notifications.py:642:20 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["can_push"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/push_notifications.py:650:33 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["expected_end_timestamp"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:258:34 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:269:24 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `object` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:277:67 error[no-matching-overload] No overload of bound method `join` matches arguments
- zerver/lib/validator.py:434:19 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["widget_type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:444:12 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:483:8 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:494:8 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:507:8 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:518:58 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:526:8 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:549:8 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:469:56 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[dict[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/openapi/openapi.py:50:47 error[invalid-argument-type] Argument to function `naively_merge` is incorrect: Expected `dict[str, object]`, found `Top[dict[Unknown, Unknown]]`
+ zerver/openapi/openapi.py:50:47 error[invalid-argument-type] Argument to function `naively_merge` is incorrect: Expected `dict[str, object]`, found `Top[dict[Unknown, Unknown]] | Top[TypedDict]`
- zerver/openapi/openapi.py:71:63 error[invalid-argument-type] Argument to function `naively_merge_allOf_dict` is incorrect: Expected `dict[str, object]`, found `Top[dict[Unknown, Unknown]]`
+ zerver/openapi/openapi.py:71:63 error[invalid-argument-type] Argument to function `naively_merge_allOf_dict` is incorrect: Expected `dict[str, object]`, found `Top[dict[Unknown, Unknown]] | Top[TypedDict]`6490850 to
f2f91f3
Compare
cde374a to
3fa7514
Compare
3fa7514 to
cbe8a82
Compare
47d3fc6 to
aa5ab5e
Compare
Summary
This PR implements a
TypedDictToptype that is a supertype of allTypedDicttypes, and treated as assignable toMapping[str, object].With this type,
isinstance(x, dict)andisinstance(x, MutableMapping)now generate a constraint that includesTypedDictTop, e.g.,Top[dict[Unknown, Unknown]] | TypedDictTop.Closes astral-sh/ty#1130.
Closes astral-sh/ty#2374.