Skip to content

false positive invalid-name on attrs classvar #10525

@Redoubts

Description

@Redoubts

Bug description

consider

from typing import ClassVar

import attrs


class X:
    A: ClassVar[int] = 1

    def __init__(self) -> None:
        self.b: int = 2


@attrs.define
class Y:
    A: ClassVar[int] = 1
    b: int = 2

I notice that with default settings, X.A is fine but Y.A gets an invalid-name lint. I think A is supposed to match on class-attribute-naming-style, which is any by default, but this appears to match attr-naming-style or something like it

Configuration

Command used

pylint --rcfile /dev/null --disable all --enable invalid-name x.py

Pylint output

x.py:15:4: C0103: Attribute name "A" doesn't conform to snake_case naming style (invalid-name)

Expected behavior

10/10 would lint again

Pylint version

pylint 3.3.7
astroid 3.3.11
Python 3.11.13

OS / Environment

Debian

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: invalid-nameFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid updateNeeds an astroid update (probably a release too) before being mergable

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions