Skip to content

Automatically generate example config file(s) from a config schema #8

@emann

Description

@emann

Is your feature request related to a problem? Please describe.
It'd be nice to have a way to automatically generate an example yaml config file from a config schema to include in a project for future contributors. Not something necessary any time soon but would be a nice convenience.

Describe the solution you'd like

def generate_example_file(config_schema: ConfigSchema, path: Path = os.getcwd(), file_types: Optional[Set[str]]=None):
    ...

Generates an instance of the schema, then turns it into a dictionary with .dict() and dumps it into a file of each of the supplied file types (or all supported types if file_types is omitted) at the specified path. Example value precedence for each field would be the following:

  1. Default value
  2. Example value
  3. An example generated off of the type hints

Generating example values might get a little icky, but could be either unsupported initially or have minimal support, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions