Fix syntax error false positive on alternative match patterns by ntBre · Pull Request #21362 · astral-sh/ruff (original) (raw)
Summary
Fixes #21360 by using the union of names instead of overwriting them, as Micha suggested originally on #21104.
This avoids overwriting the n name in the Subscript by the empty set of
names visited in the nested OR pattern before visiting the other arm of the
outer OR pattern.
Test Plan
A new inline test case taken from the issue
added the bug
Something isn't working
label
ntBre marked this pull request as ready for review
ntBre deleted the brent/alt-patterns-2 branch
dcreager added a commit that referenced this pull request
- origin/main: (38 commits)
[ty] Make implicit submodule imports only occur in global scope (#21370)
[ty] introduce local variables for
fromimports of submodules in__init__.py(i)(#21173) [ruff] Ignorestr()when not used for simple conversion (RUF065) (#21330) [ty] implementtyping.NewTypeby addingType::NewTypeInstance[ty] supress inlay hints for+1and-1(#21368) [ty] Use type context for inference of generic constructors (#20933) [ty] Improve generic call expression inference (#21210) [ty] supress some trivial expr inlay hints (#21367) [configuration] Fix unclear error messages for line-length values exceedingu16::MAX(#21329) [ty] Fix incorrect inference ofenum.auto()for enums with non-intmixins, and imprecise inference ofenum.auto()for single-member enums (#20541) [refurb] Detect empty f-strings (FURB105) (#21348) [ty] provideimportcompletion when infrom <name> <name>statement (#21291) [ty] elide redundant inlay hints for function args (#21365) Fix syntax error false positive on alternativematchpatterns (#21362) Add a new "Opening a PR" section to the contribution guide (#21298) [flake8-simplify] Fix SIM222 false positive fortuple(generator) or None(SIM222) (#21187) Rebuild ruff binary instead of sharing it across jobs (#21361) [ty] Fix--excludeandsrc.excludemerging (#21341) [ty] Add support for properties that returnSelf(#21335) Add upstream linter URL toruff linter --output-format=json(#21316) ...
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
[ Show hidden characters]({{ revealButtonHref }})