From 3a5647e4d7717402cfb1302d4e8188943eae8e0d Mon Sep 17 00:00:00 2001 From: Zen Lee Date: Thu, 4 Sep 2025 23:53:51 +0800 Subject: [PATCH 1/2] Add regression test --- .../invalid_name/invalid_name_issue_10525.py | 24 +++++++++++++++++++ .../invalid_name/invalid_name_issue_10525.txt | 0 2 files changed, 24 insertions(+) create mode 100644 tests/functional/i/invalid/invalid_name/invalid_name_issue_10525.py create mode 100644 tests/functional/i/invalid/invalid_name/invalid_name_issue_10525.txt diff --git a/tests/functional/i/invalid/invalid_name/invalid_name_issue_10525.py b/tests/functional/i/invalid/invalid_name/invalid_name_issue_10525.py new file mode 100644 index 0000000000..203e08843d --- /dev/null +++ b/tests/functional/i/invalid/invalid_name/invalid_name_issue_10525.py @@ -0,0 +1,24 @@ +"""Regression test for https://github.com/pylint-dev/pylint/issues/10525.""" + +# pylint: disable=too-few-public-methods + +from typing import ClassVar + +import attrs + + +class X: + """Class without attrs decorator""" + + A: ClassVar[int] = 1 + + def __init__(self) -> None: + self.b: int = 2 + + +@attrs.define +class Y: + """Class with attrs decorator""" + + A: ClassVar[int] = 1 # should not trigger `invalid-name` + b: int = 2 diff --git a/tests/functional/i/invalid/invalid_name/invalid_name_issue_10525.txt b/tests/functional/i/invalid/invalid_name/invalid_name_issue_10525.txt new file mode 100644 index 0000000000..e69de29bb2 From 8b16c69bed5fab8321e43225388e7ddbe2aa8b12 Mon Sep 17 00:00:00 2001 From: Zen Lee Date: Fri, 5 Sep 2025 20:02:33 +0800 Subject: [PATCH 2/2] Add changelog --- doc/whatsnew/fragments/10525.false_positive | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/whatsnew/fragments/10525.false_positive diff --git a/doc/whatsnew/fragments/10525.false_positive b/doc/whatsnew/fragments/10525.false_positive new file mode 100644 index 0000000000..3772097b61 --- /dev/null +++ b/doc/whatsnew/fragments/10525.false_positive @@ -0,0 +1,3 @@ +Fix a false positive for ``invalid-name`` in ``attrs`` decorated classes with ``ClassVar`` annotated attributes. + +Closes #10525