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
{{ message }}
Repository navigation
Review classes and types - Configuration vs. PathSpec vs. Path (pydantic to the rescue) #26
Notes to self: (this ticket might explode out into a handful of separate ones)
It's gotten messy.
It's not 100% consistent what gets set as an instance attribute vs. getting looked up from the self.config dictionaries.
Lazy load configs - should not be afraid of creating a PDFBakerDocument because it immediately tries to load a config file.
There are types for typehints, and a PDFBakerOptions dataclass. Nothing really in terms of validating the YAML beyond its syntax. I'll go with Pydantic (2.11.3) and make these all BaseModel. That still serves the typehints but also adds validation when I instantiate with a value from YAML.
Implement this top-down. Make the Baker nice, then proceed to Document, then Page.
Absolute paths are not getting tested yet.
(tests should just create a temporary config then use its absolute path as the starting point)
Working with PathSpec (name/path/etc.) and Path vs. string (from YAML) is a general issue and should be handled in exactly one place. Special logic ("just a name" for document means directory with config.yaml, for page means {name}.yaml inside "pages" directory) can be delegated to subclasses.
After making a start in 563b726 on danny-pydantic
the big commit for the full refactoring is 4f23218
Still some way to go before this is ready to go live but it's about 90% there.
Activity
dannyadair commentedon Apr 25, 2025
After making a start in 563b726 on danny-pydantic
the big commit for the full refactoring is 4f23218
Still some way to go before this is ready to go live but it's about 90% there.
dannyadair commentedon Apr 28, 2025
Migration to pydantic models completed in 22e807a