bswck / configzen

Manage configuration with pydantic.

Home Page:https://bswck.github.io/configzen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LinkedRoute

bswck opened this issue · comments

Use case

A config route that supports type-safety and runtime validation.

If we have

class ConfItem(BaseConfiguration):
    pair: tuple[int, int]


class Conf(BaseConfiguration):
    item: ConfItem

then instead of writing

Conf.at("item.pair[0]")

write

Conf.at(Conf.item.pair[0])

where

Conf.item.pair[0]

is in fact

LinkedRoute(Conf, Route([GetAttr("item"), GetAttr("pair"), GetItem(0)]))

at runtime.

Example usage

No response

Additional context

No response