Skip to content

[ty] Support narrowing with aliased conditional expressions#23937

Draft
mtshiba wants to merge 34 commits intomainfrom
narrow-by-aliased-conditional-expr
Draft

[ty] Support narrowing with aliased conditional expressions#23937
mtshiba wants to merge 34 commits intomainfrom
narrow-by-aliased-conditional-expr

Conversation

@mtshiba
Copy link
Copy Markdown
Collaborator

@mtshiba mtshiba commented Mar 13, 2026

Summary

Closes astral-sh/ty#719

Test Plan

new mdtest: narrow/aliased_conditions.md

@mtshiba mtshiba added ty Multi-file analysis & type inference ecosystem-analyzer labels Mar 13, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 13, 2026

Typing conformance results

No changes detected ✅

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

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 13, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 710.01MB 710.38MB +0.05% (380.50kB)
sphinx 260.04MB 260.20MB +0.06% (167.11kB)
trio 116.93MB 116.95MB +0.02% (25.17kB)
flake8 47.91MB 47.92MB +0.02% (8.55kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
semantic_index 175.70MB 176.05MB +0.19% (350.46kB)
infer_expression_types_impl 63.62MB 63.63MB +0.02% (14.37kB)
Expression 9.03MB 9.04MB +0.12% (10.76kB)
all_negative_narrowing_constraints_for_expression 2.69MB 2.69MB +0.08% (2.18kB)
all_narrowing_constraints_for_expression 7.38MB 7.38MB +0.03% (2.00kB)
UnionType<'db>::from_two_elements_ 970.94kB 971.17kB +0.02% (236.00B)
is_redundant_with_impl 2.01MB 2.01MB +0.01% (228.00B)
IntersectionType 709.26kB 709.44kB +0.03% (184.00B)
is_redundant_with_impl::interned_arguments 2.13MB 2.13MB +0.01% (176.00B)
place_by_id 4.67MB 4.67MB -0.00% (136.00B)
UnionType 939.31kB 939.42kB +0.01% (112.00B)
UnionType<'db>::from_two_elements_::interned_arguments 357.76kB 357.84kB +0.02% (88.00B)
place_by_id::interned_arguments 3.44MB 3.44MB -0.00% (72.00B)
infer_definition_types 91.21MB 91.21MB +0.00% (60.00B)
use_def_map 476.72kB 476.66kB -0.01% (60.00B)
... 1 more

sphinx

Name Old New Diff Outcome
semantic_index 61.27MB 61.42MB +0.24% (152.49kB)
infer_expression_types_impl 20.81MB 20.82MB +0.03% (6.88kB)
Expression 3.22MB 3.23MB +0.18% (5.84kB)
all_narrowing_constraints_for_expression 2.39MB 2.39MB +0.07% (1.77kB)
all_negative_narrowing_constraints_for_expression 1.05MB 1.05MB +0.01% (84.00B)
infer_definition_types 23.65MB 23.65MB +0.00% (48.00B)
infer_scope_types_impl 15.46MB 15.47MB +0.00% (12.00B)

trio

Name Old New Diff Outcome
semantic_index 30.03MB 30.06MB +0.08% (25.32kB)
Expression 1.42MB 1.42MB +0.06% (864.00B)
place_by_id 549.41kB 548.82kB -0.11% (600.00B)
place_by_id::interned_arguments 408.94kB 408.73kB -0.05% (216.00B)
use_def_map 54.73kB 54.55kB -0.32% (180.00B)
place_table 76.64kB 76.46kB -0.23% (180.00B)
infer_expression_types_impl 7.00MB 7.00MB +0.00% (156.00B)

flake8

Name Old New Diff Outcome
semantic_index 13.74MB 13.75MB +0.06% (8.48kB)
Expression 368.58kB 368.65kB +0.02% (72.00B)

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 13, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 2 0 0
unused-type-ignore-comment 1 0 0
Total 3 0 0

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

Raw diff:

discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/view.py:151:53 error[invalid-argument-type] Argument to `ExpectedClosingQuoteError.__init__` is incorrect: Expected `str`, found `str | None`
+ discord/ext/commands/view.py:162:57 error[invalid-argument-type] Argument to `ExpectedClosingQuoteError.__init__` is incorrect: Expected `str`, found `str | None`

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/index_hierarchy.py:1903:49 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive

Full report with detailed diff (timing results)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 13, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 60 skipped benchmarks1


Comparing narrow-by-aliased-conditional-expr (76cb30b) with main (5da0719)

Open in CodSpeed

Footnotes

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

@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch 2 times, most recently from f876929 to de49ca6 Compare March 13, 2026 16:23
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 13, 2026

mypy_primer results

Changes were detected when running on open source projects
more-itertools (https://github.com/more-itertools/more-itertools)
- more_itertools/more.py:4660:13: error[call-non-callable] Object of type `None` is not callable
- more_itertools/more.py:4684:13: error[call-non-callable] Object of type `None` is not callable
- more_itertools/more.py:4738:13: error[call-non-callable] Object of type `None` is not callable
- more_itertools/recipes.py:473:13: error[call-non-callable] Object of type `None` is not callable
- Found 31 diagnostics
+ Found 27 diagnostics

spack (https://github.com/spack/spack)
+ lib/spack/spack/install_test.py:608:76: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ lib/spack/spack/install_test.py:628:53: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- lib/spack/spack/package_base.py:1772:21: error[unresolved-attribute] Object of type `Self@do_patch` has no attribute `patch`
+ lib/spack/spack/package_base.py:1772:21: error[call-top-callable] Object of type `Top[(...) -> object]` is not safe to call; its signature is not known
- Found 4466 diagnostics
+ Found 4468 diagnostics

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/runner.py:127:43: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 381 diagnostics
+ Found 382 diagnostics

PyGithub (https://github.com/PyGithub/PyGithub)
+ github/Repository.py:2329:35: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ github/Repository.py:4086:91: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 326 diagnostics
+ Found 328 diagnostics

mitmproxy (https://github.com/mitmproxy/mitmproxy)
- test/mitmproxy/proxy/tutils.py:187:13: error[unresolved-attribute] Object of type `Command | Event` has no attribute `data`
- Found 2132 diagnostics
+ Found 2131 diagnostics

operator (https://github.com/canonical/operator)
+ ops/model.py:3700:16: warning[redundant-cast] Value is already of type `bool`
- Found 124 diagnostics
+ Found 125 diagnostics

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/ext/imgmath.py:269:52: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ sphinx/ext/imgmath.py:279:63: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 409 diagnostics
+ Found 411 diagnostics

mypy (https://github.com/python/mypy)
+ mypy/checkmember.py:1273:31: warning[redundant-cast] Value is already of type `Decorator`
+ mypy/checkmember.py:1302:24: warning[redundant-cast] Value is already of type `Decorator`
- Found 1762 diagnostics
+ Found 1764 diagnostics

discord.py (https://github.com/Rapptz/discord.py)
- discord/app_commands/transformers.py:112:67: error[invalid-argument-type] Argument to bound method `_checked_translate` is incorrect: Expected `locale_str`, found `str | locale_str`
- discord/app_commands/transformers.py:117:67: error[invalid-argument-type] Argument to bound method `_checked_translate` is incorrect: Expected `locale_str`, found `str | locale_str`
- discord/ext/commands/view.py:151:53: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `str | None`
- discord/ext/commands/view.py:162:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `str | None`
- Found 558 diagnostics
+ Found 554 diagnostics

meson (https://github.com/mesonbuild/meson)
- mesonbuild/compilers/detect.py:1166:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | None`
+ mesonbuild/compilers/detect.py:1166:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `str | None`
- mesonbuild/compilers/detect.py:1168:73: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | list[str]`, found `None | str | list[str]`
- Found 2354 diagnostics
+ Found 2353 diagnostics

setuptools (https://github.com/pypa/setuptools)
- setuptools/_imp.py:42:24: error[invalid-argument-type] Argument to function `issubclass` is incorrect: Expected `type`, found `Unknown | Loader | None`
- setuptools/_imp.py:50:24: error[invalid-argument-type] Argument to function `issubclass` is incorrect: Expected `type`, found `Unknown | Loader | None`
- setuptools/_vendor/more_itertools/more.py:4671:13: error[call-non-callable] Object of type `None` is not callable
- setuptools/_vendor/more_itertools/more.py:4695:13: error[call-non-callable] Object of type `None` is not callable
- setuptools/_vendor/more_itertools/more.py:4749:13: error[call-non-callable] Object of type `None` is not callable
- setuptools/_vendor/more_itertools/recipes.py:540:13: error[call-non-callable] Object of type `None` is not callable
- Found 1125 diagnostics
+ Found 1119 diagnostics

pandera (https://github.com/pandera-dev/pandera)
+ pandera/inspection_utils.py:14:57: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 1667 diagnostics
+ Found 1668 diagnostics

xarray (https://github.com/pydata/xarray)
- xarray/core/groupby.py:769:22: error[invalid-argument-type] Argument to bound method `_to_temp_dataset` is incorrect: Expected `DataArray`, found `T_Xarray@GroupBy`
- xarray/core/groupby.py:775:20: error[invalid-argument-type] Argument to bound method `_shuffle` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- xarray/core/groupby.py:775:20: error[invalid-argument-type] Argument to bound method `_shuffle` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `Dataset` of type variable `Self`
- xarray/core/groupby.py:780:20: error[invalid-argument-type] Argument to bound method `_from_temp_dataset` is incorrect: Argument type `T_Xarray@GroupBy` does not satisfy upper bound `DataArray` of type variable `Self`
- Found 1691 diagnostics
+ Found 1687 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-dbt/prefect_dbt/core/_orchestrator.py:1289:28: error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["execution_time"]` and `Unknown | None`
- src/integrations/prefect-dbt/prefect_dbt/core/_orchestrator.py:1290:71: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- src/prefect/utilities/pydantic.py:192:5: error[invalid-assignment] Object of type `def __init__(__pydantic_self__: M@add_type_dispatch, **data: Any) -> None` is not assignable to attribute `__init__` of type `Overload[(self, o: object, /) -> None, (self, name: str, bases: tuple[type, ...], dict: dict[str, Any], /, **kwds: Any) -> None]`
- src/prefect/utilities/pydantic.py:193:5: error[invalid-assignment] Object of type `def __new__(cls: type[M@add_type_dispatch], **kwargs: Any) -> M@add_type_dispatch` is not assignable to attribute `__new__` of type `def __new__(mcs, cls_name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], __pydantic_generic_metadata__: PydanticGenericMetadata | None = None, __pydantic_reset_parent_namespace__: bool = True, _create_model_module: str | None = None, **kwargs: Any) -> type`
+ src/prefect/utilities/pydantic.py:192:5: error[invalid-assignment] Object of type `def __init__(__pydantic_self__: M@add_type_dispatch, **data: Any) -> None` is not assignable to attribute `__init__` on type `type[M@add_type_dispatch] & ~<Protocol with members '__dispatch_key__'>`
+ src/prefect/utilities/pydantic.py:193:5: error[invalid-assignment] Object of type `def __new__(cls: type[M@add_type_dispatch], **kwargs: Any) -> M@add_type_dispatch` is not assignable to attribute `__new__` on type `type[M@add_type_dispatch] & ~<Protocol with members '__dispatch_key__'>`
- Found 5888 diagnostics
+ Found 5886 diagnostics

bokeh (https://github.com/bokeh/bokeh)
- src/bokeh/plotting/_geo_feature.py:505:23: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | None`
- src/bokeh/plotting/_geo_feature.py:521:40: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 863 diagnostics
+ Found 861 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/appsec/_common_module_patches.py:349:9: error[unresolved-attribute] Attribute `downstream_requests` is not defined on `None` in union `ASM_Environment | None`
- ddtrace/vendor/psutil/__init__.py:1071:24: error[invalid-argument-type] Argument to function `sleep` is incorrect: Expected `SupportsIndex | float`, found `Unknown | None`
- ddtrace/vendor/psutil/__init__.py:1829:24: error[invalid-argument-type] Argument to function `sleep` is incorrect: Expected `SupportsIndex | float`, found `Unknown | None`
- ddtrace/vendor/psutil/__init__.py:1839:24: error[invalid-argument-type] Argument to function `sleep` is incorrect: Expected `SupportsIndex | float`, found `Unknown | None`
- ddtrace/vendor/psutil/__init__.py:1894:24: error[invalid-argument-type] Argument to function `sleep` is incorrect: Expected `SupportsIndex | float`, found `Unknown | None`
- ddtrace/vendor/psutil/__init__.py:1904:24: error[invalid-argument-type] Argument to function `sleep` is incorrect: Expected `SupportsIndex | float`, found `Unknown | None`
- Found 9358 diagnostics
+ Found 9352 diagnostics

scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/compose/_column_transformer.py:1085:29: error[unresolved-attribute] Object of type `Self@transform` has no attribute `feature_names_in_`
+ sklearn/compose/_column_transformer.py:1085:29: error[not-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- sklearn/decomposition/_dict_learning.py:2321:23: error[no-matching-overload] No overload matches arguments
- sklearn/decomposition/_dict_learning.py:2322:23: error[no-matching-overload] No overload matches arguments
+ sklearn/externals/array_api_extra/_lib/_utils/_helpers.py:194:22: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- sklearn/linear_model/_ridge.py:252:22: error[no-matching-overload] No overload of function `atleast_1d` matches arguments
- Found 2522 diagnostics
+ Found 2520 diagnostics

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/api.py:1891:30: error[not-iterable] Object of type `Unknown | None` may not be iterable
- ibis/expr/api.py:1893:31: error[not-iterable] Object of type `Unknown | None` may not be iterable
- ibis/expr/api.py:1895:33: error[not-iterable] Object of type `Unknown | None` may not be iterable
- Found 4892 diagnostics
+ Found 4889 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/solvers/solveset.py:3129:25: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `tuple[Unknown, ...] | (Unknown & <Protocol with members '__iter__'>)`
+ sympy/solvers/solveset.py:3137:19: error[unresolved-attribute] Object of type `object` has no attribute `name`
+ sympy/solvers/solveset.py:3167:15: error[no-matching-overload] No overload of bound method `subs` matches arguments
- Found 16468 diagnostics
+ Found 16469 diagnostics

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/arrays/categorical.py:176:53: error[invalid-argument-type] Argument to function `invalid_comparison` is incorrect: Expected `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | list[Unknown] | ... omitted 14 union elements`, found `Hashable`
+ pandas/core/construction.py:358:54: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ pandas/core/generic.py:8279:61: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 4555 diagnostics
+ Found 4558 diagnostics

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/container_util.py:1830:66: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/frame.py:7561:43: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/index_hierarchy.py:1880:77: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/index_hierarchy.py:1902:49: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/loc_map.py:187:32: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- static_frame/core/util.py:1429:26: error[no-matching-overload] No overload matches arguments
+ static_frame/core/util.py:3092:65: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 1812 diagnostics
+ Found 1817 diagnostics

jax (https://github.com/google/jax)
+ jax/experimental/mosaic/gpu/tcgen05.py:435:25: warning[redundant-cast] Value is already of type `TMEMRef`
- Found 2162 diagnostics
+ Found 2163 diagnostics

rotki (https://github.com/rotki/rotki)
+ rotkehlchen/chain/evm/names.py:63:94: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ rotkehlchen/chain/evm/names.py:67:73: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- rotkehlchen/chain/zksync_lite/manager.py:646:39: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[int, HistoryEventType, HistoryEventSubType, Asset, FVal, ChecksumAddress, ChecksumAddress | None, str]`, found `tuple[Literal[0], Literal[HistoryEventType.WITHDRAWAL], Literal[HistoryEventSubType.BRIDGE], Asset, FVal, ChecksumAddress | None, None, str]`
+ rotkehlchen/chain/zksync_lite/manager.py:700:42: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ rotkehlchen/tests/api/test_ens.py:62:94: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ rotkehlchen/tests/api/test_ens.py:66:73: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 2150 diagnostics
+ Found 2154 diagnostics

core (https://github.com/home-assistant/core)
- homeassistant/components/tts/__init__.py:371:41: error[invalid-argument-type] Argument to bound method `write` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `object`
- Found 12121 diagnostics
+ Found 12120 diagnostics

scipy (https://github.com/scipy/scipy)
- scipy/_lib/_util.py:287:23: error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: SupportsIndex, /) -> Unknown, (index: slice[Any, Any, Any], /) -> tuple[Unknown, ...]]` cannot be called with key of type `None` on object of type `tuple[Unknown, ...]`
- scipy/integrate/tests/test_quadrature.py:539:15: error[no-matching-overload] No overload of function `broadcast_to` matches arguments
- scipy/interpolate/_fitpack_impl.py:130:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["u"]` and value of type `Unknown | None` on object of type `dict[str, ndarray[tuple[Any, ...], dtype[Any]] | int]`
- scipy/interpolate/_fitpack_impl.py:132:35: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/interpolate/_fitpack_impl.py:136:35: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/ndimage/_morphology.py:940:9: error[no-matching-overload] No overload matches arguments
- scipy/ndimage/_morphology.py:941:9: error[no-matching-overload] No overload matches arguments
- scipy/ndimage/_morphology.py:1166:9: error[no-matching-overload] No overload matches arguments
- scipy/ndimage/_morphology.py:2382:12: error[unresolved-attribute] Attribute `dtype` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2384:12: error[unresolved-attribute] Attribute `shape` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2387:9: error[invalid-assignment] Cannot assign to a subscript on an object of type `None`
- scipy/ndimage/_morphology.py:2391:12: error[unresolved-attribute] Attribute `ndim` is not defined on `None` in union `Unknown | None | ndarray[tuple[Any, ...], Unknown]`
- scipy/ndimage/_morphology.py:2393:24: error[unresolved-attribute] Attribute `size` is not defined on `None` in union `Unknown | None | ndarray[tuple[Any, ...], Unknown]`
- scipy/ndimage/_morphology.py:2393:57: error[unresolved-attribute] Attribute `shape` is not defined on `None` in union `Unknown | None | ndarray[tuple[Any, ...], Unknown]`
- scipy/ndimage/_morphology.py:2398:10: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/ndimage/_morphology.py:2398:10: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/ndimage/_morphology.py:2407:16: error[unresolved-attribute] Attribute `dtype` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2409:16: error[unresolved-attribute] Attribute `shape` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2414:25: error[unresolved-attribute] Attribute `shape` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2415:29: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/ndimage/_morphology.py:2417:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `None`
- scipy/ndimage/_morphology.py:2577:12: error[unresolved-attribute] Attribute `shape` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2579:12: error[unresolved-attribute] Attribute `dtype` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2587:49: error[unresolved-attribute] Attribute `dtype` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2595:16: error[unresolved-attribute] Attribute `shape` is not defined on `None` in union `Unknown | None`
- scipy/ndimage/_morphology.py:2597:16: error[unresolved-attribute] Attribute `dtype` is not defined on `None` in union `Unknown | None`
+ scipy/optimize/_lsq/trf.py:235:19: error[not-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
+ scipy/optimize/_lsq/trf.py:235:19: error[not-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method
+ scipy/optimize/_lsq/trf.py:285:23: error[not-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
+ scipy/optimize/_lsq/trf.py:285:23: error[not-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method
- scipy/spatial/transform/_rigid_transform.py:1400:25: error[unresolved-attribute] Attribute `dtype` is not defined on `int`, `slice[Any, Any, Any]`, `EllipsisType`, `None` in union `int | slice[Any, Any, Any] | EllipsisType | None | ArrayLike`
- scipy/spatial/transform/_rigid_transform.py:1402:36: error[unresolved-attribute] Attribute `dtype` is not defined on `int`, `slice[Any, Any, Any]`, `EllipsisType`, `None` in union `int | slice[Any, Any, Any] | EllipsisType | None | ArrayLike`
- scipy/spatial/transform/_rotation.py:2214:25: error[unresolved-attribute] Object of type `int | slice[Any, Any, Any] | EllipsisType | None` has no attribute `dtype`
- scipy/spatial/transform/_rotation.py:2216:42: error[unresolved-attribute] Object of type `int | slice[Any, Any, Any] | EllipsisType | None` has no attribute `dtype`
+ subprojects/array_api_extra/src/array_api_extra/_lib/_utils/_helpers.py:194:22: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 7976 diagnostics
+ Found 7951 diagnostics

@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from a5185d3 to bed2995 Compare March 27, 2026 04:32
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from 83ccce0 to 28dedf8 Compare March 28, 2026 12:04
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from 28dedf8 to 61f3951 Compare March 28, 2026 12:17
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from a938efa to 6e225aa Compare March 28, 2026 14:05
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from 0896823 to e29cc48 Compare March 29, 2026 04:43
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from a9261ba to cbb8f56 Compare March 29, 2026 10:59
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from f4fd36d to 339fc69 Compare March 29, 2026 13:05
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from 339fc69 to 4954d09 Compare March 29, 2026 13:14
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from 5a6cf74 to 87e334f Compare March 29, 2026 13:42
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from c3488d2 to 47334bb Compare March 29, 2026 15:28
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch 2 times, most recently from 36da824 to 1433707 Compare March 29, 2026 16:08
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from 1433707 to 1bbd0fd Compare March 29, 2026 16:46
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 25, 2026

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.

@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from c4da201 to 7b7a08a Compare April 25, 2026 11:22
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from 7b7a08a to 9c7bdb9 Compare April 25, 2026 11:30
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch 2 times, most recently from 178f5d3 to cb6569a Compare April 25, 2026 16:13
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from cb6569a to 76cb30b Compare April 25, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type narrowing fails to account for reassignment in a conditional based on an intermediate variable (aliased conditional expressions)

1 participant