Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Python 3.9 #54

Closed
davemfish opened this issue Nov 20, 2024 · 0 comments · Fixed by #55
Closed

support Python 3.9 #54

davemfish opened this issue Nov 20, 2024 · 0 comments · Fixed by #55

Comments

@davemfish
Copy link
Collaborator

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: 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)
class ArchiveResource(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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant