Skip to content

[ty] Gradual isinstance narrowing for generic classes - #27308

Merged
sharkdp merged 35 commits into
mainfrom
david/isinstance-filtering
Aug 6, 2026
Merged

[ty] Gradual isinstance narrowing for generic classes#27308
sharkdp merged 35 commits into
mainfrom
david/isinstance-filtering

Conversation

@sharkdp

@sharkdp sharkdp commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces a new ty.analysis.strict-generic-narrowing option that controls how isinstance and issubclass narrowing works for unspecialized generic classes. When this option is set to true, we use the top materialization of the generic class (e.g. Top[list[Unknown]]). This is the current behavior on main and the sound way to do isinstance narrowing with generic classes. When the option is set to false (the new default), we switch to an unsound mode that is intended to help users migrate from other type checkers.

In this non-strict mode, we intersect with the Unknown-specialization of the generic class. For example, x: object is narrowed to object & list[Unknown] = list[Unknown] after isinstance(x, list). If the type of x already contains a specialization of list, or a generic base of list, we narrow to the corresponding list specialization instead. For example, x: Sequence[int] is narrowed to list[int], and x: Mapping[str, int] is narrowed to dict[str, int] after isinstance(x, dict).

We also add a special case for TypedDicts here: When starting from a TypedDict type, and narrowing via isinstance(.., dict) (or Mapping, MutableMapping, ..), we simply preserve the previous TypedDict type.

We also apply those settings to class patterns in match statements, resolving this comment: astral-sh/ty#3676 (comment)

strict-generic-narrowing = true (current behavior on main)

def f(xs: object):
    if isinstance(xs, list):
        reveal_type(xs)  # Top[list[Unknown]]
        for x in xs:
            reveal_type(x)  # object

        xs.append(1)  # error!

def g(xs: Sequence[int]):
    if isinstance(xs, list):
        reveal_type(xs)  # Sequence[int] & Top[list[Unknown]] = Top[list[int & Unknown]]

strict-generic-narrowing = false (gradual / non-strict, new default behavior)

def f(xs: object):
    if isinstance(xs, list):
        reveal_type(xs)  # list[Unknown]
        for x in xs:
            reveal_type(x)  # Unknown

        xs.append(1)  # okay

def g(xs: Sequence[int]):
    if isinstance(xs, list):
        reveal_type(xs)  # list[int]

closes astral-sh/ty#3476 (basically asks for exactly this feature)
closes astral-sh/ty#3890 (we support all of these use cases as intended by the user)
closes astral-sh/ty#3676 (in the new default mode, the original use case is supported, in strict mode, we need to implement the intersection simplifications which are tracked in astral-sh/ty#1824)
closes astral-sh/ty#2843 (we support the original use case now. we could keep this issue open if we really want to support this in strict mode as well?)
closes astral-sh/ty#3477 (already closed, but directly asks for a mode like this)

also related: astral-sh/ty#1130 (we have special handling for TypedDicts here, but we probably still want to solve this for strict mode)

Previously considered alternatives

  • [ty] Relaxed isinstance/issubclass narrowing using gradual intersections #26472 Intersecting with the gradual Unknown specialization. The problem here was that this introduces too much graduality. When starting from a fully static type like Sequence[int], we would get Sequence[int] & Sequence[Unknown] = Sequence[int & Unknown] after an isinstance(..., Sequence) check. Iterating over that type would yield elements of type int & Unknown, which is too permissive.
  • [ty] Relaxed isinstance narrowing using transient top materializations #26797 Intersecting with transient top materializations. The idea here was to still intersect with Top[C[Unknown]], but then remove that Top materialization after the intersection type had been simplified. This solved the problem with Sequence[..] above, because now we created the intersection type Sequence[int] & Top[Sequence[Unknown]] = Sequence[int] & Sequence[object] = Sequence[int & object] = Sequence[int] which was still fully static. However, this still caused problems when invariant generics were involved. For example, starting with Sequence[int] and narrowing using isinstance(.., list) would lead to Sequence[int] & Top[list[Unknown]]. We showed that this type is equivalent to Top[list[int & Unknown]], but that didn't solve the problem that iterating over that type after removing the Top materialization still yielded elements of type int & Unknown.
  • [ty] Experiment: Relaxed isinstance narrowing using tagged object/Never types #26848 isinstance narrowing using tagged object/Never types. This approach followed the suggestion in Specially marked top/bottom types for better TypeIs narrowing experience ty#3375. The idea was to create types that act like object/Never in intersection simplification, but like Unknown elsewhere. One problem was that this didn't really address the problem of invariant generics. For those, we were still forced to use a special Top*[..] materialization that would tell us: this type came from a non-strict isinstance narrowing and it should produce object*/Never* types when methods/attributes are accessed on this type. So for the Sequence[int] / isinstance(.., list) example, we would still create Sequence[int] & Top*[list[Unknown]], but the advantage was that we now created the intersection int & object* when iterating over that type. Since this simplified to int, it seemed like the problem from above was solved. However, introducing those two magical types didn't feel very satisfactory. And we still didn't match the behavior of other type checkers. When narrowing from object using isinstance(..., list), we would create Top*[list[Unknown]], whereas other type checkers simply inferred list[Unknown]. And there were also more subtle problems where merging a type like object* with another type in a control-flow join would create object* | Other = object* and therefore lose precision.

Test plan

New and updated Markdown tests

Ecosystem

Looks good. There are some cases where TypedDict types "survive" a negative isinstance(.., dict) check, but I think that's astral-sh/ty#1130. Gradual mode doesn't do anything differently in negative branches.

PR_27308_ECOSYSTEM_SUMMARY.md (the egglog case was resolved since then)

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jul 29, 2026
@sharkdp sharkdp changed the title [ty] Experiment: Relaxed narrowing using specialization filtering [ty] Experiment: Relaxed isinstance narrowing using specialization filtering Jul 29, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 96.96%. The percentage of expected errors that received a diagnostic held steady at 92.77%. The number of fully passing files held steady at 105/133.

@astral-sh-bot

astral-sh-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
prefect 667.29MB 667.79MB +0.07% (511.57kB)
sphinx 208.16MB 208.33MB +0.09% (183.17kB)
trio 94.53MB 94.64MB +0.12% (118.00kB)
flake8 40.42MB 40.42MB +0.01% (4.62kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 6.91MB 7.42MB +7.36% (521.36kB)
infer_expression_types_impl 47.07MB 47.16MB +0.20% (94.93kB)
intersection_from_two_elements 643.45kB 676.97kB +5.21% (33.52kB)
Type<'db>::class_member_with_policy_inner_ 12.52MB 12.50MB -0.16% (20.58kB) ⬇️
infer_scope_types_impl 35.99MB 36.01MB +0.05% (18.01kB)
Type<'db>::apply_specialization_inner_::interned_arguments 7.31MB 7.30MB -0.23% (17.34kB) ⬇️
infer_definition_types 60.43MB 60.42MB -0.03% (16.30kB) ⬇️
Type<'db>::apply_specialization_inner_ 4.91MB 4.90MB -0.32% (16.30kB) ⬇️
check_file_impl 12.45MB 12.44MB -0.11% (14.25kB) ⬇️
MemberLookupKey 9.96MB 9.95MB -0.13% (13.05kB) ⬇️
member_lookup_with_policy_and_receiver_inner 320.34kB 310.80kB -2.98% (9.54kB) ⬇️
FunctionType 9.64MB 9.63MB -0.10% (9.44kB) ⬇️
when_constraint_set_assignable_to_owned_impl 6.95MB 6.96MB +0.13% (9.27kB)
member_lookup_with_policy_inner 14.55MB 14.54MB -0.06% (8.87kB) ⬇️
specialization_inner 629.33kB 623.63kB -0.90% (5.70kB) ⬇️
... 70 more

sphinx

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 2.44MB 2.61MB +6.82% (170.63kB)
infer_expression_types_impl 16.82MB 16.83MB +0.04% (7.36kB)
intersection_from_two_elements 251.71kB 257.80kB +2.42% (6.09kB)
Type<'db>::apply_specialization_inner_::interned_arguments 2.03MB 2.02MB -0.25% (5.16kB) ⬇️
Type<'db>::apply_specialization_inner_ 1.29MB 1.28MB -0.27% (3.50kB) ⬇️
StaticClassLiteral<'db>::try_mro_ 2.18MB 2.18MB +0.15% (3.29kB)
infer_scope_types_impl 8.42MB 8.42MB +0.03% (3.01kB)
infer_definition_types 14.06MB 14.07MB +0.01% (2.02kB)
UnionType 806.44kB 808.12kB +0.21% (1.69kB)
TypeVarInference 413.45kB 411.91kB -0.37% (1.55kB) ⬇️
GenericAlias 809.72kB 811.20kB +0.18% (1.48kB)
when_constraint_set_assignable_to_owned_impl 1.64MB 1.64MB +0.08% (1.26kB)
TypePair 2.72MB 2.72MB -0.04% (1.22kB) ⬇️
MemberLookupKey 3.43MB 3.42MB -0.03% (1.12kB) ⬇️
StaticClassLiteral<'db>::try_mro_::interned_arguments 721.12kB 722.11kB +0.14% (1008.00B)
... 50 more

trio

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 597.09kB 642.02kB +7.52% (44.92kB)
CallableType 1.41MB 1.42MB +0.43% (6.22kB)
TypePair 964.22kB 969.84kB +0.58% (5.62kB)
infer_expression_types_impl 5.32MB 5.32MB +0.09% (4.69kB)
when_constraint_set_assignable_to_owned_impl 971.90kB 976.25kB +0.45% (4.35kB)
intersection_from_two_elements 67.15kB 71.02kB +5.77% (3.88kB)
IntersectionType 274.46kB 277.95kB +1.27% (3.49kB)
infer_definition_types 4.50MB 4.51MB +0.07% (3.41kB)
is_redundant_with_impl 323.61kB 326.69kB +0.95% (3.08kB)
Type<'db>::class_member_with_policy_inner_ 1.17MB 1.17MB +0.25% (2.95kB)
FunctionType 1.25MB 1.25MB +0.23% (2.95kB)
StaticClassLiteral<'db>::try_mro_ 928.94kB 931.49kB +0.28% (2.55kB)
MemberLookupKey 1.15MB 1.15MB +0.22% (2.54kB)
Type<'db>::apply_specialization_inner_::interned_arguments 1.19MB 1.20MB +0.20% (2.50kB)
Specialization 1.03MB 1.03MB +0.24% (2.48kB)
... 55 more

flake8

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 99.60kB 106.52kB +6.94% (6.91kB)
TypePair 233.53kB 233.06kB -0.20% (480.00B) ⬇️
Type<'db>::apply_specialization_inner_::interned_arguments 221.09kB 220.70kB -0.18% (400.00B) ⬇️
when_constraint_set_assignable_to_owned_impl 164.34kB 164.73kB +0.24% (400.00B)
FunctionType 314.05kB 313.77kB -0.09% (288.00B) ⬇️
Type<'db>::apply_specialization_inner_ 139.73kB 139.49kB -0.17% (248.00B) ⬇️
Type<'db>::class_member_with_policy_inner_ 263.81kB 263.57kB -0.09% (248.00B) ⬇️
MemberLookupKey 278.74kB 278.54kB -0.07% (208.00B) ⬇️
IntersectionType 70.07kB 69.88kB -0.28% (200.00B) ⬇️
member_lookup_with_policy_inner 324.35kB 324.18kB -0.05% (176.00B) ⬇️
assignable_solutions_impl 14.50kB 14.67kB +1.19% (176.00B)
BoundMethodType 67.81kB 67.66kB -0.23% (160.00B) ⬇️
Type<'db>::cached_materialization_::interned_arguments 68.12kB 67.97kB -0.23% (160.00B) ⬇️
infer_expression_types_impl 768.50kB 768.63kB +0.02% (136.00B)
FunctionType<'db>::signature_ 352.76kB 352.64kB -0.03% (120.00B) ⬇️
... 12 more

@astral-sh-bot

astral-sh-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 8 1,037 100
invalid-assignment 1 222 37
unresolved-attribute 7 109 36
invalid-return-type 1 115 27
no-matching-overload 1 87 0
invalid-key 2 0 53
unsupported-operator 0 46 2
not-subscriptable 0 39 1
not-iterable 0 15 3
call-non-callable 2 10 1
invalid-yield 0 10 2
redundant-cast 4 7 0
unused-ignore-comment 5 0 0
unused-type-ignore-comment 3 2 0
invalid-type-form 0 0 2
call-top-callable 0 1 0
unknown-argument 0 1 0
Total 34 1,701 264

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Showing a random sample of 227 of 1999 changes. See the HTML report for the full diff.

Raw diff sample (227 of 1999 changes)
Expression (https://github.com/cognitedata/Expression)
- expression/collections/maptree.py:113:25 error[invalid-argument-type] Argument to function `mk` is incorrect: Expected `Option[MapTreeLeaf[Top[SupportsLessThan] | Unknown, object]]`, found `Option[MapTreeLeaf[Key@rebalance, Value@rebalance]]`
- expression/collections/maptree.py:121:27 error[invalid-argument-type] Argument to function `mk` is incorrect: Expected `Option[MapTreeLeaf[Top[SupportsLessThan] | Unknown, object]]`, found `Option[MapTreeLeaf[Key@rebalance, Value@rebalance]]`
- expression/collections/maptree.py:132:32 error[invalid-return-type] Return type does not match returned value: expected `Option[MapTreeLeaf[Key@rebalance, Value@rebalance]]`, found `Option[MapTreeLeaf[Unknown | Top[SupportsLessThan], object]]`
- expression/collections/maptree.py:141:61 error[invalid-argument-type] Argument to function `mk` is incorrect: Expected `Option[MapTreeLeaf[Unknown | Top[SupportsLessThan], object]]`, found `Option[MapTreeLeaf[Key@rebalance, Value@rebalance]]`
- expression/core/fn.py:58:23 warning[redundant-cast] Value is already of type `TailCall[_P@tailrec_async]`

PyGithub (https://github.com/PyGithub/PyGithub)
+ github/AdvisoryCredit.py:122:26 error[unresolved-attribute] Attribute `login` is not defined on `SimpleCredit & ~Top[dict[Unknown, Unknown]]` in union `(SimpleCredit & ~Top[dict[Unknown, Unknown]]) | (AdvisoryCredit & ~Top[dict[Unknown, Unknown]])`
+ github/AdvisoryCredit.py:123:25 error[unresolved-attribute] Attribute `type` is not defined on `SimpleCredit & ~Top[dict[Unknown, Unknown]]` in union `(SimpleCredit & ~Top[dict[Unknown, Unknown]]) | (AdvisoryCredit & ~Top[dict[Unknown, Unknown]])`
- github/AdvisoryVulnerability.py:129:59 error[invalid-assignment] Object of type `object` is not assignable to `SimpleAdvisoryVulnerabilityPackage`

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/commands/slash.py:1785:30 error[not-iterable] Object of type `Sequence[((int, /, *args: Any, **kwargs: Any) -> Coroutine[Any, Any, Any] | Any) | ((str, /, *args: Any, **kwargs: Any) -> Coroutine[Any, Any, Any] | Any)] | ((int, /, *args: Any, **kwargs: Any) -> Coroutine[Any, Any, Any] | Any) | ((str, /, *args: Any, **kwargs: Any) -> Coroutine[Any, Any, Any] | Any)` may not be iterable
- tanjun/commands/slash.py:1795:63 error[invalid-argument-type] Argument is incorrect: Expected `str | float`, found `object`
- tanjun/commands/slash.py:2078:97 error[invalid-assignment] Object of type `None | Mapping[str, str] | (Sequence[str] & Top[Mapping[Unknown, object]]) | (Sequence[tuple[str, str]] & Top[Mapping[Unknown, object]]) | (Sequence[CommandChoice] & Top[Mapping[Unknown, object]])` is not assignable to `Mapping[str, str] | list[CommandChoice] | None`

aiohttp (https://github.com/aio-libs/aiohttp)
- aiohttp/client.py:1225:37 error[invalid-argument-type] Argument to bound method `MultiDict.add` is incorrect: Expected `str`, found `object`
- aiohttp/cookiejar.py:345:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Morsel[str].__getitem__(key: str, /) -> Any` cannot be called with key of type `Literal[-1]` on object of type `Morsel[str]`
- aiohttp/cookiejar.py:355:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Morsel[str].__getitem__(key: str, /) -> Any` cannot be called with key of type `Literal[0]` on object of type `Morsel[str]`
- aiohttp/cookiejar.py:374:20 error[unresolved-attribute] Attribute `rstrip` is not defined on `Morsel[str] & ~AlwaysFalsy` in union `(Morsel[str] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | str`

altair (https://github.com/vega/altair)
+ altair/vegalite/v6/api.py:2506:34 warning[unused-ignore-comment] Unused blanket `ty: ignore` directive
+ altair/vegalite/v6/api.py:3102:70 warning[unused-ignore-comment] Unused blanket `ty: ignore` directive
+ altair/vegalite/v6/api.py:3790:56 warning[unused-ignore-comment] Unused blanket `ty: ignore` directive

anyio (https://github.com/agronholm/anyio)
- src/anyio/_backends/_trio.py:115:20 error[invalid-return-type] Return type does not match returned value: expected `Coroutine[Any, Any, T_Retval@ensure_returns_coro]`, found `Awaitable[T_Retval@ensure_returns_coro] & Coroutine[object, Never, object]`
- src/anyio/_core/_sockets.py:994:38 error[invalid-argument-type] Argument is incorrect: Expected `str | IPv4Address | IPv6Address`, found `object`

apprise (https://github.com/caronc/apprise)
- apprise/config/base.py:1255:29 error[no-matching-overload] No overload of bound method `MutableMapping.update` matches arguments

archinstall (https://github.com/archlinux/archinstall)
- archinstall/tui/components.py:1320:29 error[invalid-assignment] Object of type `object` is not assignable to `ValueT@_AppInstance | None`

artigraph (https://github.com/artigraph/artigraph)
- src/arti/storage/_internal.py:146:9 error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `object` on object of type `dict[str, str]`

black (https://github.com/psf/black)
- src/black/ranges.py:508:26 error[invalid-argument-type] Argument to function `last_leaf` is incorrect: Expected `Leaf | Node`, found `object`

bokeh (https://github.com/bokeh/bokeh)
- src/bokeh/util/datatypes.py:89:13 warning[redundant-cast] Value is already of type `set[V@MultiValuedDict]`
- src/bokeh/util/datatypes.py:111:24 warning[redundant-cast] Value is already of type `set[V@MultiValuedDict]`
- 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:260:18 error[invalid-assignment] Object of type `list[object]` is not assignable to `Model | Sequence[Model] | dict[str, Model]`
- src/bokeh/plotting/contour.py:305:41 error[invalid-argument-type] Argument to function `_palette_from_collection` is incorrect: Expected `PaletteCollection`, found `(Sequence[ColorLike] & Top[dict[Unknown, Unknown]]) | (Color & Top[dict[Unknown, Unknown]]) | dict[int, Palette]`

cloud-init (https://github.com/canonical/cloud-init)
- cloudinit/distros/gentoo.py:141:19 error[invalid-argument-type] Argument to function `subp` is incorrect: Expected `str | bytes | list[str] | list[bytes]`, found `list[object]`

core (https://github.com/home-assistant/core)
- homeassistant/helpers/integration_platform.py:366:30 error[invalid-assignment] Object of type `object` is not assignable to `_R@LazyIntegrationPlatforms | None`
- homeassistant/components/rest/data.py:51:44 error[invalid-argument-type] Argument to constructor `BasicAuth.__new__` is incorrect: Expected `str`, found `object`

cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/builder.py:240:58 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["name"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/builder.py:273:21 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/builder.py:276:17 error[invalid-assignment] Cannot assign to a subscript on an object of type `int`
- cwltool/builder.py:279:21 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- cwltool/builder.py:670:24 error[invalid-return-type] Return type does not match returned value: expected `float | str | CWLFileType | ... omitted 4 union elements`, found `dict[object, float | str | CWLFileType | ... omitted 4 union elements]`
- cwltool/checker.py:115:12 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:123:12 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:133:43 error[invalid-key] Unknown key "type" for TypedDict `CWLDirectoryType` (subscripted object has type `(int & Top[MutableMapping[Unknown, Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]]) | (float* & Top[MutableMapping[Unknown, Unknown]]) | ... omitted 5 union elements`)
+ cwltool/checker.py:133:43 error[invalid-key] Unknown key "type" for TypedDict `CWLDirectoryType` (subscripted object has type `(int & MutableMapping[Unknown, Unknown]) | (str & MutableMapping[Unknown, Unknown]) | (float* & MutableMapping[Unknown, Unknown]) | ... omitted 5 union elements`)
- cwltool/checker.py:133:57 error[invalid-key] Unknown key "type" for TypedDict `CWLDirectoryType` (subscripted object has type `(int & Top[MutableMapping[Unknown, Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]]) | (float* & Top[MutableMapping[Unknown, Unknown]]) | ... omitted 5 union elements`)
+ cwltool/checker.py:133:57 error[invalid-key] Unknown key "type" for TypedDict `CWLDirectoryType` (subscripted object has type `(int & MutableMapping[Unknown, Unknown]) | (str & MutableMapping[Unknown, Unknown]) | (float* & MutableMapping[Unknown, Unknown]) | ... omitted 5 union elements`)
- cwltool/checker.py:133:39 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:133:39 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:133:39 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:133:52 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/command_line_tool.py:645:33 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["writable"]` and value of type `object` on object of type `MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements]`
- cwltool/command_line_tool.py:1571:17 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["type"]` on object of type `MutableSequence[Divergent]`
- cwltool/command_line_tool.py:1571:17 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/command_line_tool.py:1574:52 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["fields"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/load_tool.py:178:33 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["stdout", "stderr"]` and value of type `str` on object of type `MutableSequence[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements] | str | int]`
- cwltool/load_tool.py:337:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/load_tool.py:233:13 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements] | str, (index: slice[int | None, int | None, int | None], /) -> MutableSequence[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements] | str]]` cannot be called with key of type `Literal["run"]` on object of type `MutableSequence[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements] | str]`
- cwltool/main.py:199:32 error[invalid-argument-type] Argument to bound method `MutableSequence.remove` is incorrect: Expected `Never`, found `Literal["null"]`
- cwltool/main.py:212:63 error[invalid-argument-type] Argument to function `generate_example_input` is incorrect: Expected `float | str | CWLFileType | ... omitted 4 union elements`, found `object`
- cwltool/main.py:296:27 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/main.py:300:74 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/main.py:304:27 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `Literal["type"]` on object of type `str`
- cwltool/main.py:305:17 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- cwltool/main.py:307:63 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/main.py:310:25 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `Literal["items"]` on object of type `str`
- cwltool/main.py:310:85 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `Literal["items"]` on object of type `str`
- cwltool/main.py:319:17 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- cwltool/main.py:405:12 error[invalid-return-type] Return type does not match returned value: expected `tuple[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements] | None, str, Loader]`, found `tuple[None | (int & Top[MutableMapping[Unknown, Unknown]]) | (float* & Top[MutableMapping[Unknown, Unknown]]) | ... omitted 3 union elements, Unknown | str, Loader]`
- cwltool/pack.py:30:38 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["run"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:30:38 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `Literal["run"]` on object of type `str`
+ cwltool/pack.py:106:88 error[invalid-key] TypedDict `CWLDirectoryType` can only be subscripted with a string literal key, got key of type `str`
- cwltool/pack.py:47:38 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["id"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:47:38 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["id"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:48:35 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["name"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:48:35 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["name"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:93:31 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["name"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:94:39 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["id"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/process.py:448:17 error[invalid-assignment] Invalid subscript assignment with key of type `int` and value of type `MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements] | MutableSequence[Any] | float | ... omitted 6 union elements` on object of type `MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements]`
- cwltool/process.py:1095:58 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["requirements"]` on object of type `MutableSequence[Divergent]`
- cwltool/process.py:1095:58 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements], (index: slice[int | None, int | None, int | None], /) -> MutableSequence[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements]]]` cannot be called with key of type `Literal["requirements"]` on object of type `MutableSequence[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements]]`
- cwltool/process.py:1095:58 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["requirements"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/process.py:1097:37 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements], (index: slice[int | None, int | None, int | None], /) -> MutableSequence[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements]]]` cannot be called with key of type `Literal["requirements"]` on object of type `MutableSequence[MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements]]`
- cwltool/secrets.py:64:39 error[invalid-argument-type] Argument to bound method `SecretStore.retrieve` is incorrect: Expected `float | str | CWLFileType | ... omitted 3 union elements`, found `object`
- cwltool/utils.py:195:13 error[invalid-assignment] Invalid subscript assignment with key of type `str | Any` and value of type `str | MutableSequence[Any] | MutableMapping[str, Any]` on object of type `MutableSequence[Any]`
- cwltool/workflow_job.py:335:28 error[invalid-argument-type] Argument to function `match_types` is incorrect: Expected `float | str | CWLFileType | ... omitted 5 union elements`, found `object`
- cwltool/workflow_job.py:342:13 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["type"]` and value of type `object` on object of type `MutableMapping[str, float | str | CWLFileType | ... omitted 4 union elements]`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- scripts/view_trace_snapshot.py:24:16 error[invalid-return-type] Return type does not match returned value: expected `list[list[dict[str, object]]]`, found `Top[list[Unknown]] & ~AlwaysFalsy`
- ddtrace/appsec/_api_security/_normalized_route.py:1083:61 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Any, (index: slice[int | None, int | None, int | None], /) -> Sequence[Any]]` cannot be called with key of type `object` on object of type `Sequence[Any]`
- ddtrace/appsec/_api_security/_normalized_route.py:1083:61 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 `object` on object of type `Top[Mapping[Unknown, object]]`

discord.py (https://github.com/Rapptz/discord.py)
- discord/channel.py:1275:31 error[unresolved-attribute] Object of type `object` has no attribute `id`
- discord/ext/commands/cog.py:527:13 error[unresolved-attribute] Unresolved attribute `__cog_listener__` on type `(...) -> Coroutine[Any, Any, Any]`
+ discord/ext/commands/cog.py:527:13 error[unresolved-attribute] Unresolved attribute `__cog_listener__` on type `(...) -> Unknown`
- discord/utils.py:1047:19 error[invalid-yield] Yield type `list[object]` does not match annotated yield type `list[T@_chunk]`

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/types/relations.py:3222:28 error[invalid-argument-type] Method `__getitem__` of type `bound method Schema.__getitem__(name: str) -> DataType` cannot be called with key of type `object` on object of type `Schema`

jax (https://github.com/google/jax)
- jax/_src/numpy/lax_numpy.py:4983:37 error[invalid-argument-type] Argument to function `_block` is incorrect: Expected `Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | ... omitted 3 union elements`, found `object`

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]]`
+ src/jinja2/filters.py:169:48 error[invalid-assignment] Object of type `dict_items[str, Any] | dict_items[tuple[str, Any], Unknown]` is not assignable to `Iterable[tuple[str, Any]]`
- src/jinja2/parser.py:1024:37 error[invalid-argument-type] Argument to bound method `list.extend` is incorrect: Expected `Iterable[Node]`, found `(Node & Top[list[Unknown]]) | list[Node]`

koda-validate (https://github.com/keithasaurus/koda-validate)
- koda_validate/_internal.py:214:24 error[invalid-return-type] Return type does not match returned value: expected `tuple[Literal[True], A@_union_validator] | tuple[Literal[False], Invalid]`, found `tuple[Literal[True], object]`
+ koda_validate/_internal.py:214:24 error[invalid-return-type] Return type does not match returned value: expected `tuple[Literal[True], A@_union_validator] | tuple[Literal[False], Invalid]`, found `tuple[Literal[True], Any | Invalid]`
- koda_validate/serialization/json_schema.py:334:17 error[invalid-return-type] Return type does not match returned value: expected `dict[str, None | float | str | ... omitted 3 union elements]`, found `dict[str, None | float | str | ... omitted 5 union elements]`
- koda_validate/serialization/json_schema.py:362:17 error[invalid-return-type] Return type does not match returned value: expected `dict[str, None | float | str | ... omitted 3 union elements]`, found `dict[str, None | float | str | ... omitted 5 union elements]`

kopf (https://github.com/nolar/kopf)
- kopf/_cogs/structs/patches.py:159:45 error[invalid-argument-type] Argument to bound method `Patch._apply_patch` is incorrect: Expected `tuple[str, ...]`, found `tuple[object, ...]`
- kopf/_kits/hierarchies.py:44:24 error[no-matching-overload] No overload of bound method `MutableMapping.setdefault` matches arguments
- kopf/_kits/hierarchies.py:215:38 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["metadata"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/feature_benchmark/benchmark.py:157:17 error[unresolved-attribute] Attribute `run` is not defined on `None` in union `None | Action`

meson (https://github.com/mesonbuild/meson)
- mesonbuild/cargo/manifest.py:766:40 error[no-matching-overload] No overload of function `normpath` matches arguments
- mesonbuild/cmake/interpreter.py:1048:40 error[invalid-argument-type] Argument to function `nodeify` is incorrect: Expected `Sequence[str | int | Path | BaseNode] | int | Path | BaseNode`, found `~None`
- mesonbuild/interpreterbase/decorators.py:780:64 error[invalid-argument-type] Argument to function `version_compare_condition_with_min` is incorrect: Expected `str | Range[Version]`, found `Range[Version] | (NoProjectVersion & Top[Range[Unknown]])`
- mesonbuild/options.py:343:16 error[invalid-return-type] Return type does not match returned value: expected `str | int | list[str]`, found `(_T@UserOption & str) | (_T@UserOption & int) | (_T@UserOption & Top[list[Unknown]])`

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- pymongo/helpers_shared.py:189:21 error[invalid-argument-type] Method `__getitem__` of type `bound method Mapping[str, Any].__getitem__(key: str, /) -> Any` cannot be called with key of type `tuple[str, int | str | Mapping[str, Any]]` on object of type `Mapping[str, Any]`
- pymongo/helpers_shared.py:189:21 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 `tuple[str, int | str | Mapping[str, Any]]` on object of type `Top[Mapping[Unknown, object]]`

mypy (https://github.com/python/mypy)
- mypy/test/test_diff_cache.py:127:42 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["/c."]` and `object`
- mypy/test/test_diff_cache.py:128:42 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["/a."]` and `object`
- mypy/test/test_diff_cache.py:128:56 error[unresolved-attribute] Object of type `object` has no attribute `startswith`

optuna (https://github.com/optuna/optuna)
- optuna/study/study.py:520:13 error[invalid-argument-type] Argument to function `_optimize` is incorrect: Expected `tuple[type[Exception], ...]`, found `tuple[object, ...]`

packaging (https://github.com/pypa/packaging)
- src/packaging/specifiers.py:925:17 error[invalid-assignment] Object of type `tuple[object, ...]` is not assignable to attribute `_specs` of type `tuple[Specifier, ...]`
- src/packaging/tags.py:164:16 error[invalid-return-type] Return type does not match returned value: expected `str`, found `object`
- src/packaging/tags.py:171:16 error[invalid-return-type] Return type does not match returned value: expected `str`, found `object`
- src/packaging/tags.py:203:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[str, str, str]`, found `tuple[object, object, object]`
- src/packaging/version.py:827:29 error[unresolved-attribute] Object of type `~None` has no attribute `pre`

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/arrays/_mixins.py:213:16 error[no-matching-overload] No overload of function `maybe_convert_objects` matches arguments
- pandas/core/arrays/datetimelike.py:665:21 error[no-matching-overload] No overload of function `maybe_convert_objects` matches arguments
- pandas/core/indexes/multi.py:4838:59 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `object`
- pandas/core/reshape/concat.py:832:17 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 `object` on object of type `Top[Mapping[Unknown, object]]`
+ pandas/core/reshape/concat.py:832:17 error[invalid-argument-type] Method `__getitem__` of type `bound method Mapping[Series | DataFrame, Unknown].__getitem__(key: Series | DataFrame, /) -> Unknown` cannot be called with key of type `HashableT@_clean_keys_and_objs` on object of type `Mapping[Series | DataFrame, Unknown]`
- pandas/io/excel/_base.py:868:21 error[unsupported-operator] Operator `+=` is not supported between objects of type `object` and `int`
- pandas/io/formats/printing.py:282:13 error[no-matching-overload] No overload of bound method `MutableMapping.update` matches arguments
- pandas/io/parsers/python_parser.py:138:13 error[invalid-assignment] Object of type `(ReadCsvBuffer[str] & Top[list[Unknown]]) | list[Unknown]` is not assignable to attribute `data` of type `Iterator[list[str]] | list[list[str | bytes | date | ... omitted 8 union elements]]`
- pandas/io/parsers/python_parser.py:879:45 error[invalid-argument-type] Argument to bound method `PythonParser._is_line_empty` is incorrect: Expected `Sequence[str | bytes | date | ... omitted 8 union elements]`, found `object`
- pandas/io/stata.py:2933:21 error[invalid-argument-type] Argument to function `isfile` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `str | PathLike[str] | (WriteBuffer[bytes] & Top[PathLike[Unknown]])`

pip (https://github.com/pypa/pip)
- src/pip/_internal/network/utils.py:120:41 error[invalid-assignment] Object of type `object` is not assignable to `float | None`
- src/pip/_vendor/packaging/specifiers.py:925:17 error[invalid-assignment] Object of type `tuple[object, ...]` is not assignable to attribute `_specs` of type `tuple[Specifier, ...]`
- src/pip/_vendor/cachecontrol/controller.py:443:21 error[invalid-argument-type] Argument to bound method `CacheController._cache_set` is incorrect: Expected `HTTPResponse`, found `~None`
- src/pip/_vendor/packaging/version.py:804: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:817: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:828:30 error[unresolved-attribute] Object of type `~None` has no attribute `post`
- 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]]]`

ppb-vector (https://github.com/ppb/ppb-vector)
- 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]]`

psycopg (https://github.com/psycopg/psycopg)
- psycopg/psycopg/types/enum.py:231:30 error[not-iterable] Object of type `E@_make_load_map` is not iterable
- psycopg/psycopg/types/enum.py:249:30 error[not-iterable] Object of type `E@_make_dump_map` is not iterable

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/aglib/heap/ptmalloc.py:271:28 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Value | None | int`
+ pwndbg/aglib/heap/ptmalloc.py:271:28 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Value | None | Unknown`
- pwndbg/aglib/heap/ptmalloc.py:452:17 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Value | None`
+ pwndbg/aglib/heap/ptmalloc.py:452:17 error[invalid-argument-type] Argument to constructor `int.__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Value | None | Unknown`
- pwndbg/commands/__init__.py:420:33 error[unresolved-attribute] Object of type `object` has no attribute `prog`
- pwndbg/commands/ptmalloc2.py:54:15 error[call-non-callable] Object of type `Type` is not callable
- pwndbg/commands/ptmalloc2.py:466:11 error[unresolved-attribute] Attribute `value_to_human_readable` is not defined on `None` in union `Value | CStruct2GDB | None`
+ pwndbg/commands/ptmalloc2.py:466:11 error[unresolved-attribute] Attribute `value_to_human_readable` is not defined on `None` in union `Unknown | None`
- pwndbg/commands/ptmalloc2.py:1391:31 error[unresolved-attribute] Attribute `address` is not defined on `None` in union `Value | CStruct2GDB | None`
+ pwndbg/commands/ptmalloc2.py:1391:31 error[unresolved-attribute] Attribute `address` is not defined on `None` in union `Unknown | None`

pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/mark/structures.py:464:37 error[invalid-argument-type] Argument to function `normalize_mark_list` is incorrect: Expected `Iterable[Mark | MarkDecorator]`, found `list[object] | list[Unknown] | (Any & Top[list[Unknown]])`

schema_salad (https://github.com/common-workflow-language/schema_salad)
- src/schema_salad/avro/schema.py:804:44 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | float | ... omitted 5 union elements`, found `object`
- src/schema_salad/avro/schema.py:809:38 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["items"]` on object of type `Top[dict[Unknown, Unknown]]`
- src/schema_salad/avro/schema.py:809:57 error[invalid-argument-type] Argument to function `is_subtype` is incorrect: Expected `None | str | float | ... omitted 5 union elements`, found `object`
- src/schema_salad/makedoc.py:788:26 error[invalid-argument-type] Argument to bound method `list.extend` is incorrect: Expected `Iterable[dict[str, Any]]`, found `(int & Top[MutableSequence[Unknown]]) | (float* & Top[MutableSequence[Unknown]]) | (str & Top[MutableSequence[Unknown]]) | (CommentedMap & Top[MutableSequence[Unknown]]) | CommentedSeq`
- src/schema_salad/metaschema.py:672:41 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/metaschema.py:697:29 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Any, (index: slice[int | None, int | None, int | None], /) -> MutableSequence[Any]]` cannot be called with key of type `Literal["$graph"]` on object of type `MutableSequence[Any]`
- src/schema_salad/ref_resolver.py:1135:25 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- src/schema_salad/ref_resolver.py:1135:61 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/ref_resolver.py:1154:29 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/ref_resolver.py:1155:62 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `str` on object of type `str`
- src/schema_salad/ref_resolver.py:1161:41 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/ref_resolver.py:1161:41 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/ref_resolver.py:1164:41 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/ref_resolver.py:1164:41 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `str` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/schema.py:434:30 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["name"]` on object of type `Top[Mapping[Unknown, object]]`
- src/schema_salad/schema.py:545:48 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Any, (index: slice[int | None, int | None, int | None], /) -> MutableSequence[Any]]` cannot be called with key of type `Literal["name"]` on object of type `MutableSequence[Any]`
- src/schema_salad/schema.py:549:31 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `Literal["type"]` on object of type `str`
- src/schema_salad/schema.py:562:20 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Any, (index: slice[int | None, int | None, int | None], /) -> MutableSequence[Any]]` cannot be called with key of type `Literal["name"]` on object of type `MutableSequence[Any]`
- src/schema_salad/schema.py:563:38 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> Any, (index: slice[int | None, int | None, int | None], /) -> MutableSequence[Any]]` cannot be called with key of type `Literal["name"]` on object of type `MutableSequence[Any]`
- src/schema_salad/schema.py:564:27 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `Literal["name"]` on object of type `str`
- src/schema_salad/schema.py:568:21 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[MutableMapping[Unknown, Unknown]].__getitem__(key: Never, /) -> object` cannot be called with key of type `Literal["names"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/schema.py:568:21 error[invalid-argument-type] Method `__getitem__` of type `bound method str.__getitem__(key: SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str` cannot be called with key of type `Literal["type"]` on object of type `str`

schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/core/error_feedback/parsers/ajv.py:359:48 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["message"]` on object of type `Top[dict[Unknown, Unknown]]`
- src/schemathesis/core/error_feedback/parsers/marshmallow.py:159:36 error[invalid-assignment] Object of type `object` is not assignable to `str | int`
- src/schemathesis/core/error_feedback/parsers/marshmallow.py:164:23 error[invalid-yield] Yield type `tuple[tuple[str | int, ...], ParameterLocation, object]` does not match annotated yield type `tuple[tuple[str | int, ...], ParameterLocation, str]`
- src/schemathesis/core/error_feedback/parsers/rails.py:218: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["errors"]` on object of type `Top[dict[Unknown, Unknown]]`
- src/schemathesis/specs/openapi/_auth_retry.py:82:9 error[invalid-argument-type] Argument to `Case.__init__` is incorrect: Expected `dict[str, Divergent] | list[Divergent] | str | ... omitted 4 union elements`, found `Top[list[Unknown]] | Top[dict[Unknown, Unknown]] | str | ... omitted 4 union elements`
- src/schemathesis/openapi/checks.py:176:13 error[invalid-argument-type] Argument to `JsonSchemaError.__init__` is incorrect: Expected `dict[str, Any] | bool`, found `Top[dict[Unknown, Unknown]]`
- src/schemathesis/specs/openapi/_hypothesis.py:1095:24 error[invalid-argument-type] Argument to function `_snap_float32_node` is incorrect: Expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]]`
- src/schemathesis/specs/openapi/adapter/responses.py:402:16 error[invalid-return-type] Return type does not match returned value: expected `str | None`, found `object`

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/_vendor/pyproject_metadata/project_table.py:226:62 error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `object` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- src/scikit_build_core/_vendor/pyproject_metadata/project_table.py:277:16 error[no-matching-overload] No overload of bound method `Pattern.fullmatch` matches arguments

scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/externals/array_api_compat/common/_aliases.py:594:22 warning[redundant-cast] Value is already of type `tuple[Any | str, ...]`
- sklearn/manifold/_spectral_embedding.py:421:9 error[unsupported-operator] Operator `-=` is not supported between objects of type `csr_array[Top[number[Any, complex]] | numpy.bool[builtins.bool], tuple[int] | tuple[int, int]]` and `dia_array[float64] | Unknown`
+ sklearn/manifold/_spectral_embedding.py:421:9 error[unsupported-operator] Operator `-=` is not supported between objects of type `csr_array[Unknown, Unknown]` and `dia_array[float64] | Unknown`
- sklearn/utils/tests/test_plotting.py:351:16 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method

scipy (https://github.com/scipy/scipy)
- scipy/special/tests/test_cdflib.py:114:54 error[invalid-argument-type] Argument to constructor `zip.__new__` is incorrect: Expected `Iterable[Unknown | None]`, found `None | (Unknown & Top[list[Unknown]]) | list[Unknown | None]`
+ scipy/special/tests/test_cdflib.py:114:54 error[invalid-argument-type] Argument to constructor `zip.__new__` is incorrect: Expected `Iterable[Unknown | None]`, found `None | (Unknown & list[Unknown]) | list[Unknown | None]`
- subprojects/array_api_extra/src/array_api_extra/testing.py:276:26 error[invalid-argument-type] Argument to function `getattr` is incorrect: Expected `str`, found `object`
- subprojects/array_api_extra/src/array_api_extra/testing.py:285:9 error[invalid-assignment] Object of type `dict[str, int | type]` is not assignable to attribute `_lazy_xp_function` on type `Unknown | (((...) -> Any) & ~tuple[object, ...])`
+ subprojects/array_api_extra/src/array_api_extra/testing.py:285:9 error[invalid-assignment] Object of type `dict[str, int | type]` is not assignable to attribute `_lazy_xp_function` on type `Any | (((...) -> Any) & ~tuple[object, ...])`
- subprojects/highs/highs/highspy/highs.py:383:65 error[invalid-assignment] Object of type `Iterable[highs_var | Integral] & Top[Mapping[Unknown, object]]` is not assignable to `Mapping[Any, highs_var | Integral]`

scrapy (https://github.com/scrapy/scrapy)
- scrapy/exporters.py:124:58 error[invalid-argument-type] Argument to bound method `BaseItemExporter.serialize_field` is incorrect: Expected `str`, found `object`
- scrapy/exporters.py:335:26 error[invalid-assignment] Object of type `ValuesView[object]` is not assignable to `Iterable[str]`

setuptools (https://github.com/pypa/setuptools)
- setuptools/_distutils/command/build_ext.py:445:30 error[not-iterable] Object of type `~AlwaysFalsy` is not iterable

spack (https://github.com/spack/spack)
- lib/spack/spack/audit.py:1463:82 error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `object` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- lib/spack/spack/cmd/commands.py:567:34 error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `object` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`

spark (https://github.com/apache/spark)
- python/pyspark/ml/functions.py:794:17 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `object` on object of type `list[list[int] | None]`
- python/pyspark/pandas/data_type_ops/boolean_ops.py:326:52 error[invalid-argument-type] Argument to function `_as_categorical_type` is incorrect: Expected `CategoricalDtype[object]`, found `Top[CategoricalDtype[Unknown]]`
- python/pyspark/pandas/data_type_ops/datetime_ops.py:145:52 error[invalid-argument-type] Argument to function `_as_categorical_type` is incorrect: Expected `CategoricalDtype[object]`, found `Top[CategoricalDtype[Unknown]]`
- python/pyspark/sql/classic/table_arg.py:44:20 error[invalid-assignment] Object of type `Column & Top[list[Unknown]]` is not assignable to `tuple[Column | str, ...]`
+ python/pyspark/sql/classic/table_arg.py:44:20 error[invalid-assignment] Object of type `Column & list[Unknown]` is not assignable to `tuple[Column | str, ...]`
- python/pyspark/sql/connect/functions/builtin.py:1717:16 error[invalid-assignment] Object of type `(Column & Top[list[Unknown]]) | (Sequence[Column | str] & Top[list[Unknown]]) | (Column & Top[set[Unknown]]) | ... omitted 3 union elements` is not assignable to `tuple[Column | Sequence[Column | str], ...]`
+ python/pyspark/sql/connect/functions/builtin.py:1717:16 error[invalid-assignment] Object of type `(Column & list[Unknown]) | (Column & set[Unknown]) | (Column & tuple[Unknown, ...]) | ... omitted 3 union elements` is not assignable to `tuple[Column | Sequence[Column | str], ...]`
- python/pyspark/sql/connect/window.py:35:16 error[invalid-assignment] Object of type `(Column & Top[list[Unknown]]) | (Sequence[Column | str] & Top[list[Unknown]])` is not assignable to `tuple[Column | Sequence[Column | str], ...]`
+ python/pyspark/sql/connect/window.py:35:16 error[invalid-assignment] Object of type `(Column & list[Unknown]) | list[Column | str]` is not assignable to `tuple[Column | Sequence[Column | str], ...]`
- python/pyspark/sql/session.py:1234:60 error[invalid-argument-type] Argument to bound method `SparkSession._inferSchema` is incorrect: Expected `list[str] | None`, found `None | (DataType & Top[list[Unknown]]) | list[str] | (DataType & tuple[object, ...])`
+ python/pyspark/sql/session.py:1234:60 error[invalid-argument-type] Argument to bound method `SparkSession._inferSchema` is incorrect: Expected `list[str] | None`, found `None | (DataType & list[Unknown]) | (DataType & tuple[Unknown, ...]) | list[str]`
- python/pyspark/sql/types.py:2809:17 error[invalid-assignment] Object of type `list[tuple[object, object]]` is not assignable to `Iterable[tuple[str, Any]]`
- python/pyspark/testing/sqlutils.py:310:21 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `str` on object of type `_Environ[str]`
- python/pyspark/testing/utils.py:1026:18 error[unresolved-attribute] Attribute `select` is not defined on `list[Row]` in union `pyspark.sql.dataframe.DataFrame | (pandas.core.frame.DataFrame & Top[list[Unknown]]) | (pyspark.pandas.frame.DataFrame[Unknown] & Top[list[Unknown]]) | list[Row]`
+ python/pyspark/testing/utils.py:1026:18 error[unresolved-attribute] Attribute `select` is not defined on `list[Row]` in union `pyspark.sql.dataframe.DataFrame | (pandas.core.frame.DataFrame & list[Unknown]) | (pyspark.pandas.frame.DataFrame[Unknown] & list[Unknown]) | list[Row]`
- python/pyspark/testing/utils.py:1035:43 error[invalid-argument-type] Argument to function `rename_dataframe_columns` is incorrect: Expected `pyspark.sql.dataframe.DataFrame`, found `pyspark.sql.dataframe.DataFrame | (pandas.core.frame.DataFrame & Top[list[Unknown]]) | (pyspark.pandas.frame.DataFrame[Unknown] & Top[list[Unknown]]) | list[Row] | Unknown`
+ python/pyspark/testing/utils.py:1035:43 error[invalid-argument-type] Argument to function `rename_dataframe_columns` is incorrect: Expected `pyspark.sql.dataframe.DataFrame`, found `pyspark.sql.dataframe.DataFrame | (pandas.core.frame.DataFrame & list[Unknown]) | (pyspark.pandas.frame.DataFrame[Unknown] & list[Unknown]) | list[Row] | Unknown`

static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/frame.py:5483:20 error[no-matching-overload] No overload of bound method `Frame._extract` matches arguments
- static_frame/core/index_hierarchy.py:1754:19 error[invalid-assignment] Object of type `int | (list[int] & Top[integer[Unknown]])` is not assignable to `int | None`
+ static_frame/core/index_hierarchy.py:1754:19 error[invalid-assignment] Object of type `int | (list[int] & integer[Unknown])` is not assignable to `int | None`
+ static_frame/core/store.py:394:24 error[invalid-argument-type] Argument to function `insert` is incorrect: Expected `Hashable | complex | integer[Any] | ... omitted 8 union elements`, found `Hashable | complex | integer[Any] | ... omitted 9 union elements`
- static_frame/core/type_blocks.py:3777:35 error[invalid-argument-type] Argument to bound method `list.append` is incorrect: Expected `Never`, found `ndarray[tuple[Any, ...], dtype[Any]]`

steam.py (https://github.com/Gobot1234/steam.py)
- steam/trade.py:401:13 error[invalid-assignment] Object of type `Sequence[ReceivingAssetT@TradeOffer] | (ReceivingAssetT@TradeOffer & Sequence[object]) | list[Unknown]` is not assignable to `Sequence[ReceivingAssetT@TradeOffer]`: Incompatible value of type `Sequence[ReceivingAssetT@TradeOffer] | (ReceivingAssetT@TradeOffer & Sequence[object]) | list[Unknown]`

strawberry (https://github.com/strawberry-graphql/strawberry)
- strawberry/codegen/plugins/python.py:135:62 error[invalid-argument-type] Argument to bound method `PythonPlugin._print_argument_value` is incorrect: Expected `GraphQLStringValue | GraphQLNullValue | GraphQLIntValue | ... omitted 6 union elements`, found `object`
- strawberry/http/sync_base_view.py:96:21 error[invalid-argument-type] Argument to bound method `SyncBaseHTTPView.execute_single` is incorrect: Expected `GraphQLRequestData`, found `object`
- strawberry/http/sync_base_view.py:270:41 error[unresolved-attribute] Object of type `object` has no attribute `errors`

sympy (https://github.com/sympy/sympy)
- sympy/physics/quantum/operatorset.py:128:34 error[invalid-argument-type] Method `__getitem__` of type `bound method dict[frozenset[<class 'J2Op'> | <class 'JxOp'>] | frozenset[<class 'J2Op'> | <class 'JyOp'>] | frozenset[<class 'J2Op'> | <class 'JzOp'>] | ... omitted 4 union elements, <class 'JxKet'> | <class 'JyKet'> | <class 'JzKet'> | ... omitted 4 union elements].__getitem__(key: frozenset[<class 'J2Op'> | <class 'JxOp'>] | frozenset[<class 'J2Op'> | <class 'JyOp'>] | frozenset[<class 'J2Op'> | <class 'JzOp'>] | ... omitted 4 union elements, /) -> <class 'JxKet'> | <class 'JyKet'> | <class 'JzKet'> | ... omitted 4 union elements` cannot be called with key of type `frozenset[type]` on object of type `dict[frozenset[<class 'J2Op'> | <class 'JxOp'>] | frozenset[<class 'J2Op'> | <class 'JyOp'>] | frozenset[<class 'J2Op'> | <class 'JzOp'>] | ... omitted 4 union elements, <class 'JxKet'> | <class 'JyKet'> | <class 'JzKet'> | ... omitted 4 union elements]`
- sympy/ntheory/tests/test_factor_.py:64:16 error[unsupported-operator] Operator `%` is not supported between objects of type `~AlwaysFalsy & ~Literal[1] & ~Literal[True]` and `Literal[2]`
- sympy/polys/domains/polynomialring.py:51:35 error[invalid-assignment] Object of type `Domain[Er@PolynomialRing] | Domain[Er@PolyRing]` is not assignable to `Domain[Er@PolynomialRing]`: Incompatible value of type `Domain[Er@PolynomialRing] | Domain[Er@PolyRing]`
+ sympy/polys/domains/polynomialring.py:51:35 error[invalid-assignment] Object of type `Domain[Unknown] | Domain[Er@PolynomialRing] | Domain[Er@PolyRing]` is not assignable to `Domain[Er@PolynomialRing]`: Incompatible value of type `Domain[Unknown] | Domain[Er@PolynomialRing] | Domain[Er@PolyRing]`
+ sympy/polys/rings.py:998:20 error[invalid-argument-type] Argument to bound method `PolyElement._try_rsub_ground` is incorrect: Argument type `Er@PolyElement & PolyElement[Unknown] & ~PolyElement[Er@PolyElement]` does not satisfy upper bound `PolyElement[Er@PolyElement]` of type variable `Self`
- sympy/solvers/solveset.py:3167:15 error[no-matching-overload] No overload of bound method `Set.subs` matches arguments

trio (https://github.com/python-trio/trio)
- src/trio/_core/_tests/test_run.py:2913:16 error[unresolved-attribute] Object of type `BaseException` has no attribute `message`
+ src/trio/_core/_tests/test_run.py:2913:16 error[unresolved-attribute] Attribute `message` is not defined on `BaseException` in union `Unknown | BaseException`

websockets (https://github.com/aaugustin/websockets)
- src/websockets/asyncio/connection.py:481:45 error[invalid-argument-type] Argument to bound method `Protocol.send_text` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `bytes | bytearray | (Iterable[str | bytes | bytearray | memoryview[int]] & Top[memoryview[Unknown]]) | memoryview[int]`
+ src/websockets/asyncio/connection.py:481:45 error[invalid-argument-type] Argument to bound method `Protocol.send_text` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `bytes | bytearray | memoryview[str | bytes | bytearray | memoryview[int]] | memoryview[int]`
- src/websockets/sync/connection.py:492:47 error[invalid-argument-type] Argument to bound method `Protocol.send_binary` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `bytes | bytearray | (Iterable[str | bytes | bytearray | memoryview[int]] & Top[memoryview[Unknown]]) | memoryview[int]`
+ src/websockets/sync/connection.py:492:47 error[invalid-argument-type] Argument to bound method `Protocol.send_binary` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `bytes | bytearray | memoryview[str | bytes | bytearray | memoryview[int]] | memoryview[int]`

werkzeug (https://github.com/pallets/werkzeug)
- src/werkzeug/_internal.py:42:12 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `(Any & Top[dict[Unknown, Unknown]]) | dict[str, Any] | (Request & Top[dict[Unknown, Unknown]])`
- src/werkzeug/middleware/shared_data.py:121:23 error[invalid-assignment] Object of type `ItemsView[object, object]` is not assignable to `Mapping[str, str | tuple[str, str]] | Iterable[tuple[str, str | tuple[str, str]]]`
+ src/werkzeug/middleware/shared_data.py:121:23 error[invalid-assignment] Object of type `ItemsView[str, str | tuple[str, str]] | ItemsView[tuple[str, str | tuple[str, str]], Unknown]` is not assignable to `Mapping[str, str | tuple[str, str]] | Iterable[tuple[str, str | tuple[str, str]]]`

xarray (https://github.com/pydata/xarray)
- xarray/core/dataset.py:4714:48 error[unsupported-operator] Operator `<` is not supported between objects of type `int` and `object`
- xarray/namedarray/core.py:843:59 error[invalid-argument-type] Argument to bound method `ChunkManagerEntrypoint.rechunk` is incorrect: Expected `tuple[tuple[int, ...], ...] | tuple[int, ...]`, found `(Mapping[Any, str | int | tuple[int, ...] | None] & float*) | str | tuple[int, ...] | ... omitted 4 union elements`
+ xarray/namedarray/core.py:843:59 error[invalid-argument-type] Argument to bound method `ChunkManagerEntrypoint.rechunk` is incorrect: Expected `tuple[tuple[int, ...], ...] | tuple[int, ...]`, found `str | tuple[int, ...] | (Mapping[Any, str | int | tuple[int, ...] | None] & float*) | ... omitted 4 union elements`
- xarray/namedarray/core.py:862:59 error[invalid-argument-type] Argument to bound method `ChunkManagerEntrypoint.from_array` is incorrect: Expected `tuple[tuple[int, ...], ...]`, found `(Mapping[Any, str | int | tuple[int, ...] | None] & float*) | str | tuple[int, ...] | ... omitted 5 union elements`
+ xarray/namedarray/core.py:862:59 error[invalid-argument-type] Argument to bound method `ChunkManagerEntrypoint.from_array` is incorrect: Expected `tuple[tuple[int, ...], ...]`, found `str | tuple[int, ...] | (Mapping[Any, str | int | tuple[int, ...] | None] & float*) | ... omitted 4 union elements`
- xarray/structure/combine.py:69:57 error[invalid-argument-type] Argument to function `_infer_tile_ids_from_nested_list` is incorrect: Expected `NestedSequence[Unknown]`, found `object`
+ xarray/structure/combine.py:69:57 error[invalid-argument-type] Argument to function `_infer_tile_ids_from_nested_list` is incorrect: Expected `NestedSequence[T@_infer_tile_ids_from_nested_list]`, found `T@_infer_tile_ids_from_nested_list | NestedSequence[T@_infer_tile_ids_from_nested_list]`

zulip (https://github.com/zulip/zulip)
- scripts/lib/supervisor.py:51:12 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- scripts/lib/supervisor.py:52:23 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- zerver/lib/push_notifications.py:608:23 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["android_devices"]` on object of type `Top[dict[Unknown, Unknown]]`
- zerver/lib/push_notifications.py:609:23 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:615:20 error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `object` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- zerver/lib/push_notifications.py:616:20 error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `object` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- zerver/lib/push_notifications.py:651: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/remote_server.py:479:50 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- zerver/lib/validator.py:275: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:475:20 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]]`
- zerver/lib/validator.py:502: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]]`

Full report with detailed diff (timing results)

@codspeed-hq

codspeed-hq Bot commented Jul 30, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 5.38%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 170 untouched benchmarks
⏩ 24 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ty_micro[mixed_typed_dict_union_copy] 121.2 ms 115 ms +5.38%

Tip

Curious why this is faster? Use the CodSpeed MCP and ask your agent.


Comparing david/isinstance-filtering (885be27) with main (fce9727)

Open in CodSpeed

Footnotes

  1. 24 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sharkdp sharkdp changed the title [ty] Experiment: Relaxed isinstance narrowing using specialization filtering [ty] Relaxed isinstance narrowing via union filtering Jul 31, 2026
@sharkdp
sharkdp force-pushed the david/isinstance-filtering branch 4 times, most recently from 4cc2f56 to 8548567 Compare August 5, 2026 07:30
@sharkdp sharkdp changed the title [ty] Relaxed isinstance narrowing via union filtering [ty] Gradual isinstance narrowing for generic classes Aug 5, 2026
Comment thread crates/ruff_benchmark/benches/ty_walltime.rs
Comment thread crates/ty_python_semantic/resources/mdtest/call/builtins.md
Comment thread crates/ty_python_semantic/src/types/narrow.rs
@sharkdp
sharkdp marked this pull request as ready for review August 5, 2026 15:17
@sharkdp
sharkdp requested review from a team as code owners August 5, 2026 15:17
@astral-sh-bot
astral-sh-bot Bot requested a review from carljm August 5, 2026 15:17
Comment thread crates/ty_test/src/db.rs

def narrow_union_with_unrelated_classes(value: Item | OpenItem | Sequence[int]) -> None:
if isinstance(value, list):
reveal_type(value) # revealed: (OpenItem & list[Unknown]) | list[int]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notably, we still build proper intersection types like OpenItem & list[Unknown] here where other type checkers just infer list[int]. I think this should be addressed separately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is tracked in astral-sh/ty#1578

from typing import Callable

def call_with_args(y: object):
if isinstance(y, Callable):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this means that our default behavior here for isinstance(.., Callable) will be different from a callable(..) check, which always uses the top materialization. This was previously discussed as an acceptable compromise, if I understood our discussion correctly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember details of that discussion. I think this is probably acceptable for now, though I think ideally these would have the same semantics. I guess in order to do that we would need to special-case callable (so the top materialization of its return type can depend on the strict-narrowing setting) rather than just patching typeshed...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous discussion here: #26797 (comment). I will open a ticket to address this as a follow-up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread crates/ty_python_semantic/resources/mdtest/narrow/isinstance.md

@carljm carljm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good, thank you! Really not that much new code to implement this. Lots of new tests (and unfortunately a lot of ongoing maintenance burden to double-write some kinds of tests.)

Question I hate to ask: should we double-run ecosystem checks now, once in gradual mode and once in strict mode? Otherwise it seems it will be very hard to see the effects of changes to e.g. intersection simplification or disjointness on strict mode.

We have some docs on "how to make ty strict" -- should we add a reference to this setting there?

Comment thread crates/ty_python_semantic/src/types/narrow.rs Outdated
Comment thread crates/ty_python_semantic/src/types/narrow.rs
Comment thread crates/ty_python_semantic/src/types/narrow.rs Outdated
from typing import Callable

def call_with_args(y: object):
if isinstance(y, Callable):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember details of that discussion. I think this is probably acceptable for now, though I think ideally these would have the same semantics. I guess in order to do that we would need to special-case callable (so the top materialization of its return type can depend on the strict-narrowing setting) rather than just patching typeshed...

def __init__(self, value: T) -> None: ...

def box_with_default[T: str = str](value: Box[T] | T) -> Box[T]:
def box_with_default[T: Item = Item](value: Box[T] | T) -> Box[T]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this PR change that (without the @final)?

Comment thread crates/ty_python_semantic/resources/mdtest/narrow/isinstance.md Outdated
Comment thread crates/ty_python_semantic/resources/mdtest/narrow/isinstance.md Outdated
#[derive(Hash, PartialEq, Debug, Eq, Clone, get_size2::GetSize, salsa::SalsaValue)]
struct Conjunctions<'db> {
conjuncts: SmallVec<[Type<'db>; 2]>,
conjuncts: SmallVec<[NarrowingOperation<'db>; 2]>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we could do better with memory here (presuming most narrowings are not generic-filterings), but the overall impact seems low, so I don't think that needs to be done in this PR.

@sharkdp sharkdp Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what you have in mind here, but if you have concrete ideas, or a feeling that we should improve this, it would be great if you could open a follow-up ticket.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just meant that the extra bit we track here might bump up the size here (though I haven't checked the sizeof Type vs NarrowingOperation, not sure if there's a niche available in Type that it can take advantage of), and if most narrowings are not generic filterings, we could avoid that by keeping the representation in a sidecar form rather than inline with every conjunct. But I don't think this is even worth a follow-up issue, it doesn't look that significant in the memory report.

Comment thread crates/ty_python_semantic/src/types/narrow.rs
@sharkdp

sharkdp commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Question I hate to ask: should we double-run ecosystem checks now, once in gradual mode and once in strict mode? Otherwise it seems it will be very hard to see the effects of changes to e.g. intersection simplification or disjointness on strict mode.

Yes, that seems like a good idea. I started a discussion with the team.

We have some docs on "how to make ty strict" -- should we add a reference to this setting there?

@AlexWaygood previously argued that this should not be part of https://docs.astral.sh/ty/coming-from-mypy-or-pyright/#stricter-checking-with-ty because it goes beyond what mypy/pyright do. But I guess we could have a general "how to make ty strict" section in the docs?

Edit: I see we have a section that goes beyond what pyright/mypy do. I will update that and various other parts in the documentation as a follow up.

@sharkdp

sharkdp commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

there was a single (expected) change in the ecosystem report after pushing these updates.

@sharkdp
sharkdp merged commit 87aa1aa into main Aug 6, 2026
103 of 104 checks passed
@sharkdp
sharkdp deleted the david/isinstance-filtering branch August 6, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

3 participants