You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've been using a feature of std library dataclasses that was released in Python 3.10: the kw_only parameter. This parameter avoids the problem, TypeError: non-default argument 'foo' follows default argument, which arises when a dataclass with non-default attributes inherits from one with default attributes. For example,
@dataclass(kw_only=True)classArchiveResource(Resource):
compression: str# no default value assigned here
Our Requirement:
We like to use default arguments -- attributes with default values assigned on init -- because we like our metadata documents to include all attributes, even ones that haven't yet been assigned a value. That way users editing the yaml by hand can add values without having to know all the attribute names.
Making these non-default arguments "keyword-only" means their positional order no longer matters.
But, in order to make geometamaker compatible with Python 3.9, we need a solution other than using kw_only, which satisfies our requirement. It's possible there might be a solution in Pydantic, which we're already planning to adopt for #29 .
The text was updated successfully, but these errors were encountered:
This is a requirement for a related invest issue: natcap/invest#1662
We've been using a feature of std library
dataclasses
that was released in Python 3.10: thekw_only
parameter. This parameter avoids the problem,TypeError: non-default argument 'foo' follows default argument
, which arises when a dataclass with non-default attributes inherits from one with default attributes. For example,Our Requirement:
We like to use default arguments -- attributes with default values assigned on init -- because we like our metadata documents to include all attributes, even ones that haven't yet been assigned a value. That way users editing the yaml by hand can add values without having to know all the attribute names.
Making these non-default arguments "keyword-only" means their positional order no longer matters.
But, in order to make geometamaker compatible with Python 3.9, we need a solution other than using
kw_only
, which satisfies our requirement. It's possible there might be a solution in Pydantic, which we're already planning to adopt for #29 .The text was updated successfully, but these errors were encountered: