nkdsl.configsΒΆ

Configuration management for nkDSL.

This module provides a typed, environment-aware configuration system.

All nkDSL options are bound to environment variables with the prefix NKDSL_ and are matched case-insensitively for convenience.

The public singleton exported by this module is cfg.

Functions

cast(typ, val)

Cast a value to a type.

dataclass([cls, init, repr, eq, order, ...])

Add dunder methods based on the fields defined in the class.

dedent(text)

Remove any common leading whitespace from every line in text.

new_error_content(message, *args, **kwargs)

non_negative_int_validator(value)

Validates non-negative integers.

parse_bool(value)

Parses a boolean with permissive string handling.

parse_csv_tuple(value)

Parses a comma-separated value list into a tuple of strings.

parse_float(value)

Parses a float value.

parse_int(value)

Parses an integer value.

parse_optional_int(value)

Parses an optional integer.

parse_optional_string(value)

Parses an optional string.

positive_float_validator(value)

Validates strictly positive floats.

positive_int_validator(value)

Validates strictly positive integers.

replace(obj, /, **changes)

Return a new object replacing specified fields with new values.

Classes

Any(*args, **kwargs)

Special type indicating an unconstrained type.

ConfigManager()

Typed, hookable, and singleton configuration manager for nkDSL.

ConfigMutability(value)

Defines when a configuration option may be changed.

ConfigMutation(name, old_value, new_value, ...)

Represents a single effective configuration mutation event.

ConfigOption(name, default, doc[, ...])

Static declaration of one configuration option.

ConfigSource(value)

Describes where an observed configuration value originated.

Generic()

Abstract base class for generic types.

ReadOnlyDict

An immutable dictionary used for package-wide static variables.

TextIO()

Typed version of the return of open() in text mode.

TypeVar(name, *constraints[, bound, ...])

Type variable.

Exceptions

ConfigError(msg)

Base class for all nkDSL configuration errors.

ConfigValidationError(msg)

Raised when a configuration value fails parsing or validation.

UnknownOptionError(msg)

Raised when accessing or mutating an unknown configuration option.