Skip to content

[ty] Preserve non-boolean comparison results for intersections - #28045

Draft
carljm wants to merge 3 commits into
mainfrom
cjm/ty-4380-intersection-comparisons
Draft

[ty] Preserve non-boolean comparison results for intersections#28045
carljm wants to merge 3 commits into
mainfrom
cjm/ty-4380-intersection-comparisons

Conversation

@carljm

@carljm carljm commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Comparisons on narrowed operands can return objects other than bool, but intersection comparison inference intersected those results with bool. This could turn a valid comparison into Never and hide errors in code that remains reachable.

Resolve rich-comparison methods with the full intersection receiver so non-boolean results and Self constraints are preserved. Keep boolean simplifications for boolean results, respect reflected-method priority, and use inherited object comparison methods only as fallbacks. Bound combinations of union return types and guard recursive metatype projection to keep inference terminating.

Analyze direct conditions separately from saved expression values. Short-circuit guards still rule out unreachable branches when an operand has mutable truthiness, while testing a saved result can call __bool__ again and take a different branch.

Fixes astral-sh/ty#4380.

Test plan

  • Non-boolean, non-returning, and conditional comparisons, including inherited object fallbacks and reflected dispatch.
  • Self and nested Self returns after narrowing, plus narrowed context-manager __enter__ results.
  • Comparisons on a NewType of float, bounded union-return intersections, and recursive alias metatypes.
  • Short-circuit reachability for nested boolean operations, chained comparisons, and conditional expressions in branches, loops, assertions, comprehensions, and match guards.
  • Conditional-expression result selection, plus saved and re-tested values whose truthiness can change.
  • Conditional expressions in quoted Annotated metadata.

carljm added 2 commits August 25, 2026 11:34
Resolve rich comparison methods against the complete intersection receiver, preserving non-boolean return types and Self bindings while retaining boolean simplifications.

Bound conditional method return intersections and guard recursive meta-type expansion. Add regression coverage for comparison results, reflected methods, conditional definitions, and recursive aliases.

Fixes astral-sh/ty#4380
@carljm carljm added the ty Multi-file analysis & type inference label Aug 25, 2026
@astral-sh-bot

astral-sh-bot Bot commented Aug 25, 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 97.69%. The percentage of expected errors that received a diagnostic held steady at 93.71%. The number of fully passing files held steady at 110/136.

@astral-sh-bot

