Convert schema-like objects to dataclasses
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 150
- Forks
- 23
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 2
Description
As well as incorporating enumerations (see #942), there are objects in the codebase where we could convert to further data classes in order to better encode and handle their schema-like nature. Though we should only do so if a genuinely useful case for the logic using them, to avoid over-engineering.
An immediate example I see is from the parallel dictionaries in the constants module, e.g. the formula term system, where the same key space for the CF-supported Parametric Vertical Coordinates are spread across four parallel dicts which each define constraints set out in Appendix D of the CF Conventions:
and where conversion to data classes of a template similar to the following would make the underlying schema explicit and improve readability/maintainability:
from dataclasses import dataclass
@dataclass(frozen=True)
class FormulaDefinition:
standard_names: dict
units: dict
max_dimensions: dict
computed_standard_names: dict
But we can systematically survey the codebase for further candidates, ideally at the same time as we plan #942.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the parallel dictionaries in constants.py, especially the formula term system and the CF-supported Parametric Vertical Coordinates section linked in the issue. Survey the codebase alongside issue #942 for other schema-like objects, and consider only candidates with a genuinely useful consumer; done means the worthwhile cases have explicit dataclass-based schemas without over-engineering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100