Skip to content

[ty] Relaxed isinstance/issubclass narrowing#26472

Open
sharkdp wants to merge 1 commit into
mainfrom
david/isinstance-relaxed-elsetop-plain
Open

[ty] Relaxed isinstance/issubclass narrowing#26472
sharkdp wants to merge 1 commit into
mainfrom
david/isinstance-relaxed-elsetop-plain

Conversation

@sharkdp

@sharkdp sharkdp commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces a new ty.analysis.generic-narrowing option that controls how isinstance and issubclass narrowing works for unspecialized generic classes. When this option is set to strict, we use the top materialization of the generic class (e.g. Top[list[Unknown]]). This is the current behavior on main. However, when the option is set to relaxed (the new default), we intersect with list[Unknown] directly, leading to a more gradual behavior (see example below). The idea here is to help users migrate from other type checkers. If they want to use a stricter type checking behavior, they can then switch to generic-narrowing = "strict" later.

strict (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.push(1)  # error!

relaxed (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.push(1)  # okay

One important detail here is how this new relaxed narrowing behavior works in the negative case (in else branches, or when using not isinstance(...)). I previously tried to simply intersect with ~list[Unknown], but this generally leads to leftover gradual types since we're not excluding all lists. A previous experiment shows that this leads to ~900 new diagnostics, even after implementing some gradual intersection simplifications. So here, we simply intersect with ~Top[list[Unknown]] in the negative case, which reflects what the runtime does: it excludes all list instances. The only downside is that this breaks symmetry: the narrowed type in the if branch and the narrowed type in the else branch don't recombine to the original type. I haven't seen any practical consequences of this though.

Another alternative that I considered was to introduce special marked object*/Never* types. This had a similar ecosystem impact, but the implementation is more complex. It also doesn't seem very principled and introduces two new fundamental types that can interact with the rest of the type system in many different ways. Maybe most importantly, I think this would be harder to teach to users. They would have to understand not just what a top-materialization is, but also that these give rise to new object and Never variants that behave in complex ways that are not clear from their naming. The approach followed in this PR, by contrast, relies on our core concepts (set theoretic gradual types). In the new "relaxed" mode implemented here, users will also see a lot fewer Top[..] types. One advantage of the object* approach is that it doesn't always "propagate" the gradual nature of the check. For example, when narrowing Item | Sequence[Item] via isinstance(..., Sequence), it yields Sequence[Item] & Sequence[object*] = Sequence[Item], instead of the permissive Sequence[Item & Unknown] that we get on this branch.

In a follow-up to this PR, I will make a similar change to TypeIs narrowing.

closes astral-sh/ty#3476
closes astral-sh/ty#3676
closes astral-sh/ty#3477
closes astral-sh/ty#3375

Post-merge TODO

  • Update the ty documentation, potentially update this section in the mypy/pyright migration docs.
  • if isinstance(..., Callable) should also follow this approach.

Test plan

  • New Markdown tests with a whole new section that includes various use cases that we've seen in user reports.

Ecosystem

1824 removed diagnostics. Most of the 32 newly added diagnostics are unused-(type-)ignore-comment.

@astral-sh-bot

astral-sh-bot Bot commented Jun 30, 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 94.47%. The percentage of expected errors that received a diagnostic held steady at 89.19%. The number of fully passing files held steady at 95/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
trio 70.77MB 70.79MB +0.02% (14.95kB)
prefect 450.84MB 450.85MB +0.00% (6.14kB)
flake8 29.18MB 29.18MB -0.01% (1.98kB) ⬇️
sphinx 167.68MB 167.66MB -0.02% (27.64kB) ⬇️

Significant changes

Click to expand detailed breakdown

trio

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 461.09kB 466.45kB +1.16% (5.36kB)
infer_expression_types_impl 4.42MB 4.42MB +0.04% (1.80kB)
is_redundant_with_impl::interned_arguments 237.96kB 239.25kB +0.54% (1.29kB)
when_constraint_set_assignable_to_owned_impl 282.68kB 283.69kB +0.36% (1.01kB)
member_lookup_with_policy_inner 1.03MB 1.03MB +0.09% (992.00B)
check_file_impl 1.57MB 1.57MB -0.05% (856.00B)
is_redundant_with_impl 129.89kB 130.69kB +0.61% (816.00B)
Type<'db>::class_member_with_policy_ 890.20kB 890.99kB +0.09% (808.00B)
infer_expression_type_impl 37.80kB 38.56kB +2.00% (776.00B)
infer_definition_types 3.98MB 3.98MB +0.02% (640.00B)
UnionType 145.19kB 145.80kB +0.42% (624.00B)
member_lookup_with_policy_inner::interned_arguments 766.99kB 767.58kB +0.08% (600.00B)
Type<'db>::apply_specialization_inner_::interned_arguments 510.23kB 509.69kB -0.11% (560.00B)
StaticClassLiteral<'db>::try_mro_ 532.70kB 532.18kB -0.10% (536.00B)
InferableTypeVarsInner 70.59kB 71.08kB +0.70% (504.00B)
... 31 more

prefect

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 5.23MB 5.26MB +0.65% (34.66kB)
check_file_impl 17.67MB 17.66MB -0.04% (7.55kB)
FunctionType 4.61MB 4.60MB -0.14% (6.55kB)
IntersectionType 986.02kB 991.83kB +0.59% (5.81kB)
Type<'db>::apply_specialization_inner_::interned_arguments 2.96MB 2.96MB -0.18% (5.55kB)
when_constraint_set_assignable_to_owned_impl 2.14MB 2.14MB +0.22% (4.73kB)
Type<'db>::class_member_with_policy_ 7.92MB 7.91MB -0.05% (4.06kB)
StaticClassLiteral<'db>::try_mro_ 3.39MB 3.39MB -0.11% (3.85kB)
Specialization 2.69MB 2.69MB -0.14% (3.73kB)
Type<'db>::apply_specialization_inner_ 2.04MB 2.04MB -0.14% (2.99kB)
Type<'db>::class_member_with_policy_::interned_arguments 5.74MB 5.74MB -0.05% (2.95kB)
is_redundant_with_impl::interned_arguments 2.36MB 2.36MB +0.11% (2.75kB)
infer_definition_types 50.06MB 50.06MB -0.00% (2.55kB)
when_constraint_set_assignable_to_owned_impl::interned_arguments 582.23kB 580.08kB -0.37% (2.15kB)
infer_expression_types_impl 37.98MB 37.98MB -0.00% (1.81kB)
... 55 more

flake8

Name Old New Diff Outcome
Type<'db>::apply_specialization_inner_::interned_arguments 178.36kB 177.89kB -0.26% (480.00B) ⬇️
when_constraint_set_assignable_to_owned_impl 106.70kB 106.34kB -0.34% (376.00B) ⬇️
all_narrowing_constraints_for_expression 74.57kB 74.88kB +0.41% (312.00B) ⬇️
Type<'db>::apply_specialization_inner_ 121.19kB 120.91kB -0.23% (288.00B) ⬇️
Type<'db>::class_member_with_policy_ 237.02kB 236.77kB -0.10% (248.00B) ⬇️
member_lookup_with_policy_inner::interned_arguments 207.07kB 206.84kB -0.11% (240.00B) ⬇️
Specialization 178.97kB 178.75kB -0.12% (224.00B) ⬇️
Type<'db>::class_member_with_policy_::interned_arguments 170.42kB 170.22kB -0.12% (208.00B) ⬇️
IntersectionType 54.03kB 54.23kB +0.36% (200.00B) ⬇️
is_possibly_constraint_set_assignable::interned_arguments 19.51kB 19.34kB -0.88% (176.00B) ⬇️
member_lookup_with_policy_inner 293.13kB 292.96kB -0.06% (176.00B) ⬇️
when_constraint_set_assignable_to_owned_impl::interned_arguments 29.30kB 29.13kB -0.59% (176.00B) ⬇️
is_possibly_constraint_set_assignable 10.56kB 10.48kB -0.81% (88.00B) ⬇️
BoundMethodType 55.55kB 55.47kB -0.14% (80.00B) ⬇️
ClassType<'db>::nearest_disjoint_base_ 1.45kB 1.52kB +4.84% (72.00B) ⬇️
... 4 more

sphinx

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 1.95MB 1.96MB +0.67% (13.34kB) ⬇️
Type<'db>::apply_specialization_inner_::interned_arguments 1.55MB 1.54MB -0.41% (6.48kB) ⬇️
Type<'db>::apply_specialization_inner_ 1.04MB 1.04MB -0.39% (4.18kB) ⬇️
FunctionType 1.79MB 1.78MB -0.22% (3.94kB) ⬇️
when_constraint_set_assignable_to_owned_impl 1022.52kB 1018.75kB -0.37% (3.77kB) ⬇️
check_file_impl 4.44MB 4.44MB -0.07% (3.12kB) ⬇️
Specialization 1.43MB 1.42MB -0.20% (2.86kB) ⬇️
member_lookup_with_policy_inner::interned_arguments 2.71MB 2.70MB -0.08% (2.11kB) ⬇️
Type<'db>::class_member_with_policy_ 3.60MB 3.60MB -0.05% (1.98kB) ⬇️
StaticClassLiteral<'db>::try_mro_ 1.81MB 1.81MB -0.10% (1.84kB) ⬇️
when_constraint_set_assignable_to_owned_impl::interned_arguments 291.33kB 289.78kB -0.53% (1.55kB) ⬇️
Type<'db>::class_member_with_policy_::interned_arguments 2.36MB 2.36MB -0.06% (1.52kB) ⬇️
member_lookup_with_policy_inner 4.29MB 4.29MB -0.03% (1.25kB) ⬇️
CallableType 1.44MB 1.44MB -0.08% (1.16kB) ⬇️
FunctionType<'db>::signature_ 1.61MB 1.61MB -0.07% (1.09kB) ⬇️
... 35 more

@astral-sh-bot

astral-sh-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 4 1,006 81
invalid-assignment 5 222 35
unresolved-attribute 0 130 34
invalid-return-type 4 119 27
no-matching-overload 0 104 0
invalid-key 0 62 0
not-subscriptable 2 49 3
unsupported-operator 0 42 3
call-non-callable 2 24 1
not-iterable 0 20 3
invalid-yield 0 15 1
index-out-of-bounds 0 14 0
redundant-cast 0 9 0
unused-type-ignore-comment 7 2 0
unused-ignore-comment 8 0 0
invalid-type-form 0 2 2
invalid-raise 0 2 0
possibly-unresolved-reference 0 2 0
call-top-callable 0 1 0
Total 32 1,825 190

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

Showing a random sample of 228 of 2047 changes. See the HTML report for the full diff.

Raw diff sample (228 of 2047 changes)
Expression (https://github.com/cognitedata/Expression)
- expression/collections/maptree.py:116:28 error[invalid-argument-type] Argument to function `mk` is incorrect: Expected `Option[MapTreeLeaf[Key@rebalance, object]]`, found `Option[MapTreeLeaf[Never, Never]]`
- expression/collections/maptree.py:121:24 error[invalid-return-type] Return type does not match returned value: expected `Option[MapTreeLeaf[Key@rebalance, Value@rebalance]]`, found `Option[MapTreeLeaf[Key@rebalance, object]]`
- expression/collections/maptree.py:133:62 error[invalid-argument-type] Argument to function `mk` is incorrect: Expected `Option[MapTreeLeaf[Key@rebalance, object]]`, found `Option[MapTreeLeaf[Never, Never]]`
- expression/collections/maptree.py:141:31 error[invalid-argument-type] Argument to function `mk` is incorrect: Expected `Option[MapTreeLeaf[Key@rebalance, object]]`, found `Option[MapTreeLeaf[Never, Never]]`

PyGithub (https://github.com/PyGithub/PyGithub)
- github/RepositoryAdvisory.py:291:71 error[invalid-argument-type] Argument to function `AdvisoryCredit._validate_credit` is incorrect: Expected `SimpleCredit | AdvisoryCredit`, found `object`
- github/RepositoryAdvisory.py:307:84 error[invalid-argument-type] Argument to function `AdvisoryVulnerability._to_github_dict` is incorrect: Expected `SimpleAdvisoryVulnerability | AdvisoryVulnerability`, found `object`
- 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:165:41 error[invalid-argument-type] Invalid argument to key "vulnerable_functions" with declared type `list[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]]`

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- 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:1207:37 error[invalid-argument-type] Argument to bound method `MultiDict.add` is incorrect: Expected `str`, found `object`
- aiohttp/cookiejar.py:332:23 error[invalid-assignment] Object of type `ItemsView[object, object]` is not assignable to `Mapping[str, str | BaseCookie[str] | Morsel[Any]] | Iterable[tuple[str, str | BaseCookie[str] | Morsel[Any]]] | BaseCookie[str]`
- aiohttp/web.py:349:25 error[invalid-argument-type] Argument to `UnixSite.__init__` is incorrect: Expected `str | PathLike[str]`, found `str | (Iterable[str | PathLike[str]] & PathLike[object]) | PathLike[str]`

aioredis (https://github.com/aio-libs/aioredis)
- aioredis/client.py:3430:34 error[invalid-assignment] Object of type `ValuesView[object]` is not assignable to `ValuesView[int | float] | None`

altair (https://github.com/vega/altair)
+ altair/vegalite/v6/api.py:2767:63 warning[unused-ignore-comment] Unused blanket `ty: ignore` directive

anyio (https://github.com/agronholm/anyio)
- src/anyio/_core/_sockets.py:994:38 error[invalid-argument-type] Argument is incorrect: Expected `str | IPv4Address | IPv6Address`, found `object`
- src/anyio/streams/stapled.py:125:21 error[not-subscriptable] Cannot delete subscript on object of type `Sequence[Listener[object]]` with no `__delitem__` method
+ src/anyio/streams/stapled.py:125:21 error[not-subscriptable] Cannot delete subscript on object of type `Sequence[Listener[Unknown]]` with no `__delitem__` method

apprise (https://github.com/caronc/apprise)
- tests/test_config_base.py:254:16 error[unresolved-attribute] Object of type `object` has no attribute `tags`

archinstall (https://github.com/archlinux/archinstall)
- archinstall/lib/profile/profiles_handler.py:132:19 error[unresolved-attribute] Object of type `object` has no attribute `name`

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

beartype (https://github.com/beartype/beartype)
- beartype/vale/_is/_valeis.py:327:24 error[invalid-assignment] Object of type `object` is not assignable to `((Any, /) -> bool) | tuple[(Any, /) -> bool]`

black (https://github.com/psf/black)
- src/black/trans.py:301:20 error[invalid-raise] Cannot use object of type `object` as an exception cause
- src/black/trans.py:497:13 error[unresolved-attribute] Unresolved attribute `__cause__` on type `object`
- src/black/trans.py:502:19 error[invalid-yield] Yield type `Ok[object]` does not match annotated yield type `Ok[Line] | Err[CannotTransform]`

bokeh (https://github.com/bokeh/bokeh)
- src/bokeh/io/showing.py:165:33 error[invalid-argument-type] Argument to function `_show_with_state` is incorrect: Expected `Showable`, found `UIElement | DOMNode | Sequence[UIElement | DOMNode] | (Application & Sequence[object]) | (((Document, /) -> None) & Sequence[object])`
- src/bokeh/plotting/_plot.py:93:45 error[invalid-argument-type] Argument to `Range1d.__init__` is incorrect: Expected `Value`, found `int | float | (Unknown & ~None) | str | IntrinsicType`
+ src/bokeh/plotting/_plot.py:93:45 error[invalid-argument-type] Argument to `Range1d.__init__` is incorrect: Expected `Value`, found `(Unknown & ~None) | IntrinsicType`

build (https://github.com/pypa/build)
- src/build/_builder.py:165:38 error[no-matching-overload] No overload of bound method `str.join` matches arguments

core (https://github.com/home-assistant/core)
- homeassistant/components/asuswrt/helpers.py:42:16 error[invalid-return-type] Return type does not match returned value: expected `T@translate_to_legacy`, found `dict[str, Any]`
+ homeassistant/components/asuswrt/helpers.py:42:16 error[invalid-return-type] Return type does not match returned value: expected `T@translate_to_legacy`, found `dict[Unknown, Any]`
- homeassistant/components/imap/__init__.py:262:20 error[invalid-return-type] Return type does not match returned value: expected `Message[str, str]`, found `object`
+ homeassistant/components/imap/__init__.py:262:20 error[invalid-return-type] Return type does not match returned value: expected `Message[str, str]`, found `Message[str, str] | Any | str`
- homeassistant/components/onvif/device.py:440:17 error[unresolved-attribute] Object of type `object` has no attribute `Name`
- homeassistant/components/onvif/device.py:445:25 error[unresolved-attribute] Object of type `object` has no attribute `VideoEncoderConfiguration`
- homeassistant/components/onvif/device.py:455:21 error[unresolved-attribute] Object of type `object` has no attribute `PTZConfiguration`
- homeassistant/components/rest/data.py:51:44 error[invalid-argument-type] Argument to constructor `BasicAuth.__new__` is incorrect: Expected `str`, found `object`
- homeassistant/components/ring/binary_sensor.py:170:9 error[invalid-assignment] Cannot assign to a subscript on an object of type `Mapping[str, Any]`

cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/builder.py:276:17 error[invalid-assignment] Cannot assign to a subscript on an object of type `float`
- cwltool/builder.py:279:21 error[invalid-assignment] Cannot assign to a subscript on an object of type `float`
- cwltool/builder.py:279:24 error[invalid-key] Unknown key "streamable" for TypedDict `CWLDirectoryType` (subscripted object has type `(int & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | (float & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | ... omitted 3 union elements`)
- cwltool/checker.py:117: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 `Literal["items"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:118: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 `Literal["items"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:121: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["type"]` on object of type `MutableSequence[Divergent]`
- cwltool/checker.py:121:12 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/checker.py:121:40 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: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["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/checker.py:123: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["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 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/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:605:33 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["writable"]` and value of type `object` on object of type `MutableMapping[str, int | str | float | ... omitted 5 union elements]`
- cwltool/command_line_tool.py:1531:17 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/load_tool.py:233:13 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["id"]` and value of type `str` on object of type `MutableSequence[Divergent]`
- cwltool/load_tool.py:233:13 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/load_tool.py:233:32 error[invalid-key] Unknown key "id" 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/main.py:283:58 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:296: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:297:17 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- cwltool/main.py:309:16 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: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["items"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/main.py:318:16 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/pack.py:33:40 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: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["name"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:47:40 error[invalid-key] Unknown key "id" for TypedDict `CWLDirectoryType` (subscripted object has type `(MutableMapping[str, int | str | float | ... omitted 5 union elements] & ~Top[MutableSequence[Unknown]]) | (int & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | ... omitted 4 union elements`)
- cwltool/pack.py:47:40 error[invalid-key] Unknown key "name" for TypedDict `CWLDirectoryType` (subscripted object has type `(MutableMapping[str, int | str | float | ... omitted 5 union elements] & ~Top[MutableSequence[Unknown]]) | (int & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | ... omitted 4 union elements`)
- 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["id"]` 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["id"]` 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/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["name"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:94:41 error[invalid-key] Unknown key "id" for TypedDict `CWLDirectoryType` (subscripted object has type `(MutableMapping[str, int | str | float | ... omitted 5 union elements] & ~Top[MutableSequence[Unknown]]) | (int & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | ... omitted 4 union elements`)
- cwltool/pack.py:98:27 error[invalid-key] Unknown key "$import" for TypedDict `CWLDirectoryType` (subscripted object has type `(MutableMapping[str, int | str | float | ... omitted 5 union elements] & ~Top[MutableSequence[Unknown]]) | (int & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]] & ~Top[MutableSequence[Unknown]]) | ... omitted 4 union elements`)
- cwltool/pack.py:142: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 `Literal["id"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- cwltool/pack.py:147:20 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- cwltool/pack.py:237:13 error[invalid-argument-type] Argument to function `update` is incorrect: Expected `CommentedSeq | CommentedMap`, found `(int & Top[MutableMapping[Unknown, Unknown]]) | (float & Top[MutableMapping[Unknown, Unknown]]) | (str & Top[MutableMapping[Unknown, Unknown]]) | (CommentedMap & Top[MutableMapping[Unknown, Unknown]])`
+ cwltool/pack.py:237:13 error[invalid-argument-type] Argument to function `update` is incorrect: Expected `CommentedSeq | CommentedMap`, found `(int & MutableMapping[Unknown, Unknown]) | (float & MutableMapping[Unknown, Unknown]) | (str & MutableMapping[Unknown, Unknown]) | (CommentedMap & MutableMapping[Unknown, Unknown])`
- cwltool/process.py:1069: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:1069: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:1071:37 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:1071:37 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:1226:26 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> CWLFileType | CWLDirectoryType | MutableMapping[str, int | str | float | ... omitted 5 union elements], (index: slice[int | None, int | None, int | None], /) -> Sequence[CWLFileType | CWLDirectoryType | MutableMapping[str, int | str | float | ... omitted 5 union elements]]]` cannot be called with key of type `Literal["id"]` on object of type `Sequence[CWLFileType | CWLDirectoryType | MutableMapping[str, int | str | float | ... omitted 5 union elements]]`
- cwltool/process.py:1227:58 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: int, /) -> CWLFileType | CWLDirectoryType | MutableMapping[str, int | str | float | ... omitted 5 union elements], (index: slice[int | None, int | None, int | None], /) -> Sequence[CWLFileType | CWLDirectoryType | MutableMapping[str, int | str | float | ... omitted 5 union elements]]]` cannot be called with key of type `Literal["id"]` on object of type `Sequence[CWLFileType | CWLDirectoryType | MutableMapping[str, int | str | float | ... omitted 5 union elements]]`
- tests/test_examples.py:348:26 error[invalid-key] TypedDict `CWLDirectoryType` can only be subscripted with a string literal key, got key of type `Literal[0]`
- tests/test_examples.py:350:26 error[invalid-key] TypedDict `CWLDirectoryType` can only be subscripted with a string literal key, got key of type `Literal[2]`
- tests/test_examples.py:363:12 error[not-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- tests/test_examples.py:363:27 error[invalid-key] Unknown key "checksum" for TypedDict `CWLDirectoryType` (subscripted object has type `int | str | float | ... omitted 5 union elements`)

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/contrib/internal/pymongo/utils.py:152:85 error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["Batch"]` and `object`
- ddtrace/llmobs/_evaluators/llm_judge.py:702:59 error[invalid-argument-type] Argument to bound method `LLMClient.__call__` is incorrect: Expected `dict[str, Any] | None`, found `None | (BooleanStructuredOutput & Top[dict[Unknown, Unknown]] & ~AlwaysFalsy) | (ScoreStructuredOutput & Top[dict[Unknown, Unknown]] & ~AlwaysFalsy) | ... omitted 3 union elements`

discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/cog.py:527:13 error[unresolved-attribute] Unresolved attribute `__cog_listener__` on type `(...) -> Coroutine[Any, Any, Any]`

freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/strategy/parameters.py:283:27 error[invalid-argument-type] Argument to `SKDecimal.__init__` is incorrect: Expected `int | float`, found `object`

graphql-core (https://github.com/graphql-python/graphql-core)
- tests/execution/test_hooks.py:355:16 error[unresolved-attribute] Object of type `object` has no attribute `errors`

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/types/relations.py:3223:28 error[unresolved-attribute] Object of type `Expr` has no attribute `type`

jax (https://github.com/google/jax)
- jax/_src/numpy/reductions.py:803:7 error[invalid-assignment] Object of type `object` is not assignable to `Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | ... omitted 4 union elements`
- jax/_src/numpy/lax_numpy.py:3134:20 error[not-iterable] Object of type `(Sequence[int] & tuple[object, ...]) | Array | ndarray[tuple[Any, ...], dtype[Any]] | ... omitted 11 union elements` may not be iterable
- jax/_src/pallas/mosaic_gpu/core.py:378:11 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `object`

koda-validate (https://github.com/keithasaurus/koda-validate)
- koda_validate/serialization/json_schema.py:356:17 error[invalid-return-type] Return type does not match returned value: expected `dict[str, None | int | str | ... omitted 4 union elements]`, found `dict[str, object]`
- koda_validate/serialization/json_schema.py:386:22 error[unresolved-attribute] Object of type `object` has no attribute `decode`

meson (https://github.com/mesonbuild/meson)
- mesonbuild/cargo/manifest.py:766:57 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["path"]` on object of type `Top[dict[Unknown, Unknown]]`
- mesonbuild/compilers/d.py:503:29 error[invalid-argument-type] Argument to bound method `list.extend` is incorrect: Expected `Iterable[str]`, found `list[str] | (((CompileCheckMode, /) -> list[str]) & Top[list[Unknown]])`
- mesonbuild/interpreterbase/helpers.py:43:20 error[invalid-return-type] Return type does not match returned value: expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `dict[object, Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`
- mesonbuild/interpreterbase/helpers.py:43:33 error[invalid-argument-type] Argument to function `resolver` 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:139:39 error[no-matching-overload] No overload of bound method `MutableMapping.setdefault` matches arguments
- mkdocs/config/config_options.py:836:46 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:846:42 error[no-matching-overload] No overload of function `join` matches arguments
- mkdocs/config/config_options.py:851:26 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]]`

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- pymongo/asynchronous/collection.py:961:25 error[invalid-assignment] Cannot assign to a subscript on an object of type `_DocumentType@AsyncCollection`
- pymongo/helpers_shared.py:191:13 error[invalid-assignment] Invalid subscript assignment with key of type `str | tuple[str, int | str | Mapping[str, Any]]` and value of type `Unknown` on object of type `dict[str, Any]`
- pymongo/helpers_shared.py:158:20 error[invalid-return-type] Return type does not match returned value: expected `Sequence[tuple[str, int | str | Mapping[str, Any]]]`, found `list[str | tuple[object, object]]`
+ pymongo/helpers_shared.py:158:20 error[invalid-return-type] Return type does not match returned value: expected `Sequence[tuple[str, int | str | Mapping[str, Any]]]`, found `list[str | tuple[str, int | str | Mapping[str, Any]] | tuple[Unknown, Unknown]]`
- pymongo/synchronous/topology.py:857:57 error[invalid-argument-type] Argument to function `_is_stale_error_topology_version` is incorrect: Expected `Mapping[str, Any] | None`, found `object`

mypy (https://github.com/python/mypy)
- mypy/server/astdiff.py:157:67 error[invalid-argument-type] Argument to function `compare_symbol_table_snapshots` is incorrect: Expected `dict[str, tuple[object, ...]]`, found `Top[dict[Unknown, Unknown]]`

openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/plugins/upstream/utils.py:337:49 error[no-matching-overload] No overload of function `sorted` matches arguments

packaging (https://github.com/pypa/packaging)
- src/packaging/specifiers.py:890:25 error[unresolved-attribute] Object of type `object` has no attribute `get`
- src/packaging/specifiers.py:900:21 error[invalid-assignment] Object of type `tuple[object, ...]` is not assignable to attribute `_specs` of type `tuple[Specifier, ...]`
- src/packaging/tags.py:210:35 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- src/packaging/version.py:790:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_dev` of type `tuple[Literal["dev"], int] | None`
- src/packaging/version.py:798:35 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["_epoch"]` on object of type `Top[dict[Unknown, Unknown]]`
- src/packaging/version.py:801:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_post` of type `tuple[Literal["post"], int] | None`

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/ops/mask_ops.py:189:12 error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]], ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]]]`, found `tuple[(NAType & ndarray[tuple[object, ...], dtype[object]]) | ndarray[tuple[Any, ...], dtype[Any]] | Unknown, Any | ndarray[tuple[Any, ...], dtype[Any]]]`
- pandas/core/common.py:467:38 error[invalid-argument-type] Argument to `RandomState.__init__` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any]]]] | int | ... omitted 3 union elements`, found `int | integer[Any] | ndarray[tuple[Any, ...], dtype[Any]] | ... omitted 3 union elements`
- pandas/core/construction.py:353:28 error[invalid-argument-type] Argument to bound method `MaskedArray.filled` is incorrect: Argument type `ExtensionArray & MaskedArray[tuple[object, ...], dtype[object]]` does not satisfy upper bound `MaskedArray[_ShapeT_co@MaskedArray, _DTypeT_co@MaskedArray]` of type variable `Self`
- pandas/core/dtypes/missing.py:254:18 error[invalid-assignment] Object of type `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Any` is not assignable to `ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]] | NDFrame`
- pandas/core/indexes/multi.py:4804:49 error[invalid-argument-type] Argument to bound method `MultiIndex.from_tuples` is incorrect: Expected `Iterable[tuple[Hashable, ...]]`, found `(Unknown & ~Generator[object, None, None] & ~MultiIndex) | (list[object] & ~MultiIndex)`
+ pandas/core/internals/construction.py:800:24 error[invalid-return-type] Return type does not match returned value: expected `tuple[list[ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]], Index]`, found `tuple[list[Unknown & ndarray[tuple[Any, ...], Unknown]], Index]`
- pandas/core/nanops.py:1483:30 error[no-matching-overload] No overload of bound method `ndarray.astype` matches arguments
- pandas/core/reshape/concat.py:799: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/io/_util.py:166:35 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]]`
- pandas/io/excel/_base.py:867:57 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Unknown, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Unknown]]` cannot be called with key of type `object` on object of type `list[Unknown]`
- pandas/io/formats/format.py:571:22 error[invalid-assignment] Object of type `(Sequence[str | int] & Top[Mapping[Unknown, object]] & ~int & ~str) | (Mapping[Hashable, str | int] & ~int & ~str)` is not assignable to `Mapping[Hashable, str | int]`
- pandas/io/formats/printing.py:283:24 error[invalid-assignment] Object of type `list[object]` is not assignable to `Iterable[str] | None`
- 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]]`
- pandas/io/pytables.py:5445:26 error[no-matching-overload] No overload of bound method `ndarray.reshape` matches arguments
- pandas/tests/extension/date/array.py:106:25 error[unresolved-attribute] Attribute `astype` is not defined on `date` in union `date | ndarray[tuple[Any, ...], dtype[Any]] | Any`
- pandas/util/_validators.py:378:33 error[invalid-argument-type] Argument to function `validate_bool_kwarg` is incorrect: Argument type `object` does not satisfy constraints (`bool`, `int`, `None`) of type variable `BoolishNoneT`

pandera (https://github.com/pandera-dev/pandera)
- pandera/decorators.py:401:20 error[invalid-return-type] Return type does not match returned value: expected `None`, found `(Any & ~tuple[object, ...]) | tuple[object, ...]`
+ pandera/decorators.py:401:20 error[invalid-return-type] Return type does not match returned value: expected `None`, found `(Any & ~tuple[object, ...]) | tuple[Unknown, ...]`
- pandera/engines/utils.py:82:47 error[invalid-argument-type] Argument to function `numpy_pandas_coercible` is incorrect: Expected `Series[Any]`, found `Series[Any] | DataFrame | Any`
+ pandera/engines/utils.py:82:47 error[invalid-argument-type] Argument to function `numpy_pandas_coercible` is incorrect: Expected `Series[Any]`, found `(Series[Any] & ~ndarray[tuple[object, ...], dtype[object]]) | DataFrame | Series[int | float] | Any`

pip (https://github.com/pypa/pip)
- src/pip/_vendor/packaging/specifiers.py:1461:21 error[invalid-assignment] Object of type `tuple[object, ...]` is not assignable to attribute `_specs` of type `tuple[Specifier, ...]`
- src/pip/_vendor/packaging/specifiers.py:1470:31 error[unresolved-attribute] Object of type `object` has no attribute `get`
- src/pip/_vendor/packaging/version.py:803:21 error[invalid-assignment] Object of type `object` is not assignable to attribute `_dev` of type `tuple[Literal["dev"], int] | None`
- src/pip/_vendor/requests/cookies.py:617:21 error[no-matching-overload] No overload of function `cookiejar_from_dict` matches arguments
- src/pip/_vendor/resolvelib/structs.py:206:12 error[invalid-return-type] Return type does not match returned value: expected `Iterable[CT@build_iter_view]`, found `_SequenceIterableView[RT@_SequenceIterableView]`

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/blocks/system.py:68:20 error[invalid-return-type] Return type does not match returned value: expected `SecretStr | Secret[T@Secret]`, found `(T@Secret & Secret[object]) | SecretStr | Secret[T@Secret]`
- 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[RelatedResource]`
+ src/prefect/cli/events.py:198:9 error[invalid-argument-type] Argument is incorrect: Expected `list[RelatedResource]`, found `(list[Any & dict[Unknown, Unknown]] & ~AlwaysFalsy) | (Any & list[Unknown] & ~AlwaysFalsy) | list[RelatedResource]`
- src/prefect/logging/loggers.py:385:13 error[unresolved-attribute] Object of type `object` has no attribute `_log`

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/commands/ptmalloc2.py:445:64 error[unresolved-attribute] Object of type `~AlwaysFalsy` has no attribute `address`
- pwndbg/commands/ptmalloc2.py:451:15 error[unresolved-attribute] Object of type `~AlwaysFalsy` has no attribute `value_to_human_readable`

pydantic (https://github.com/pydantic/pydantic)
- pydantic/json_schema.py:1719:13 error[no-matching-overload] No overload of bound method `MutableMapping.update` matches arguments
- pydantic/v1/main.py:1128:52 error[invalid-argument-type] Argument to `ValidationError.__init__` is incorrect: Expected `Sequence[Sequence[Any] | ErrorWrapper]`, found `list[object] & ~AlwaysFalsy`

pyproject-metadata (https://github.com/pypa/pyproject-metadata)
- pyproject_metadata/pyproject.py:103:44 error[unresolved-attribute] Object of type `object` has no attribute `get`

schema_salad (https://github.com/common-workflow-language/schema_salad)
- src/schema_salad/python_codegen_support.py:647:13 error[invalid-argument-type] Argument to `LoadingOptions.__init__` is incorrect: Expected `str | None`, found `object`
- src/schema_salad/python_codegen_support.py:653:22 error[invalid-argument-type] Argument to bound method `MutableSequence.pop` is incorrect: Expected `int`, found `Literal["$namespaces"]`
- src/schema_salad/python_codegen_support.py:655:22 error[invalid-argument-type] Argument to bound method `MutableMapping.pop` is incorrect: Expected `Never`, found `Literal["$schemas"]`
- src/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]]`
- src/schema_salad/avro/schema.py:811: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["values"]` on object of type `Top[dict[Unknown, Unknown]]`
- src/schema_salad/jsonld_context.py:211:17 error[invalid-assignment] Cannot assign to a subscript on an object of type `int`
- src/schema_salad/jsonld_context.py:211:17 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- src/schema_salad/jsonld_context.py:216:28 error[invalid-argument-type] Argument to function `fix_jsonld_ids` is incorrect: Expected `CommentedMap | int | float | str | CommentedSeq`, found `object`
- src/schema_salad/jsonld_context.py:229:19 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]]`
- src/schema_salad/jsonld_context.py:252:9 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- src/schema_salad/main.py:474:31 error[invalid-argument-type] Argument to function `printrdf` is incorrect: Expected `CommentedMap | CommentedSeq`, found `(int & Top[Mapping[Unknown, object]]) | (float & Top[Mapping[Unknown, object]]) | (str & Top[Mapping[Unknown, object]]) | ... omitted 6 union elements`
+ src/schema_salad/main.py:474:31 error[invalid-argument-type] Argument to function `printrdf` is incorrect: Expected `CommentedMap | CommentedSeq`, found `(int & Mapping[Unknown, Unknown]) | (float & Mapping[Unknown, Unknown]) | (str & Mapping[Unknown, Unknown]) | ... omitted 6 union elements`
- src/schema_salad/metaschema.py:679:22 error[invalid-argument-type] Argument to bound method `MutableMapping.pop` is incorrect: Expected `Never`, found `Literal["$base"]`
- 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:1135:61 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:1164:41 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:1177:21 error[invalid-argument-type] Argument to bound method `Loader.validate_links` is incorrect: Expected `int | float | str | ... omitted 3 union elements`, found `object`
- src/schema_salad/schema.py:271:57 error[invalid-argument-type] Argument to function `salad_to_jsonld_context` is incorrect: Expected `Iterable[MutableMapping[str, Any]]`, found `(int & Top[MutableSequence[Unknown]]) | (float & Top[MutableSequence[Unknown]]) | (str & Top[MutableSequence[Unknown]]) | (CommentedMap & Top[MutableSequence[Unknown]]) | CommentedSeq`
- src/schema_salad/schema.py:541:48 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]]`
- src/schema_salad/schema.py:543:17 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["name"]` and value of type `str` on object of type `MutableSequence[Any]`
- src/schema_salad/schema.py:545: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["type"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/schema.py:558:20 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]]`
- src/schema_salad/schema.py:558:20 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:559: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["name"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/schema.py:564:21 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["names"]` on object of type `MutableSequence[Any]`
- src/schema_salad/schema.py:564: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]]`
- src/schema_salad/schema.py:564: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["values"]` on object of type `Top[MutableMapping[Unknown, Unknown]]`
- src/schema_salad/schema.py:572:13 error[invalid-assignment] Cannot assign to a subscript on an object of type `str`
- src/schema_salad/schema.py:412:48 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method

schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/core/output/sanitization.py:31:31 error[invalid-argument-type] Method `__getitem__` of type `bound method Top[CaseInsensitiveDict[Unknown]].__getitem__(key: str) -> object` cannot be called with key of type `object` on object of type `Top[CaseInsensitiveDict[Unknown]]`
- src/schemathesis/core/output/sanitization.py:34:21 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `str` on object of type `Top[dict[Unknown, Unknown]]`
- src/schemathesis/specs/openapi/_hypothesis.py:1003:24 error[invalid-argument-type] Argument to function `_snap_float32_node` is incorrect: Expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]]`
- src/schemathesis/transport/requests.py:386: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 `str` on object of type `Top[dict[Unknown, Unknown]]`

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 `Pattern.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]]`

scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/manifold/_spectral_embedding.py:421:9 error[unsupported-operator] Operator `-=` is not supported between objects of type `csr_matrix[Never]` and `dia_array[float64] | Unknown`
+ sklearn/manifold/_spectral_embedding.py:421:9 error[unsupported-operator] Operator `-=` is not supported between objects of type `csr_matrix[(Unknown & Top[number[Any, int | float | complex]]) | (Unknown & numpy.bool[builtins.bool])]` and `dia_array[float64] | Unknown`
- sklearn/metrics/tests/test_pairwise.py:769:21 error[no-matching-overload] No overload of function `vstack` matches arguments
- sklearn/preprocessing/_polynomial.py:448:37 error[invalid-argument-type] Argument to function `max` is incorrect: Expected `Literal[2]`, found `object`

scipy (https://github.com/scipy/scipy)
- subprojects/highs/highs/highspy/highs.py:663:58 error[invalid-assignment] Object of type `(Any & Top[Mapping[Unknown, object]] & ~float & ~int) | (Mapping[Any, Any] & ~float & ~int) | (Sequence[Any] & Top[Mapping[Unknown, object]] & ~float & ~int)` is not assignable to `Mapping[Any, int | float]`
- subprojects/highs/highs/highspy/highs.py:1135:29 error[unresolved-attribute] Unresolved attribute `index` on type `object`
- subprojects/highs/highs/highspy/highs.py:1164:35 error[invalid-argument-type] Argument to constructor `map.__new__` is incorrect: Expected `(object, /) -> int`, found `<class 'int'>`

scrapy (https://github.com/scrapy/scrapy)
- scrapy/utils/datatypes.py:89:31 error[invalid-argument-type] Argument to bound method `CaselessDict.normkey` is incorrect: Argument type `str | int | AnyStr@update` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr`
+ scrapy/utils/datatypes.py:89:31 error[invalid-argument-type] Argument to bound method `CaselessDict.normkey` is incorrect: Argument type `Unknown | AnyStr@update` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr`

spark (https://github.com/apache/spark)
- python/pyspark/ml/linalg/__init__.py:469:16 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[object]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[object]]]` cannot be called with key of type `int` on object of type `ndarray[tuple[object, ...], dtype[object]]`
- python/pyspark/ml/linalg/__init__.py:469:16 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[object]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[object]]]` cannot be called with key of type `slice[Any, Any, Any]` on object of type `ndarray[tuple[object, ...], dtype[object]]`
- python/pyspark/ml/linalg/__init__.py:703:27 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[object]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[object]]]` cannot be called with key of type `ndarray[tuple[Any, ...], dtype[Unknown]]` on object of type `ndarray[tuple[object, ...], dtype[object]]`
- python/pyspark/ml/linalg/__init__.py:759:25 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[object]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[object]]]` cannot be called with key of type `Unknown` on object of type `ndarray[tuple[object, ...], dtype[object]]`
- python/pyspark/mllib/linalg/__init__.py:809:27 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[object]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[object]]]` cannot be called with key of type `ndarray[tuple[Any, ...], dtype[Unknown]]` on object of type `ndarray[tuple[object, ...], dtype[object]]`
- python/pyspark/pandas/generic.py:487:28 error[invalid-assignment] Object of type `object` is not assignable to `(...) -> Any`
- python/pyspark/sql/connect/expressions.py:511:22 error[not-iterable] Object of type `(Any & Top[list[Unknown]]) | (Any & Decimal) | (Any & bytes) | ... omitted 4 union elements` may not be iterable
+ python/pyspark/sql/connect/expressions.py:511:22 error[not-iterable] Object of type `(Any & list[Unknown]) | (Any & Decimal) | (Any & bytes) | ... omitted 4 union elements` may not be iterable
- python/pyspark/sql/connect/expressions.py:527:42 error[invalid-argument-type] Argument to bound method `DateType.fromInternal` is incorrect: Expected `int`, found `(Any & Top[list[Unknown]]) | (Any & Decimal) | (Any & bytes) | ... omitted 4 union elements`
+ python/pyspark/sql/connect/expressions.py:527:42 error[invalid-argument-type] Argument to bound method `DateType.fromInternal` is incorrect: Expected `int`, found `(Any & list[Unknown]) | (Any & Decimal) | (Any & bytes) | ... omitted 4 union elements`
- python/pyspark/sql/connect/plan.py:1035:14 error[call-non-callable] Object of type `Column` is not callable
- python/pyspark/sql/pandas/conversion.py:989:32 error[invalid-argument-type] Argument to bound method `StructType.add` is incorrect: Expected `str`, found `object`
+ python/pyspark/sql/pandas/conversion.py:989:32 error[invalid-argument-type] Argument to bound method `StructType.add` is incorrect: Expected `str`, found `Unknown | str | StructField`
- python/pyspark/testing/utils.py:1036:45 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:1036:45 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`
- python/pyspark/testing/utils.py:1054:43 error[invalid-argument-type] Argument to function `cast_columns_to_string` 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:1054:43 error[invalid-argument-type] Argument to function `cast_columns_to_string` 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/type_blocks.py:3291:35 error[invalid-argument-type] Argument to bound method `TypeBlocks._drop_blocks` is incorrect: Expected `int | integer[Any] | ndarray[Any, Any] | ... omitted 3 union elements`, found `object`
- static_frame/core/type_blocks.py:3595:24 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- static_frame/core/util.py:467:16 error[invalid-return-type] Return type does not match returned value: expected `int | list[int]`, found `list[int] | (ndarray[Any, dtype[signedinteger[_64Bit]]] & Top[list[Unknown]])`
- static_frame/test/unit/test_index.py:889:26 error[no-matching-overload] No overload of bound method `ndarray.tolist` matches arguments
- static_frame/test/unit/test_index.py:902:26 error[no-matching-overload] No overload of bound method `ndarray.tolist` matches arguments

strawberry (https://github.com/strawberry-graphql/strawberry)
- strawberry/http/sync_base_view.py:270:41 error[unresolved-attribute] Object of type `object` has no attribute `errors`

streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/elements/widgets/time_widgets.py:655:70 warning[unused-ignore-comment] Unused `ty: ignore` directive

sympy (https://github.com/sympy/sympy)
- sympy/physics/quantum/operatorset.py:118: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[object]` 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/printing/pretty/pretty_symbology.py:357:19 error[index-out-of-bounds] Index 3 is out of bounds for tuple `tuple[tuple[Unknown, Unknown, Unknown], str]` with length 2
- sympy/polys/domains/polynomialring.py:72:16 error[invalid-return-type] Return type does not match returned value: expected `PolyElement[Er@PolynomialRing]`, found `PolyElement[Er@PolynomialRing] | PolyElement[Er@PolyRing]`
+ sympy/polys/domains/polynomialring.py:72:16 error[invalid-return-type] Return type does not match returned value: expected `PolyElement[Er@PolynomialRing]`, found `(Er@PolynomialRing & PolyElement[Unknown]) | PolyElement[Er@PolynomialRing] | PolyElement[Er@PolyRing]`
- sympy/polys/domains/polynomialring.py:103:16 error[invalid-return-type] Return type does not match returned value: expected `PolyElement[Er@PolynomialRing]`, found `PolyElement[Er@PolynomialRing] | PolyElement[Er@PolyRing]`
+ sympy/polys/domains/polynomialring.py:103:16 error[invalid-return-type] Return type does not match returned value: expected `PolyElement[Er@PolynomialRing]`, found `PolyElement[Unknown] | PolyElement[Er@PolynomialRing] | PolyElement[Er@PolyRing]`
- sympy/polys/rings.py:1173:50 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- sympy/solvers/solveset.py:3167:15 error[no-matching-overload] No overload of bound method `Set.subs` matches arguments
- 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:530:40 error[unresolved-attribute] Object of type `_S@map` has no attribute `result`

urllib3 (https://github.com/urllib3/urllib3)
- src/urllib3/_collections.py:359:31 error[not-iterable] Object of type `object` is not iterable

vision (https://github.com/pytorch/vision)
- torchvision/transforms/v2/_utils.py:69:13 error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `list[int | float] | None` on object of type `dict[type | str, int | float | Sequence[int | float] | None]`

werkzeug (https://github.com/pallets/werkzeug)
- src/werkzeug/http.py:365:18 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- src/werkzeug/datastructures/headers.py:519:51 error[invalid-argument-type] Argument to bound method `Headers.getlist` is incorrect: Expected `str`, found `object`
- src/werkzeug/test.py:167:20 error[invalid-yield] Yield type `tuple[object, object]` does not match annotated yield type `tuple[str, Any]`

xarray (https://github.com/pydata/xarray)
- xarray/backends/common.py:197:51 error[invalid-argument-type] Argument to function `_normalize_path_list` is incorrect: Expected `NestedSequence[str | PathLike[Unknown] | ReadBuffer[Unknown]]`, found `(ReadBuffer[Unknown] & Top[list[Unknown]] & ~PathLike[object]) | (NestedSequence[str | PathLike[Unknown] | ReadBuffer[Unknown]] & Top[list[Unknown]] & ~PathLike[object])`
- xarray/core/common.py:1702:22 error[invalid-assignment] Object of type `(type[Any] & Top[Mapping[Unknown, object]]) | (str & Top[Mapping[Unknown, object]]) | (tuple[Any, SupportsIndex | Sequence[SupportsIndex]] & Top[Mapping[Unknown, object]]) | ... omitted 5 union elements` is not assignable to `Mapping[Any, dtype[Any] | None | type[Any] | ... omitted 6 union elements]`
- xarray/core/indexes.py:1007:29 error[unresolved-attribute] Object of type `Index[Any] & Top[CategoricalIndex[Any]]` has no attribute `remove_unused_categories`
+ xarray/core/indexes.py:1007:29 error[unresolved-attribute] Object of type `CategoricalIndex[Unknown]` has no attribute `remove_unused_categories`
- xarray/core/indexing.py:411:19 error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]] | tuple[ndarray[tuple[Any, ...], dtype[integer[Any] | numpy.bool[builtins.bool]]], ...], /) -> ndarray[tuple[Any, ...], dtype[object]], (key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any, (key: SupportsIndex | slice[Any, Any, Any] | EllipsisType | ... omitted 5 union elements, /) -> ndarray[tuple[Any, ...], dtype[object]]]` cannot be called with key of type `integer[Any]` on object of type `ndarray[tuple[object, ...], dtype[object]]`
- xarray/core/utils.py:356:35 error[invalid-argument-type] Argument to function `flat_items` is incorrect: Expected `Mapping[str, dict[str, Divergent] | Unknown]`, found `dict[str, Divergent] | (T@flat_items & Top[dict[Unknown, Unknown]])`

zulip (https://github.com/zulip/zulip)
- scripts/lib/supervisor.py:52:42 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- zerver/lib/event_schema.py:409:29 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- zerver/lib/event_schema.py:464:38 error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- zerver/lib/push_notifications.py:607: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/validator.py:274: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 `object` on object of type `Top[dict[Unknown, Unknown]]`

Full report with detailed diff (timing results)

@sharkdp sharkdp force-pushed the david/isinstance-relaxed-elsetop-plain branch from 40c75ba to 1c0b597 Compare July 1, 2026 11:07
@sharkdp sharkdp changed the title [ty] Experiment: Top-materialize negative isinstance narrowing (2) [ty] Relaxed isinstance narrowing Jul 1, 2026
@sharkdp sharkdp force-pushed the david/isinstance-relaxed-elsetop-plain branch from 1c0b597 to 7b8d150 Compare July 1, 2026 11:23
python_version: SupportedPythonVersion::Py311,
},
3,
7,

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.

The four new diagnostics here are due to unused ty: ignore suppression comments 🙃

from typing import Any
from ty_extensions import Top

def f(xyxy: Top[list[Any]]):

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 changed this to an explicit Top[...] annotation because that snippet does not create a Top materialization anymore.


if isinstance(x, list):
reveal_type(x) # revealed: Sequence[int] & Top[list[Unknown]]
reveal_type(x) # revealed: Sequence[int] & list[Unknown]

@sharkdp sharkdp Jul 1, 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.

It's plausible that we could simplify Sequence[int] & list[Unknown] to list[int], which would restore the type for x below (tracked in astral-sh/ty#1824).

@sharkdp sharkdp changed the title [ty] Relaxed isinstance narrowing [ty] Relaxed isinstance/issubclass narrowing Jul 1, 2026
@sharkdp sharkdp force-pushed the david/isinstance-relaxed-elsetop-plain branch 2 times, most recently from 0ac407b to e36f2c9 Compare July 1, 2026 11:50

def _(xs: Item | list[Item]):
if isinstance(xs, list):
reveal_type(xs) # revealed: list[Item]

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.

Here, we make use of the previously implemented simplification list[Item] & list[Unknown] = list[Item]

@sharkdp sharkdp marked this pull request as ready for review July 1, 2026 12:11
@sharkdp sharkdp requested review from a team as code owners July 1, 2026 12:11
@AlexWaygood

AlexWaygood commented Jul 1, 2026

Copy link
Copy Markdown
Member

Post-merge TODO

Though that section is about achieving the same strictness as mypy/pyright --strict, and our behaviour on main here is arguably stricter than either type checker's strict mode currently. We might want another section, detailing this setting and a few other disabled-by-default error codes that are not paralleled in mypy/pyright but that users wanting strong soundness guarantees might want to enable

@sharkdp sharkdp closed this Jul 2, 2026
@sharkdp sharkdp reopened this Jul 2, 2026
@astral-sh-bot astral-sh-bot Bot requested a review from MichaReiser July 2, 2026 07:17
@astral-sh-bot

astral-sh-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@sharkdp sharkdp force-pushed the david/isinstance-relaxed-elsetop-plain branch from e36f2c9 to 5363a4c Compare July 2, 2026 10:11
@charliermarsh

Copy link
Copy Markdown
Member

(I haven't read the code yet) How does this intersect with astral-sh/ty#1130? E.g., would #25851 still be relevant?

Separately, for this and for changes like #26414 and #26415, I think we should uniformly use a prefix like unsafe- or unsound-. We tend to do this in uv and I think it will be helpful here to indicate that these are effectively a related group of strictness relaxations.

@sharkdp

sharkdp commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

How does this intersect with astral-sh/ty#1130?

I think the change here is orthogonal to the TypedDict-related issues. One way to think about is the following. When we change from intersecting with Top[dict[Unknown, Unknown]] to intersecting with dict[Unknown, Unknown], we affect the "interior" gradualness, i.e. treat the key and value types more permissively, but we still require an actual dict type/specialization.

E.g., would #25851 still be relevant?

Yes, I think it still makes sense to intersect with the union of dict[Unknown, Unknown] and the empty open TypedDict in this new "relaxed" mode.

Separately, for this and for changes like #26414 and #26415, I think we should uniformly use a prefix like unsafe- or unsound-. We tend to do this in uv and I think it will be helpful here to indicate that these are effectively a related group of strictness relaxations.

You'd like to have that as a prefix for the configuration setting's name itself? Something like this:

unsound-generic-narrowing = true  # the default
unsound-generic-narrowing = false

I understand the intention and I agree that it seems like a good idea to group these somehow. It seems slightly unfortunate that users who WANT the strict behavior would then have to put a setting with the name "unsound" in their config file (if only to turn it off), while users with the default (unsound) behavior would have a "clean" config.

Or did you intend for this to be a prefix for the configuration value, like this?

generic-narrowing = "unsound-relaxed"  # the default  (or maybe just "unsound"?)
generic-narrowing = "strict"

This way, users with the strict behavior would only have to add generic-narrowing = "strict".

@sharkdp sharkdp requested review from carljm and removed request for MichaReiser July 6, 2026 11:41
@carljm

carljm commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

A couple high-level comments before I get into a more detailed review:

  1. I don't think failure to simplify Iterable[T] & tuple[object, ...] to tuple[T, ...] ty#3890 should be closed by this PR. The new gradual narrowing by default does mask the diagnostic in that example, but the intersection simplification discussed there is correct independent of narrowing behavior, and would still be useful for other intersections, or for people who enable strict isinstance narrowing. We might re-prioritize that issue, but I don't think we should close it.
  2. I do find the extra gradualness that we get in this branch relative to other type checkers to be fairly problematic. In this example:
def f(x: Sequence[int]):
    x[0].upper()  # error
    if isinstance(x, Sequence):
        x[0].upper()  # no error with the new default

I don't think there is any justification for losing the precision of the original type, just because we've (redundantly) checked it with isinstance. If the original type is X | Sequence[int] then it's slightly more justifiable, but only via the pedantic "might be both an X and a Sequence of something else" logic.

Ultimately I think this reveals the conceptual weakness of this approach (and the strength of the "special treatment of materialized object/Never" approach), which is that fundamentally narrowing via an isinstance check of a generic should not introduce additional gradual uncertainty about the type argument type. What we want is a more subtle behavior, where we preserve existing type argument knowledge unchanged if we have it, but use Unknown if we don't. Of course other type checkers achieve this behavior via a much simpler union filtering approach.

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

4 participants