astral-sh-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
prefect 477.08MB 477.59MB +0.11% (514.02kB)
sphinx 172.56MB 172.90MB +0.20% (351.22kB)
trio 96.86MB 96.93MB +0.07% (72.01kB)
flake8 40.21MB 40.23MB +0.04% (16.55kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
analyze_condition 0.00B 626.06kB +626.06kB (new)
infer_expression_types_impl 24.57MB 24.42MB -0.60% (149.93kB) ⬇️
infer_definition_types 37.05MB 37.00MB -0.14% (52.86kB) ⬇️
member_lookup_with_policy_and_receiver_inner 2.08MB 2.09MB +0.66% (14.07kB)
member_lookup_with_policy_and_receiver_inner::interned_arguments 718.91kB 731.33kB +1.73% (12.42kB)
BoundMethodType 2.48MB 2.49MB +0.48% (12.09kB)
Type<'db>::apply_specialization_inner_::interned_arguments 5.45MB 5.46MB +0.20% (11.33kB)
Type<'db>::class_member_with_policy_inner_ 9.91MB 9.92MB +0.11% (11.22kB)
MemberLookupKey 7.06MB 7.07MB +0.11% (7.72kB)
Type<'db>::apply_specialization_inner_ 3.75MB 3.75MB +0.18% (6.98kB)
Type<'db>::cached_materialization_::interned_arguments 1.50MB 1.50MB +0.32% (4.84kB)
IntersectionType 1.62MB 1.63MB +0.26% (4.32kB)
Specialization 5.01MB 5.02MB +0.08% (4.28kB)
TypeVarInference 1.11MB 1.11MB +0.33% (3.69kB)
Type<'db>::cached_materialization_ 1.13MB 1.14MB +0.29% (3.34kB)
... 38 more

sphinx

Name Old New Diff Outcome
analyze_condition 0.00B 426.12kB +426.12kB (new)
infer_expression_types_impl 12.01MB 11.94MB -0.57% (69.80kB) ⬇️
infer_definition_types 11.61MB 11.57MB -0.33% (38.80kB) ⬇️
BoundMethodType 1.01MB 1.03MB +1.45% (15.00kB)
member_lookup_with_policy_and_receiver_inner::interned_arguments 566.17kB 579.22kB +2.30% (13.05kB)
member_lookup_with_policy_and_receiver_inner 1.65MB 1.66MB +0.52% (8.82kB)
infer_expression_type_impl 289.49kB 282.02kB -2.58% (7.48kB) ⬇️
member_lookup_with_policy_inner 3.69MB 3.68MB -0.18% (6.80kB) ⬇️
Type<'db>::class_member_with_policy_inner_ 3.34MB 3.34MB +0.16% (5.61kB)
MemberLookupKey 3.06MB 3.06MB +0.11% (3.45kB)
Type<'db>::apply_specialization_inner_::interned_arguments 1.82MB 1.83MB +0.13% (2.42kB)
loop_header_reachability 252.11kB 249.96kB -0.85% (2.14kB) ⬇️
infer_scope_types_impl 6.13MB 6.13MB -0.03% (1.77kB) ⬇️
Type<'db>::apply_specialization_inner_ 1.16MB 1.16MB +0.14% (1.62kB)
infer_statement_types_impl 529.09kB 527.48kB -0.31% (1.62kB) ⬇️
... 23 more

trio

Name Old New Diff Outcome
analyze_condition 0.00B 76.52kB +76.52kB (new)
infer_expression_types_impl 6.43MB 6.42MB -0.21% (13.60kB) ⬇️
infer_definition_types 4.73MB 4.72MB -0.11% (5.47kB) ⬇️
member_lookup_with_policy_and_receiver_inner 244.08kB 246.80kB +1.12% (2.73kB)
BoundMethodType 338.72kB 341.25kB +0.75% (2.53kB)
member_lookup_with_policy_and_receiver_inner::interned_arguments 88.59kB 91.09kB +2.82% (2.50kB)
Type<'db>::class_member_with_policy_inner_ 1.29MB 1.29MB +0.18% (2.41kB)
place_by_id 624.57kB 622.57kB -0.32% (2.00kB) ⬇️
Type<'db>::apply_specialization_inner_::interned_arguments 1.26MB 1.26MB +0.14% (1.80kB)
MemberLookupKey 1.14MB 1.14MB +0.15% (1.73kB)
Type<'db>::cached_materialization_::interned_arguments 323.98kB 325.31kB +0.41% (1.33kB)
Type<'db>::apply_specialization_inner_ 878.87kB 880.05kB +0.13% (1.18kB)
Type<'db>::cached_materialization_ 233.98kB 234.95kB +0.41% (992.00B)
member_lookup_with_policy_inner 1.25MB 1.25MB -0.06% (848.00B) ⬇️
Specialization 1.12MB 1.12MB +0.07% (784.00B)
... 33 more

flake8

Name Old New Diff Outcome
analyze_condition 0.00B 13.98kB +13.98kB (new)
infer_expression_types_impl 806.85kB 806.31kB -0.07% (552.00B) ⬇️
Type<'db>::apply_specialization_inner_::interned_arguments 225.31kB 225.78kB +0.21% (480.00B)
BoundMethodType 81.47kB 81.94kB +0.58% (480.00B)
infer_definition_types 1.12MB 1.12MB -0.04% (472.00B) ⬇️
member_lookup_with_policy_and_receiver_inner 55.21kB 55.62kB +0.74% (416.00B)
Type<'db>::class_member_with_policy_inner_ 287.82kB 288.22kB +0.14% (408.00B)
member_lookup_with_policy_and_receiver_inner::interned_arguments 22.73kB 23.12kB +1.72% (400.00B)
MemberLookupKey 281.31kB 281.62kB +0.11% (312.00B)
Type<'db>::apply_specialization_inner_ 143.45kB 143.75kB +0.21% (304.00B)
Type<'db>::cached_materialization_::interned_arguments 65.78kB 66.02kB +0.36% (240.00B)
Type<'db>::cached_materialization_ 41.59kB 41.74kB +0.36% (152.00B)
Specialization 256.30kB 256.41kB +0.04% (112.00B)
TypeVarInference 45.02kB 45.11kB +0.21% (96.00B)
analyze_non_terminal_call 34.82kB 34.91kB +0.27% (96.00B)
... 13 more

@astral-sh-bot

astral-sh-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
unsound-return-statement 90 1 6
invalid-return-type 4 0 3
unresolved-attribute 4 0 2
unsound-assignment 1 3 1
invalid-argument-type 1 1 1
invalid-assignment 0 2 0
possibly-unresolved-reference 2 0 0
unresolved-import 0 1 0
unused-type-ignore-comment 0 1 0
Total 102 9 13

Large timing changes:

Project Old Time New Time Change
dd-trace-py 3.26s 0.83s -74%
Raw diff (124 changes)
aioredis (https://github.com/aio-libs/aioredis)
+ aioredis/lock.py:239:16 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`

apprise (https://github.com/caronc/apprise)
+ apprise/persistent_store.py:296:16 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`

cloud-init (https://github.com/canonical/cloud-init)
+ cloudinit/sources/DataSourceWSL.py:432:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`

core (https://github.com/home-assistant/core)
+ homeassistant/components/fritzbox/cover.py:73:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/miele/fan.py:113:13 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ homeassistant/components/nextcloud/binary_sensor.py:74:16 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
+ homeassistant/components/template/cover.py:261:16 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool | None`
+ homeassistant/components/vallox/switch.py:42:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/yardian/binary_sensor.py:57:12 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ homeassistant/components/aladdin_connect/cover.py:83:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/alexa/state_report.py:293:16 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Any` is not a subtype of `bool`
- homeassistant/components/alexa_devices/media_player.py:152:16 warning[unsound-return-statement] Unsound return statement: `(Unknown & ~AlwaysFalsy) | (bool & Unknown)` is not a subtype of `bool | None`
+ homeassistant/components/alexa_devices/media_player.py:152:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/elmax/cover.py:81:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/fibaro/cover.py:147:22 warning[unsound-assignment] Unsound assignment: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/fints/sensor.py:174:20 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ homeassistant/components/fints/sensor.py:194:20 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ homeassistant/components/fressnapf_tracker/light.py:107:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ homeassistant/components/hassio/coordinator.py:660:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ homeassistant/components/homematicip_cloud/binary_sensor.py:464:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/homematicip_cloud/cover.py:114:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/homematicip_cloud/cover.py:393:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/homematicip_cloud/light.py:272:16 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ homeassistant/components/homematicip_cloud/light.py:343:13 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ homeassistant/components/husqvarna_automower/button.py:35:12 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ homeassistant/components/ihc/light.py:94:16 warning[unsound-return-statement] Unsound return statement: `bool | Unknown` is not a subtype of `bool`
+ homeassistant/components/iron_os/coordinator.py:125:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ homeassistant/components/liebherr/cover.py:123:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/liebherr/light.py:95:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
- homeassistant/components/lutron_caseta/cover.py:126:16 warning[unsound-return-statement] Unsound return statement: `(Unknown & ~AlwaysFalsy) | (bool & Unknown)` is not a subtype of `bool`
+ homeassistant/components/lutron_caseta/cover.py:126:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ homeassistant/components/motion_blinds/cover.py:209:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/motion_blinds/cover.py:312:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/motion_blinds/cover.py:403:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/motion_blinds/cover.py:405:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/notion/binary_sensor.py:142:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/overkiz/water_heater/atlantic_domestic_hot_water_production_v2_ce_flat_c2_io_component.py:161:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ homeassistant/components/pglab/cover.py:95:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/pglab/cover.py:103:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/pglab/cover.py:111:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/sensoterra/sensor.py:173:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ homeassistant/components/smartthings/light.py:289:16 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool | None`
+ homeassistant/components/smartthings/light.py:405:20 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool | None`
- homeassistant/components/synology_dsm/sensor.py:459:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `StateType`
+ homeassistant/components/teslemetry/update.py:263:13 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
+ homeassistant/components/yolink/binary_sensor.py:64:13 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/components/yolink/valve.py:51:20 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`
+ homeassistant/components/zwave_me/cover.py:100:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool | None`
+ homeassistant/helpers/config_validation.py:259:16 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/appsec/_metrics.py:249:12 warning[unsound-return-statement] Unsound return statement: `Literal[True] | Any` is not a subtype of `bool`
+ ddtrace/_trace/sampling_rule.py:155:13 warning[unsound-return-statement] Unsound return statement: `bool | (Unknown & ~AlwaysTruthy)` is not a subtype of `bool`
+ ddtrace/appsec/_api_security/_normalized_route.py:590:12 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Any` is not a subtype of `bool`
+ ddtrace/debugging/_probe/remoteconfig.py:65:12 warning[unsound-return-statement] Unsound return statement: `Any | Literal[True]` is not a subtype of `bool`
+ tests/crashtracker/utils.py:189:24 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`
+ tests/crashtracker/utils.py:208:24 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`
+ tests/llmobs/test_pydantic_evaluators.py:39:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ tests/llmobs/test_pydantic_evaluators.py:44:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`

dragonchain (https://github.com/dragonchain/dragonchain)
+ dragonchain/lib/dto/btc.py:190:16 warning[unsound-return-statement] Unsound return statement: `Any | Literal[False]` is not a subtype of `bool`

freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/plugins/pairlist/PerformanceFilter.py:100:20 warning[unsound-assignment] Unsound assignment: `list[Any] | Unknown` is not a subtype of `list[str]`
+ freqtrade/plugins/pairlist/PerformanceFilter.py:100:20 warning[unsound-assignment] Unsound assignment: `list[Any]` is not a subtype of `list[str]`
- freqtrade/plugins/pairlist/PerformanceFilter.py:102:16 warning[unsound-return-statement] Unsound return statement: `list[Any] | Unknown` is not a subtype of `list[str]`
+ freqtrade/plugins/pairlist/PerformanceFilter.py:102:16 warning[unsound-return-statement] Unsound return statement: `list[Any]` is not a subtype of `list[str]`
- freqtrade/strategy/interface.py:1352:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[bool, bool, str | None]`, found `tuple[Series[bool] | Literal[False], Series[bool] | Literal[False], None]`
+ freqtrade/strategy/interface.py:1352:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[bool, bool, str | None]`, found `tuple[Series[bool] | Literal[False], Series[bool] | Literal[False], (Series[Any] & str) | None]`

ignite (https://github.com/pytorch/ignite)
+ ignite/engine/events.py:195:20 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`

jax (https://github.com/google/jax)
- jax/_src/tpu/linalg/eigh.py:78:14 warning[unsound-assignment] Unsound assignment: `Divergent` is not a subtype of `Array | None`
+ jax/_src/core.py:3573:13 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
- jax/_src/tpu/linalg/qdwh.py:56:14 warning[unsound-assignment] Unsound assignment: `Divergent` is not a subtype of `Array | None`
+ jax/experimental/mosaic/gpu/utils.py:2254:10 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ jax/experimental/mosaic/gpu/utils.py:2267:10 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ jax/experimental/mosaic/gpu/utils.py:2277:10 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ bson/objectid.py:228:20 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
+ bson/objectid.py:233:20 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
+ bson/objectid.py:238:20 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
+ bson/objectid.py:243:20 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
+ bson/objectid.py:248:20 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`
+ bson/objectid.py:253:20 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`

openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/core/lending.py:920:16 warning[unsound-return-statement] Unsound return statement: `(Unknown & ~AlwaysTruthy) | (bool & Unknown)` is not a subtype of `bool`
+ openlibrary/core/lending.py:920:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ openlibrary/plugins/upstream/addbook.py:786:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ openlibrary/utils/request_context.py:157:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ openlibrary/utils/request_context.py:160:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`

operator (https://github.com/canonical/operator)
+ ops/jujuversion.py:96:20 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`

optuna (https://github.com/optuna/optuna)
+ tests/visualization_tests/test_rank.py:139:16 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/dtypes/astype.py:330:16 warning[unsound-return-statement] Unsound return statement: `Any | bool` is not a subtype of `bool`
+ pandas/core/dtypes/dtypes.py:1444:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ pandas/core/indexes/interval.py:836:19 error[unresolved-attribute] Attribute `sum` is not defined on `Index` in union `Index | ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]] | Any`
+ pandas/core/indexes/interval.py:842:43 error[invalid-argument-type] Argument to function `maybe_booleans_to_slice` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[unsignedinteger[_8Bit]]]`, found `Index | ndarray[tuple[Any, ...], Unknown] | Any`
- pandas/core/indexes/timedeltas.py:359:20 error[invalid-return-type] Return type does not match returned value: expected `Day | Tick | None`, found `BaseOffset`
+ pandas/core/indexes/timedeltas.py:359:20 error[invalid-return-type] Return type does not match returned value: expected `Day | Tick | None`, found `BaseOffset & ~Tick`
+ pandas/core/indexing.py:3710:9 warning[unsound-return-statement] Unsound return statement: `bool | Any` is not a subtype of `bool`

pandera (https://github.com/pandera-dev/pandera)
+ pandera/backends/xarray/container.py:134:12 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`

porcupine (https://github.com/Akuli/porcupine)
+ porcupine/plugins/highlight/pygments_highlighter.py:59:17 warning[unsound-return-statement] Unsound return statement: `(Any & ~AlwaysTruthy) | bool` is not a subtype of `bool`

prefect (https://github.com/PrefectHQ/prefect)
+ src/integrations/prefect-aws/prefect_aws/workers/ecs_worker.py:1683:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ src/prefect/_internal/schemas/bases.py:53:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ src/prefect/results.py:721:16 warning[unsound-return-statement] Unsound return statement: `Unknown | Literal[True]` is not a subtype of `bool`
+ src/prefect/results.py:766:16 warning[unsound-return-statement] Unsound return statement: `Unknown | Literal[True]` is not a subtype of `bool`
+ src/prefect/runner/storage.py:389:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ src/prefect/server/utilities/schemas/bases.py:90:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`

psycopg (https://github.com/psycopg/psycopg)
+ tests/test_cursor_common.py:159:24 error[unresolved-attribute] Module `psycopg` has no member `ProgrammingError`
+ tests/test_cursor_common_async.py:157:24 error[unresolved-attribute] Module `psycopg` has no member `ProgrammingError`

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/aglib/disasm/assistant.py:372:24 error[invalid-assignment] Object of type `None` is not assignable to `Emulator`
- pwndbg/aglib/disasm/assistant.py:373:19 error[invalid-assignment] Object of type `None` is not assignable to `Emulator`
- pwndbg/aglib/kernel/nftables.py:227:16 warning[unsound-return-statement] Unsound return statement: `(Unknown & ~AlwaysFalsy) | bool` is not a subtype of `bool`
+ pwndbg/aglib/kernel/nftables.py:227:16 warning[unsound-return-statement] Unsound return statement: `Unknown | bool` is not a subtype of `bool`

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/networks.py:248:16 error[invalid-return-type] Return type does not match returned value: expected `bool`, found `SupportsBool`
+ pydantic/networks.py:253:16 error[invalid-return-type] Return type does not match returned value: expected `bool`, found `SupportsBool`
+ pydantic/networks.py:258:16 error[invalid-return-type] Return type does not match returned value: expected `bool`, found `SupportsBool`
+ pydantic/networks.py:263:16 error[invalid-return-type] Return type does not match returned value: expected `bool`, found `SupportsBool`

pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/_io/terminalwriter.py:80:24 error[unresolved-import] Cannot resolve imported module `colorama`
- src/_pytest/_io/terminalwriter.py:84:24 warning[unsound-assignment] Unsound assignment: `Unknown` is not a subtype of `TextIO | None`

pywin32 (https://github.com/mhammond/pywin32)
+ com/win32com/test/GenTestScripts.py:69:54 warning[possibly-unresolved-reference] Name `name` used when possibly not defined
+ com/win32com/test/GenTestScripts.py:75:54 warning[possibly-unresolved-reference] Name `name` used when possibly not defined

rotki (https://github.com/rotki/rotki)
+ rotkehlchen/tasks/bridges.py:287:9 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Any` is not a subtype of `bool`

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/specs/openapi/stateful/dependencies/__init__.py:282:16 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`

scipy (https://github.com/scipy/scipy)
- scipy/stats/_mstats_basic.py:2092:7 error[unresolved-attribute] Object of type `Literal[False]` has no attribute `filled`
+ scipy/stats/_mstats_basic.py:2092:7 error[unresolved-attribute] Object of type `Literal[False] | ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]]` has no attribute `filled`

setuptools (https://github.com/pypa/setuptools)
+ setuptools/_vendor/wheel/_bdist_wheel.py:116:12 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`
+ setuptools/command/bdist_wheel.py:93:12 warning[unsound-return-statement] Unsound return statement: `Any` is not a subtype of `bool`

spack (https://github.com/spack/spack)
- lib/spack/spack/cmd/info.py:490:20 error[invalid-return-type] Return type does not match returned value: expected `SupportsRichComparison`, found `tuple[bool & Any, Any & ~AlwaysFalsy]`
+ lib/spack/spack/cmd/info.py:490:20 error[invalid-return-type] Return type does not match returned value: expected `SupportsRichComparison`, found `tuple[Any, Any & ~AlwaysFalsy]`
+ lib/spack/spack/environment/environment.py:2976:16 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`

spark (https://github.com/apache/spark)
- python/pyspark/pandas/base.py:1067:16 error[unresolved-attribute] Object of type `IndexOpsLike@notnull` has no attribute `rename`
+ python/pyspark/pandas/base.py:1067:16 error[unresolved-attribute] Object of type `IndexOpsLike@notnull & ~MultiIndex` has no attribute `rename`
- python/pyspark/pandas/indexing.py:1750:20 warning[unsound-return-statement] Unsound return statement: `tuple[bool & Unknown, None, Literal[0]]` is not a subtype of `tuple[Column | None, int | None, int | None]`
+ python/pyspark/pandas/indexing.py:1750:20 warning[unsound-return-statement] Unsound return statement: `tuple[Unknown, None, Literal[0]]` is not a subtype of `tuple[Column | None, int | None, int | None]`
+ python/pyspark/sql/connect/expressions.py:627:13 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Any` is not a subtype of `bool`
- python/pyspark/streaming/context.py:389:42 error[invalid-argument-type] Argument to bound method `SparkContext.parallelize` is incorrect: Expected `Iterable[Unknown]`, found `RDD[T@queueStream]`

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:306:16 warning[unsound-return-statement] Unsound return statement: `Literal[True] | Any` is not a subtype of `bool`

static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/index.py:1307:58 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive

sympy (https://github.com/sympy/sympy)
- sympy/integrals/manualintegrate.py:1423:43 error[invalid-argument-type] Argument to bound method `list.extend` is incorrect: Expected `Iterable[tuple[type, Expr, ((...) -> Unknown) | None, tuple[Unknown, ...]]]`, found `tuple[tuple[<class 'Mul'>, Expr, None, <class 'EiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'CiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'ChiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'SiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'ShiRule'>], tuple[<class 'Pow'>, Expr, None, <class 'LiRule'>], tuple[<class 'exp'>, exp, None, <class 'ErfRule'>], tuple[<class 'Mul'>, Expr, (a, b, y) -> (Unknown & ~AlwaysTruthy) | (bool & Unknown), <class 'OwensTRule'>], tuple[<class 'sin'>, sin, None, <class 'FresnelSRule'>], tuple[<class 'cos'>, cos, None, <class 'FresnelCRule'>], tuple[<class 'Mul'>, Expr, None, <class 'UpperGammaRule'>], tuple[<class 'Mul'>, Expr, None, <class 'PolylogRule'>], tuple[<class 'Pow'>, Unknown, (a, d) -> Unknown, <class 'EllipticFRule'>], tuple[<class 'Pow'>, Unknown, (a, d) -> Unknown, <class 'EllipticERule'>]]`
+ sympy/integrals/manualintegrate.py:1423:43 error[invalid-argument-type] Argument to bound method `list.extend` is incorrect: Expected `Iterable[tuple[type, Expr, ((...) -> Unknown) | None, tuple[Unknown, ...]]]`, found `tuple[tuple[<class 'Mul'>, Expr, None, <class 'EiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'CiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'ChiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'SiRule'>], tuple[<class 'Mul'>, Expr, None, <class 'ShiRule'>], tuple[<class 'Pow'>, Expr, None, <class 'LiRule'>], tuple[<class 'exp'>, exp, None, <class 'ErfRule'>], tuple[<class 'Mul'>, Expr, (a, b, y) -> Unknown, <class 'OwensTRule'>], tuple[<class 'sin'>, sin, None, <class 'FresnelSRule'>], tuple[<class 'cos'>, cos, None, <class 'FresnelCRule'>], tuple[<class 'Mul'>, Expr, None, <class 'UpperGammaRule'>], tuple[<class 'Mul'>, Expr, None, <class 'PolylogRule'>], tuple[<class 'Pow'>, Unknown, (a, d) -> Unknown, <class 'EllipticFRule'>], tuple[<class 'Pow'>, Unknown, (a, d) -> Unknown, <class 'EllipticERule'>]]`
+ sympy/ntheory/primetest.py:730:16 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ sympy/polys/domains/gaussiandomains.py:61:20 warning[unsound-return-statement] Unsound return statement: `Unknown` is not a subtype of `bool`
+ sympy/polys/rings.py:553:16 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`
+ sympy/simplify/fu.py:288:47 error[unresolved-attribute] Attribute `q` is not defined on `Expr` in union `Expr | Unknown`

zulip (https://github.com/zulip/zulip)
+ zerver/lib/zulip_update_announcements.py:747:12 warning[unsound-return-statement] Unsound return statement: `Literal[False] | Unknown` is not a subtype of `bool`

Full report with detailed diff (timing results)

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

Development

Successfully merging this pull request may close these issues.

Equality comparisons involving intersection types incorrectly infer Never for non-boolean return types

1 participant