Skip to content

RUF009 misses function call in dataclass default #16859

@bmyers-ozette

Description

@bmyers-ozette

Summary

The following code does not seem to trigger the linter rule RUF009.

@dataclasses.dataclass
class A:
    timestamp: str = dataclasses.field(default=datetime.datetime.utcnow().isoformat())

Based on the description of the rule, I was expecting this to get flagged to use default_factory.

Version

ruff 0.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing 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