Skip to content

[ty] Support narrowing with aliased conditional expressions#23937

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

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

Conversation

@mtshiba
Copy link
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

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 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 13, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 705.20MB 705.80MB +0.09% (616.56kB)
sphinx 265.25MB 265.64MB +0.15% (402.74kB)
trio 117.75MB 117.79MB +0.03% (38.05kB)
flake8 47.89MB 47.90MB +0.04% (17.46kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
infer_expression_types_impl 60.77MB 61.05MB +0.47% (292.39kB)
all_narrowing_constraints_for_expression 7.00MB 7.14MB +2.02% (144.43kB)
semantic_index 173.44MB 173.55MB +0.06% (106.79kB)
all_negative_narrowing_constraints_for_expression 2.60MB 2.64MB +1.61% (42.80kB)
Expression 8.51MB 8.54MB +0.29% (25.10kB)
infer_definition_types 88.89MB 88.90MB +0.00% (3.25kB)
check_file_impl 17.85MB 17.85MB -0.01% (1.82kB)
infer_expression_type_impl 14.34MB 14.35MB +0.00% (612.00B)
infer_scope_types_impl 52.94MB 52.94MB +0.00% (528.00B)
Type<'db>::member_lookup_with_policy_ 15.41MB 15.41MB +0.00% (436.00B)
Type<'db>::member_lookup_with_policy_::interned_arguments 5.53MB 5.53MB +0.01% (416.00B)
place_table 736.05kB 736.41kB +0.05% (360.00B)
is_redundant_with_impl::interned_arguments 5.36MB 5.36MB +0.00% (264.00B)
is_redundant_with_impl 5.57MB 5.57MB +0.00% (264.00B)
IntersectionType 2.31MB 2.31MB +0.01% (216.00B)
... 6 more

sphinx

Name Old New Diff Outcome
infer_expression_types_impl 21.52MB 21.71MB +0.89% (195.72kB)
semantic_index 62.50MB 62.57MB +0.12% (75.94kB)
all_narrowing_constraints_for_expression 2.34MB 2.39MB +1.97% (47.32kB)
all_negative_narrowing_constraints_for_expression 1.01MB 1.05MB +4.10% (42.46kB)
Expression 3.17MB 3.20MB +0.84% (27.35kB)
infer_definition_types 24.03MB 24.04MB +0.01% (3.32kB)
infer_expression_type_impl 3.21MB 3.22MB +0.05% (1.51kB)
IntersectionType 896.59kB 897.70kB +0.12% (1.11kB)
Type<'db>::member_lookup_with_policy_ 6.10MB 6.10MB +0.02% (1.10kB)
Type<'db>::class_member_with_policy_ 7.55MB 7.56MB +0.01% (948.00B)
StaticClassLiteral<'db>::implicit_attribute_inner_ 2.37MB 2.37MB +0.03% (672.00B)
StaticClassLiteral<'db>::implicit_attribute_inner_::interned_arguments 1.90MB 1.90MB +0.03% (576.00B)
is_redundant_with_impl::interned_arguments 2.07MB 2.07MB +0.02% (528.00B)
infer_scope_types_impl 15.58MB 15.58MB +0.00% (468.00B)
loop_header_reachability 381.17kB 381.60kB +0.11% (436.00B)
... 15 more

trio

Name Old New Diff Outcome
semantic_index 30.33MB 30.35MB +0.05% (15.82kB)
infer_expression_types_impl 7.06MB 7.07MB +0.21% (15.15kB)
Expression 1.41MB 1.41MB +0.21% (3.09kB)
all_narrowing_constraints_for_expression 600.60kB 603.40kB +0.47% (2.80kB)
all_negative_narrowing_constraints_for_expression 184.73kB 185.36kB +0.34% (644.00B)
infer_definition_types 7.57MB 7.57MB +0.01% (408.00B)
infer_expression_type_impl 1.43MB 1.43MB +0.01% (96.00B)
loop_header_reachability 133.74kB 133.79kB +0.04% (48.00B)
infer_scope_types_impl 4.79MB 4.79MB +0.00% (24.00B)

flake8

Name Old New Diff Outcome
semantic_index 13.83MB 13.84MB +0.04% (5.25kB)
infer_expression_types_impl 1.07MB 1.07MB +0.45% (4.93kB)
all_narrowing_constraints_for_expression 82.57kB 85.79kB +3.89% (3.21kB)
IntersectionType 72.80kB 73.34kB +0.74% (552.00B)
infer_definition_types 1.86MB 1.86MB +0.03% (520.00B)
Expression 365.70kB 366.19kB +0.13% (504.00B)
all_negative_narrowing_constraints_for_expression 40.30kB 40.77kB +1.15% (476.00B)
is_redundant_with_impl::interned_arguments 140.34kB 140.77kB +0.31% (440.00B)
infer_expression_type_impl 157.30kB 157.65kB +0.22% (356.00B)
is_redundant_with_impl 140.37kB 140.60kB +0.17% (240.00B)
enum_metadata 68.09kB 68.27kB +0.26% (184.00B)
loop_header_reachability 13.72kB 13.84kB +0.88% (124.00B)
UnionType 101.14kB 101.25kB +0.11% (112.00B)
infer_unpack_types 37.84kB 37.95kB +0.28% (108.00B)
Type<'db>::member_lookup_with_policy_::interned_arguments 207.09kB 207.19kB +0.05% (104.00B)
... 5 more

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 13, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 1 21 1
unused-type-ignore-comment 23 0 0
unresolved-attribute 1 21 0
not-subscriptable 5 7 0
no-matching-overload 1 8 0
call-non-callable 0 8 0
invalid-assignment 0 3 2
redundant-cast 4 0 0
not-iterable 0 3 0
call-top-callable 1 0 0
unsupported-operator 0 1 0
Total 36 72 3

Full report with detailed diff (timing results)

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 13, 2026

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 30 skipped benchmarks1


Comparing narrow-by-aliased-conditional-expr (4b090de) with main (7dfefd9)

Open in CodSpeed

Footnotes

  1. 30 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 from 588cd81 to f876929 Compare March 13, 2026 16:19
@mtshiba mtshiba force-pushed the narrow-by-aliased-conditional-expr branch from f876929 to de49ca6 Compare March 13, 2026 16:23
@astral-sh-bot
Copy link

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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