topmark.toml.resolution¶
TopMark TOML source discovery and per-run TOML resolution helpers.
This module discovers TopMark-relevant TOML settings files in stable same-directory and upward-traversal precedence order, then optionally resolves those sources into a per-run TOML result.
Responsibilities
- discover user-scoped TopMark TOML sources
- discover project/local TOML sources by walking upward from an anchor path
- preserve same-directory precedence between
pyproject.tomlandtopmark.toml - honor per-directory
root = truestop markers while discovering sources - load discovered TOML sources through split parse
- resolve non-layered TOML settings such as writer preferences and config loading strictness using precedence rules
Typical discovery precedence (lowest -> highest, once later resolved): 1. built-in defaults 2. user-scoped TOML source 3. project/local TOML sources discovered upward from an anchor path 4. explicitly provided extra TOML sources
This module is intentionally separate from
topmark.config.resolution. That module owns
layered config provenance layers and
MutableConfig merge behavior; this
module owns TOML-source discovery and TOML-side per-run resolution.
TomlSourceKind
module-attribute
¶
Discovery kind for one resolved TopMark TOML source.
Allowed values
"user": discovered from the user-scoped config location"discovered": found by upward project/local TOML discovery"explicit": provided explicitly by the caller
ResolvedTopmarkTomlSource
dataclass
¶
One TopMark TOML source participating in per-run resolution.
A source may be syntactically invalid or unreadable. Such sources are still
preserved as resolved source records so TOML-source diagnostics can be
replayed into staged config validation. Only successfully parsed sources
contribute layered config fragments and TOML-side settings such as writer
options or strict.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path | SyntheticConfigSource
|
Resolved filesystem path of the TOML source. |
parsed |
ParsedTopmarkToml | None
|
Split-parsed TOML source contents, or |
kind |
TomlSourceKind
|
Discovery class of the source. Allowed values are |
validation_issues |
tuple[TomlValidationIssue, ...]
|
TOML schema validation issues associated with this source. For failed loads this is empty because no TOML schema validation could run. |
load_diagnostics |
FrozenDiagnosticLog
|
Diagnostics produced while loading or parsing the TOML source. This is normally empty for successfully parsed sources and contains a synthetic error for unreadable or invalid TOML files. |
ResolvedTopmarkTomlSources
dataclass
¶
Resolved TOML-side state across discovered TopMark TOML sources.
Attributes:
| Name | Type | Description |
|---|---|---|
sources |
list[ResolvedTopmarkTomlSource]
|
Loaded and split-parsed TopMark TOML source records in stable precedence order (lowest -> highest), excluding built-in defaults. |
writer_options |
WriterOptions | None
|
Resolved non-layered writer preferences using
highest-precedence non- |
strict |
bool | None
|
Resolved config-loading strictness using
highest-precedence non- |
resolve_topmark_toml_sources ¶
resolve_topmark_toml_sources(
input_paths=None,
extra_config_files=None,
strict=None,
no_config=False,
)
Discover, load, and resolve TopMark TOML sources for one run.
This helper resolves TOML-side settings only. It does not construct
ConfigLayer objects and does not merge layered config into a
MutableConfig.
Precedence order (lowest -> highest):
1. user-scoped TOML source
2. discovered project/local TOML sources (root-most -> nearest)
3. explicit extra TOML sources (in the order provided)
4. explicit strict function argument, if provided
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_paths
|
Iterable[Path] | None
|
Optional discovery anchors. The first path is used to pick the project-discovery starting directory. If it points to a file, its parent directory is used. If omitted, discovery falls back to the current working directory. |
None
|
extra_config_files
|
Iterable[Path] | None
|
Explicit TOML source files to append after discovered sources. Later files have higher precedence than earlier ones. |
None
|
strict
|
bool | None
|
Optional explicit override for resolved config loading strictness. |
None
|
no_config
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
ResolvedTopmarkTomlSources
|
The resolved TOML-side state across all successfully loaded sources. |