Skip to content

Commit

Permalink
WIP Use dataclass for default config
Browse files Browse the repository at this point in the history
NOTE: This is currently blocked as OmegaConf does not yet fully support
Union in the types.  This is on the roadmap for 2.3 though:
omry/omegaconf#144
  • Loading branch information
luator committed Nov 11, 2022
1 parent d675c69 commit 2a791e8
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion breathing_cat/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import pathlib
import typing
from dataclasses import dataclass, field

import variconf
from omegaconf import OmegaConf
Expand All @@ -20,8 +21,29 @@
}


@dataclass
class DefaultConfig:
@dataclass
class Doxygen:
exclude_patterns: typing.List[str] = field(default_factory=list)

@dataclass
class Intersphinx:
# FIXME: Unions are currently not supported by OmegaConf. It is on the readmap
# for 2.3, though, so there is hope for the future :).
mapping: typing.Dict[str, typing.Union[typing.Dict[str, str], str]] = field(
default_factory=dict
)

# for compatibility of deprecated ${PACKAGE_DIR}
PACKAGE_DIR: str = "{{PACKAGE_DIR}}"

doxygen: Doxygen = Doxygen()
intersphinx: Intersphinx = Intersphinx()


def _get_config_loader() -> variconf.WConf:
return variconf.WConf(_DEFAULT_CONFIG, strict=False)
return variconf.WConf(DefaultConfig, strict=False)


def config_from_dict(config: dict) -> dict:
Expand Down

0 comments on commit 2a791e8

Please sign in to comment.