mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[ruff
] Handle attrs
's auto_attribs
correctly (RUF009
) (#14520)
## Summary Resolves #14519. ## Test Plan `cargo nextest run` and `cargo insta test`.
This commit is contained in:
parent
545e9deba3
commit
d285717da8
6 changed files with 303 additions and 19 deletions
101
crates/ruff_linter/resources/test/fixtures/ruff/RUF009_attrs_auto_attribs.py
vendored
Normal file
101
crates/ruff_linter/resources/test/fixtures/ruff/RUF009_attrs_auto_attribs.py
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
import attr
|
||||
from attrs import define, field, frozen, mutable
|
||||
|
||||
|
||||
foo = int
|
||||
|
||||
|
||||
@define # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@define() # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@define(auto_attribs=None) # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@frozen # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@frozen() # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@frozen(auto_attribs=None) # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@mutable # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@mutable() # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@mutable(auto_attribs=None) # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@attr.s # auto_attribs = False
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@attr.s() # auto_attribs = False
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
||||
|
||||
|
||||
@attr.s(auto_attribs=None) # auto_attribs = None => True
|
||||
class C:
|
||||
a: str = 0
|
||||
b = field()
|
||||
c: int = foo()
|
||||
d = list()
|
Loading…
Add table
Add a link
Reference in a new issue