Skip to content

keyword-only attrs #335

@asvetlov

Description

@asvetlov

It would be nice to support keyword-only constructor parameters, e.g.

@attr.s
class A:
    a = attr.ib()
    b = attr.ib(keyword=True)

A(1, 2)  # forbidden
A(1, b=2)  # passed

Should be allowed for Python 3 only.
Well, attrs should have no Python 3 specific code -- compilation of __init__ function with keyword-only arguments generates SyntaxError on Python 2, maybe enough.

I don't know what name is better: keyword, kw_only, keyword_only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions