-
-
Notifications
You must be signed in to change notification settings - Fork 410
Closed
Labels
Description
I want to be able to write both Message("message", timestamp=time.time()) and Message("message"), where timestamp is an attribute of a base class. Currently the following code:
@attrs
class Base:
timestamp = attrib(kw_only=True, default=None)
@attrs
class Message(Base):
message = attrib()
produces the following error:
ValueError: Non keyword-only attributes are not allowed after a keyword-only attribute.
As timestamp is keyword-only, it, as far as I understand, does not pose an ordering issue.
(In my particular use-case, I have a bunch of Messages that are convenient to create using positional arguments, but the timestamp field is not always meaningful, e.g. for outgoing messages)
chrisrink10 and trianta2