Skip to content

bare-name-capture-pattern false positive with conditional case statement #10647

@correctmost

Description

@correctmost

Bug description

archinstall uses conditional case statements to determine password strength:

https://github.com/archlinux/archinstall/blob/e0c3bb3869637d332b98e77665e46293cb69d5ae/archinstall/lib/models/users.py#L59-L68

Here is a simplified version of the code:

def password_strength(length):
    match length:
        case num if 13 <= num:
            return 'strong'
        case num if 11 <= num <= 12:
            return 'moderate'
        case num if 7 <= num <= 10:
            return 'weak'
        case num if num <= 6:
            return 'very-weak'

The code works fine, but Pylint emits bare-name-capture-pattern warnings when checking it.

Configuration

Command used

pylint match.py

Pylint output

match.py:3:13: E1901: The name capture `case num` makes the remaining patterns unreachable. Use a dotted name (for example an enum) to fix this. (bare-name-capture-pattern)
match.py:5:13: E1901: The name capture `case num` makes the remaining patterns unreachable. Use a dotted name (for example an enum) to fix this. (bare-name-capture-pattern)
match.py:7:13: E1901: The name capture `case num` makes the remaining patterns unreachable. Use a dotted name (for example an enum) to fix this. (bare-name-capture-pattern)

Expected behavior

No bare-name-capture-pattern warnings

Pylint version

pylint: 4.0.0
astroid: 4.0.1
Python 3.13.7

OS / Environment

Arch Linux

Additional dependencies

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions