[ty] Preserve non-boolean comparison results for intersections - #28045
Draft
carljm wants to merge 3 commits into
Draft
[ty] Preserve non-boolean comparison results for intersections#28045carljm wants to merge 3 commits into
carljm wants to merge 3 commits into
Conversation
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
Typing conformance resultsNo changes detected ✅Current numbersThe 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. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| 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`
This was referenced Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comparisons on narrowed operands can return objects other than
bool, but intersection comparison inference intersected those results withbool. This could turn a valid comparison intoNeverand hide errors in code that remains reachable.Resolve rich-comparison methods with the full intersection receiver so non-boolean results and
Selfconstraints are preserved. Keep boolean simplifications for boolean results, respect reflected-method priority, and use inheritedobjectcomparison 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
objectfallbacks and reflected dispatch.Selfand nestedSelfreturns after narrowing, plus narrowed context-manager__enter__results.NewTypeoffloat, bounded union-return intersections, and recursive alias metatypes.Annotatedmetadata.