mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-01 12:25:45 +00:00
[ruff] Allow more field calls from attrs (RUF009) (#19021)
Summary -- Closes #19014 by identifying more `field` functions from `attrs`. We already detected these when imported from `attrs` but not the `attr` module from the same package. These functions are identical to the `attrs` versions: ```pycon >>> import attrs, attr >>> attrs.field is attr.field True >>> attrs.Factory is attr.Factory True >>> ``` Test Plan -- Regression tests based on the issue
This commit is contained in:
parent
710c60f713
commit
b00f68a23c
3 changed files with 31 additions and 3 deletions
|
|
@ -125,3 +125,20 @@ class J:
|
|||
class K:
|
||||
f: F = F()
|
||||
g: G = G()
|
||||
|
||||
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/19014
|
||||
# These are all valid field calls and should not cause diagnostics.
|
||||
@attr.define
|
||||
class TestAttrField:
|
||||
attr_field_factory: list[int] = attr.field(factory=list)
|
||||
attr_field_default: list[int] = attr.field(default=attr.Factory(list))
|
||||
attr_factory: list[int] = attr.Factory(list)
|
||||
attr_ib: list[int] = attr.ib(factory=list)
|
||||
attr_attr: list[int] = attr.attr(factory=list)
|
||||
attr_attrib: list[int] = attr.attrib(factory=list)
|
||||
|
||||
|
||||
@attr.attributes
|
||||
class TestAttrAttributes:
|
||||
x: list[int] = list() # RUF009
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue