Skip to content

Add dataclass tests #5159

Open
Open
@cdce8p

Description

@cdce8p

Current problem

from dataclasses import dataclass, field

@dataclass
class Expandable:
    _api: field()
    var = []

Desired solution

Detect invalid or problematic usage in dataclasses.

Some ideas

  • Invalid field call. It should be the value of the assignment
  • Missing type annotation
  • Missing use of field -> default_factory for mutable types. Careful of ClassVars as it might be intended for them.
  • Unsupported-version check as dataclasses require Python 3.7

--
It might be best to create a new checker class for it.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    CheckersRelated to a checkerEnhancement ✨Improvement to a componentHelp wanted 🙏Outside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationdataclasses

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions