Skip to content

Way to change defaults? #630

@quicknir

Description

@quicknir

I read this page on the mypy docs, https://mypy.readthedocs.io/en/stable/additional_features.html which says that you can't simply write a function like this:

def my_dataclass(cls):
    return attr.s(cls, auto_attribs=True)

And expect things to type check correctly.

Is there any convenient, mypy compatible way, to change defaults in attrs? I saw the RFC about defaults being inconvenient; better defaults (above all auto_attribs=True) will help but of course people will not necessarily agree on the best defaults, hence why being able to wrap it would be such a win.

It looks like pydantic has done it (https://github.com/samuelcolvin/pydantic/blob/master/pydantic/dataclasses.py), but it's hard for me to separate out the bits that are related to their extra functionality, from the bare minimum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions