Skip to content

[ty] Narrow chained operators#23093

Merged
sharkdp merged 2 commits intomainfrom
charlie/chain
Feb 9, 2026
Merged

[ty] Narrow chained operators#23093
sharkdp merged 2 commits intomainfrom
charlie/chain

Conversation

@charliermarsh
Copy link
Member

Summary

See: #23084 (comment)

@charliermarsh charliermarsh added the ty Multi-file analysis & type inference label Feb 5, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 5, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 5, 2026

mypy_primer results

Changes were detected when running on open source projects
porcupine (https://github.com/Akuli/porcupine)
+ porcupine/pluginmanager.py:133:49: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `Unknown | str`
- Found 24 diagnostics
+ Found 25 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/parsing/mathematica.py:692:38: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `Unknown | list[Unknown | str]`
- Found 15903 diagnostics
+ Found 15902 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 5, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
unsupported-operator 79 0 0
invalid-return-type 4 0 0
possibly-missing-attribute 4 0 0
invalid-argument-type 3 0 0
invalid-assignment 0 1 0
unresolved-attribute 1 0 0
Total 91 1 0

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review February 5, 2026 17:31
Comment on lines +1319 to +1322
// Use the narrowed type for subsequent comparisons in a chain.
last_rhs_ty = Some(IntersectionType::from_elements(self.db, [rhs_ty, ty]));
} else {
last_rhs_ty = Some(rhs_ty);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a branch above that handles narrowing for if type(x) is Y etc, and it has a continue. Are we still updating last_rhs_ty in that branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Good call.)

@sharkdp sharkdp self-assigned this Feb 9, 2026
@sharkdp sharkdp merged commit b0b6151 into main Feb 9, 2026
50 checks passed
@sharkdp sharkdp deleted the charlie/chain branch February 9, 2026 09:44
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.

2 participants