Skip to content

Add unreachable-match-patterns message and new checker. #10424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mbyrnepr2
Copy link
Member

Type of Changes

Type
πŸ› Bug fix
βœ“ ✨ New feature
πŸ”¨ Refactoring
πŸ“œ Docs

Description

This will emit an error message when a name capture pattern is used in a match statement which would make the remaining patterns unreachable. This code is a SyntaxError at runtime.

Closes #7128

Copy link

codecov bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 95.87%. Comparing base (a3e5bef) to head (e54d1ec).
Report is 99 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10424   +/-   ##
=======================================
  Coverage   95.86%   95.87%           
=======================================
  Files         175      177    +2     
  Lines       19074    19156   +82     
=======================================
+ Hits        18286    18366   +80     
- Misses        788      790    +2     
Files with missing lines Coverage Ξ”
pylint/checkers/match_statements_checker.py 100.00% <100.00%> (ΓΈ)

... and 24 files with indirect coverage changes

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pierre-Sassoulas Pierre-Sassoulas added the Enhancement ✨ Improvement to a component label Jun 11, 2025
``unreachable-match-patterns``.

This will emit an error message when a name capture pattern is used
in a match statement which would make the remaining patterns unreachable.
This code is a SyntaxError at runtime.

Closes pylint-dev#7128
@mbyrnepr2 mbyrnepr2 force-pushed the 7128_remaining_patterns_unreachable branch from f1ca097 to 0e5ef7c Compare June 12, 2025 08:54
@mbyrnepr2 mbyrnepr2 changed the title Add remaining-patterns-unreachable checker. Add unreachable-match-patterns message and new checker. Jun 12, 2025
@mbyrnepr2 mbyrnepr2 marked this pull request as ready for review June 12, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check for name capture syntax errors
2 participants