Skip to content

RUF012 warns for ctypes Structure._fields_ #22166

@behrmann

Description

@behrmann

Summary

The class variable _fields_ on ctypes Structure objects, e.g.

class mount_attr(ctypes.Structure):
    _fields_ = [
        ("attr_set", ctypes.c_uint64),
        ("attr_clr", ctypes.c_uint64),
        ("propagation", ctypes.c_uint64),
        ("userns_fd", ctypes.c_uint64),
    ]

will trigger RUF012, but documentation says

The fields class variable can only be set once. Later assignments will raise an AttributeError.

so an exception to this rule would be helpful.

Metadata

Metadata

Assignees

Labels

ruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions