[flake8-self] Ignore attribute accesses on instance-like variables (SLF001) (#16149)

This commit is contained in:
InSync 2025-02-23 17:00:49 +07:00 committed by GitHub
parent aa88f2dbe5
commit c814745643
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 243 additions and 134 deletions

View file

@ -0,0 +1,45 @@
from __future__ import annotations
from typing import Annotated
# https://github.com/astral-sh/ruff/issues/9022
class Lorem[T]:
def f(self):
lorem_1 = Lorem()
lorem_1._value = 1 # fine
lorem_2 = Lorem[bytes]()
lorem_2._value = 1 # fine
class Ipsum:
def __new__(cls):
instance = super().__new__(cls)
instance._value = 1 # fine
class Dolor[T]:
def f(
self,
a: Dolor,
b: Dolor[int],
c: Annotated[Dolor, ...],
d: Annotated[Dolor[str], ...]
):
a._value = 1 # fine
b._value = 1 # fine
c._value = 1 # fine
d._value = 1 # fine
@classmethod
def m(cls):
instance = cls()
instance._value = 1 # fine
class M(type):
@classmethod
def f(mcs):
cls = mcs()
cls._value = 1