load_yaml: Move module constants above functions
The compiled regular expressions _LINK_NAME_RE and _INCLUDE_PATH_RE are defined inline between the functions that use them, which scatters module-level state through the file. Move both of them to the top of the module, next to the IncludeSpec and Includes type aliases, and group them under a Constants section header so that all module-level definitions appear before the first function. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
69e53b3012
commit
7fc25e8ab3
1 changed files with 5 additions and 4 deletions
|
|
@ -8,9 +8,14 @@ from typing import Any, TypeAlias, cast
|
|||
|
||||
import yaml # type: ignore[import-untyped]
|
||||
|
||||
# -- Constants ------------------------------------------------------------------
|
||||
|
||||
IncludeSpec: TypeAlias = tuple[bool, Path, tuple[str, ...]]
|
||||
Includes: TypeAlias = list[IncludeSpec]
|
||||
|
||||
_LINK_NAME_RE = re.compile(r'^([a-zA-Z0-9_-]+)\|')
|
||||
_INCLUDE_PATH_RE = re.compile(r'^([a-zA-Z0-9_.|-]+)\|')
|
||||
|
||||
# -- Low-level helpers (call graph leaves) --------------------------------------
|
||||
|
||||
def _deep_merge(base: dict[str, Any], override: dict[str, Any]) -> dict[str, Any]:
|
||||
|
|
@ -22,8 +27,6 @@ def _deep_merge(base: dict[str, Any], override: dict[str, Any]) -> dict[str, Any
|
|||
ret[key] = deepcopy(val)
|
||||
return ret
|
||||
|
||||
_LINK_NAME_RE = re.compile(r'^([a-zA-Z0-9_-]+)\|')
|
||||
|
||||
def _parse_link(value: str) -> tuple[bool, str | None, str]:
|
||||
"""Parse a link value into (is_named, name_or_None, path_string).
|
||||
|
||||
|
|
@ -100,8 +103,6 @@ def _resolve_path(
|
|||
|
||||
# -- Include helpers ------------------------------------------------------------
|
||||
|
||||
_INCLUDE_PATH_RE = re.compile(r'^([a-zA-Z0-9_.|-]+)\|')
|
||||
|
||||
def _parse_include_spec(spec: str, parent: Path) -> IncludeSpec:
|
||||
if not spec:
|
||||
raise ValueError('Empty include spec')
|
||||
|
|
|
|||
Loading…
Reference in a new issue