From 7ba89a84a47b8073e300db48524b44db30c71c66 Mon Sep 17 00:00:00 2001 From: leynos Date: Sun, 16 Aug 2026 20:33:05 +0200 Subject: [PATCH] Normalize internal API spelling Rename internal spelling identifiers and call sites to Oxford `-ize` forms, and align diagnostics, test fixtures, and documentation. Refresh the generated spelling configuration so inline API references are checked. --- Makefile | 2 +- docs/developers-guide.md | 12 ++--- docs/documentation-style-guide.md | 2 +- docs/execplans/regenerate-lockfiles.md | 2 +- docs/lading-design.md | 6 +-- docs/roadmap.md | 2 +- docs/scripting-standards.md | 4 +- lading/cli.py | 8 ++-- lading/commands/bump.py | 4 +- lading/commands/publish.py | 16 +++---- lading/commands/publish_diagnostics.py | 44 +++++++++---------- lading/commands/publish_index_check.py | 2 +- lading/commands/publish_preflight.py | 4 +- lading/config.py | 6 +-- lading/runtime/runner.py | 4 +- lading/runtime/subprocess_runner.py | 14 +++--- lading/testing/cmd_mox_runner.py | 8 ++-- lading/utils/__init__.py | 4 +- lading/utils/path.py | 6 +-- lading/workspace/graph_build.py | 14 +++--- lading/workspace/metadata.py | 4 +- tests/bdd/features/cli.feature | 6 +-- tests/bdd/steps/test_bump_steps.py | 8 ++-- tests/bdd/steps/test_publish_given_steps.py | 12 ++--- .../bdd/steps/test_publish_infrastructure.py | 14 +++--- tests/unit/publish/test_command_helpers.py | 16 +++---- tests/unit/publish/test_formatting_helpers.py | 6 +-- tests/unit/publish/test_packaging.py | 6 +-- tests/unit/publish/test_phase_dispatch.py | 2 +- .../unit/publish/test_preflight_arguments.py | 8 ++-- .../publish/test_preflight_cargo_runner.py | 10 ++--- tests/unit/publish/test_preflight_checks.py | 10 ++--- .../unit/publish/test_publish_diagnostics.py | 42 +++++++++--------- .../publish/test_publish_execution_helpers.py | 4 +- tests/unit/publish/test_run_preflight.py | 4 +- .../unit/publish/test_run_workspace_config.py | 12 ++--- .../test_bump_lockfile_path_resolution.py | 6 +-- tests/unit/test_bump_manifest_updates.py | 4 +- tests/unit/test_cli.py | 8 ++-- tests/unit/test_config.py | 8 ++-- tests/unit/test_publish_staging.py | 16 +++---- .../unit/test_workspace_models_validation.py | 6 +-- tests/unit/utils/test_metrics.py | 4 +- tests/unit/utils/test_path.py | 28 ++++++------ typos.toml | 1 - 45 files changed, 204 insertions(+), 205 deletions(-) diff --git a/Makefile b/Makefile index befc6475..f6df0f1f 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ build: $(UV) .venv ## Build virtual-env and install deps build-release: build ## Build artefacts (sdist & wheel) $(UV) run python -m build --sdist --wheel -clean: ## Remove build artifacts +clean: ## Remove build artefacts rm -rf build dist *.egg-info \ .mypy_cache .pytest_cache .coverage coverage.* \ lcov.info htmlcov .venv diff --git a/docs/developers-guide.md b/docs/developers-guide.md index a05355a6..225cb2fc 100644 --- a/docs/developers-guide.md +++ b/docs/developers-guide.md @@ -366,15 +366,15 @@ property test in `tests/unit/test_bump_command_internals.py`, which exercises ### Workspace path normalization (`lading/utils/path.py`) -`normalise_workspace_root(value)` is the shared helper that turns a +`normalize_workspace_root(value)` is the shared helper that turns a user-supplied workspace root into a canonical `Path`. Import it from `lading.utils`: ```python -from lading.utils import normalise_workspace_root +from lading.utils import normalize_workspace_root -normalise_workspace_root("~/workspace") # -> absolute, ~ expanded -normalise_workspace_root(None) # -> Path.cwd().resolve() +normalize_workspace_root("~/workspace") # -> absolute, ~ expanded +normalize_workspace_root(None) # -> Path.cwd().resolve() ``` It accepts `Path`, `str`, or `None`. `None` selects the resolved current @@ -451,7 +451,7 @@ metadata = load_cargo_metadata(Path("/path/to/workspace")) print(metadata["workspace_root"]) ``` -The helper normalizes the workspace path with `normalise_workspace_root`, +The helper normalizes the workspace path with `normalize_workspace_root`, invokes `cargo metadata --format-version 1` through the active `CommandRunner`, and returns the parsed JSON mapping. Any execution errors or invalid output raise `CargoMetadataError` with a descriptive message, so callers can present @@ -647,7 +647,7 @@ canonical replacement callers and tests now use directly: | Removed shim | Location | Canonical replacement | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Eleven `publish_preflight` private aliases (`_preflight_argument_sets`, `_CargoPreflightOptions`, `_apply_compiletest_externs`, `_build_preflight_environment`, `_build_test_arguments`, `_compose_preflight_arguments`, `_normalise_test_excludes`, `_run_aux_build_commands`, `_run_cargo_preflight`, `_validate_lockfile_freshness`, `_verify_clean_working_tree`) | `publish.py` | `lading.commands.publish_preflight` (patch/call the defining module directly) | +| Eleven `publish_preflight` private aliases (`_preflight_argument_sets`, `_CargoPreflightOptions`, `_apply_compiletest_externs`, `_build_preflight_environment`, `_build_test_arguments`, `_compose_preflight_arguments`, `_normalize_test_excludes`, `_run_aux_build_commands`, `_run_cargo_preflight`, `_validate_lockfile_freshness`, `_verify_clean_working_tree`) | `publish.py` | `lading.commands.publish_preflight` (patch/call the defining module directly) | | `_run_preflight_checks` thin wrapper | `publish.py` | `publish_preflight._run_preflight_checks` (called directly by `run()`) | | Re-exports `_append_section`, `_format_plan` | `publish.py` | `publish_plan.append_section`, `publish_plan.format_plan` | | Re-export `metadata_module` | `publish.py` | `lading.workspace.metadata` | diff --git a/docs/documentation-style-guide.md b/docs/documentation-style-guide.md index be301f0a..2fa74de3 100644 --- a/docs/documentation-style-guide.md +++ b/docs/documentation-style-guide.md @@ -20,7 +20,7 @@ consistent, and easy to maintain across projects. - suffix -ogue in words such as _analogue_ and _catalogue_, - and so forth. - The words **"outwith"** and **"caveat"** are acceptable. -- Keep United States (US) spelling when used in an API, for example, `color`. +- Use Oxford spelling in internal APIs, for example, `colour`. - The project uses the filename `LICENSE` for community consistency. ## Punctuation and grammar diff --git a/docs/execplans/regenerate-lockfiles.md b/docs/execplans/regenerate-lockfiles.md index 7a68d48c..097b5afb 100644 --- a/docs/execplans/regenerate-lockfiles.md +++ b/docs/execplans/regenerate-lockfiles.md @@ -121,7 +121,7 @@ fixture lockfile and seeing that lockfile listed in the bump output with a - [x] (2026-07-07 12:20Z) Stage A: prototype proved `cargo update --workspace --manifest-path ` restores freshness for a nested fixture package with a path dependency on a bumped workspace crate. See - `Artifacts and notes`. No fallback command needed. + `Artefacts and notes`. No fallback command needed. - [x] (2026-07-07 13:10Z) Stage B: red tests landed and observed failing for the expected reasons — three new unit tests plus the two extended wiring tests failed with diff --git a/docs/lading-design.md b/docs/lading-design.md index d804162f..7ebb705f 100644 --- a/docs/lading-design.md +++ b/docs/lading-design.md @@ -106,7 +106,7 @@ lading [--workspace-root ] [options] - `--workspace-root` is implemented as a global flag that can be positioned before or after the subcommand. The bootstrapper removes the flag from the argument list, normalizes it via the shared - `lading.utils.normalise_workspace_root` helper (implemented with + `lading.utils.normalize_workspace_root` helper (implemented with `pathlib.Path` alone), and stores the resolved path in the `LADING_WORKSPACE_ROOT` environment variable so that Cyclopts can hydrate per-command options without bespoke parsing hooks. @@ -226,7 +226,7 @@ build scripts, and complex workspace configurations. - Workspace discovery is anchored in `lading.workspace.metadata`. The module invokes `cargo metadata --format-version 1` through the active `CommandRunner`, normalizing the workspace root via - `lading.utils.normalise_workspace_root` before invoking the command. + `lading.utils.normalize_workspace_root` before invoking the command. - Failures to locate the `cargo` executable raise `CargoExecutableNotFoundError`; non-zero exit codes raise `CargoMetadataInvocationError`; malformed JSON payloads raise @@ -602,7 +602,7 @@ lading/ ├── config.py # Frozen dataclasses for `lading.toml` ├── utils/ │ ├── __init__.py - │ └── path.py # Filesystem helpers such as `normalise_workspace_root` + │ └── path.py # Filesystem helpers such as `normalize_workspace_root` └── workspace/ ├── __init__.py ├── metadata.py # `cargo metadata` invocation and parsing diff --git a/docs/roadmap.md b/docs/roadmap.md index 01160bd6..39582e99 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -321,7 +321,7 @@ invocation and path utilities. - **Outcome:** Path normalization uses `pathlib.Path` directly, removing the `plumbum.local.path()` dependency. - - **Completion Criteria:** `normalise_workspace_root()` behaviour unchanged; + - **Completion Criteria:** `normalize_workspace_root()` behaviour unchanged; plumbum import removed from the module. ______________________________________________________________________ diff --git a/docs/scripting-standards.md b/docs/scripting-standards.md index 846ee5ab..8bc4e539 100644 --- a/docs/scripting-standards.md +++ b/docs/scripting-standards.md @@ -292,9 +292,9 @@ from pathlib import Path PROJECT_ROOT = Path(__file__).resolve().parents[1] DIST = PROJECT_ROOT / "dist" -(DIST / "artifacts").mkdir(parents=True, exist_ok=True) +(DIST / "artefacts").mkdir(parents=True, exist_ok=True) -# Portable joins and normalisation +# Portable joins and normalization cfg = PROJECT_ROOT.joinpath("config", "release.toml").resolve() ``` diff --git a/lading/cli.py b/lading/cli.py index a24a84ae..c629c331 100644 --- a/lading/cli.py +++ b/lading/cli.py @@ -42,7 +42,7 @@ WorkspaceRootOption, ) from .runtime import CommandRunner, subprocess_runner -from .utils import metrics, normalise_workspace_root +from .utils import metrics, normalize_workspace_root from .workspace import WorkspaceGraph, WorkspaceModelError, load_workspace from .workspace import metadata as metadata_module @@ -262,7 +262,7 @@ def main(argv: cabc.Sequence[str] | None = None) -> int: # an import-time side effect of lading.utils.metrics. metrics.register_summary_atexit() workspace_override, remaining = _extract_workspace_override(list(argv)) - workspace_root = normalise_workspace_root(workspace_override) + workspace_root = normalize_workspace_root(workspace_override) if not remaining: _dispatch_and_print(remaining) # Print usage message return 2 # Standard exit code for missing subcommand @@ -353,7 +353,7 @@ def bump( >>> "Dry run; would update version to 1.2.3 in" in summary # doctest: +SKIP True """ - resolved = normalise_workspace_root(workspace_root) + resolved = normalize_workspace_root(workspace_root) return _run_with_context( resolved, lambda root, configuration, workspace, command_runner: commands.bump.run( @@ -420,7 +420,7 @@ def publish( >>> readmes in summary # doctest: +SKIP True """ - resolved = normalise_workspace_root(workspace_root) + resolved = normalize_workspace_root(workspace_root) return _run_with_context( resolved, lambda root, configuration, workspace, command_runner: commands.publish.run( diff --git a/lading/commands/bump.py b/lading/commands/bump.py index 7c8cde22..0b57dc17 100644 --- a/lading/commands/bump.py +++ b/lading/commands/bump.py @@ -52,7 +52,7 @@ _workspace_dependency_sections, ) from lading.commands.bump_output import BumpChanges, _format_result_message -from lading.utils import normalise_workspace_root +from lading.utils import normalize_workspace_root if typ.TYPE_CHECKING: from pathlib import Path @@ -193,7 +193,7 @@ def _initialize_bump_context( ) -> _BumpContext: """Return the initialised bump context for ``workspace_root``.""" resolved_options = BumpOptions() if options is None else options - root_path = normalise_workspace_root(workspace_root) + root_path = normalize_workspace_root(workspace_root) configuration = resolved_options.configuration if configuration is None: configuration = config_module.current_configuration() diff --git a/lading/commands/publish.py b/lading/commands/publish.py index dd491bbb..a5497c5b 100644 --- a/lading/commands/publish.py +++ b/lading/commands/publish.py @@ -86,7 +86,7 @@ from lading.commands.publish_plan import ( PublishPlanError as PublishPlanError, # public re-export for plan_publication ) -from lading.utils.path import normalise_workspace_root +from lading.utils.path import normalize_workspace_root LOGGER = logging.getLogger(__name__) @@ -136,7 +136,7 @@ class PublishOptions: Defaults to :data:`False` so publishing remains a dry-run unless explicitly enabled. build_directory: - Optional directory used to stage workspace artifacts. When ``None``, + Optional directory used to stage workspace artefacts. When ``None``, a temporary directory is created for each invocation. preserve_symlinks: Control whether staging preserves symbolic links in the workspace @@ -180,10 +180,10 @@ class PublishPreparation: copied_readmes: tuple[Path, ...] -def _normalise_build_directory( +def _normalize_build_directory( workspace_root: Path, build_directory: Path | None ) -> Path: - """Return a directory suitable for staging workspace artifacts.""" + """Return a directory suitable for staging workspace artefacts.""" if build_directory is None: return Path(tempfile.mkdtemp(prefix="lading-publish-")) @@ -244,7 +244,7 @@ def prepare_workspace( PublishPreparationError If the staging build directory or copied workspace path is unsafe or invalid (for example nested within the workspace root); propagated - from :func:`_normalise_build_directory` and :func:`_copy_workspace_tree`. + from :func:`_normalize_build_directory` and :func:`_copy_workspace_tree`. Examples -------- @@ -253,7 +253,7 @@ def prepare_workspace( PosixPath('/tmp/lading-publish-abcd1234/my-workspace') """ active_options = PublishOptions() if options is None else options - build_directory = _normalise_build_directory( + build_directory = _normalize_build_directory( plan.workspace_root, active_options.build_directory ) LOGGER.info( @@ -550,7 +550,7 @@ def _execute_live_publication_pipeline( ) except PublishPreparationError as exc: # Preparation failures escape the preflight/publish error taxonomy; - # normalise them so the live pipeline reports a single abort class. + # normalize them so the live pipeline reports a single abort class. LOGGER.exception( "Live pipeline: aborted on crate %s — %d/%d crates completed (%s)", crate.name, @@ -712,7 +712,7 @@ def run( >>> "Staged workspace at:" in summary # doctest: +SKIP True """ - root_path = normalise_workspace_root(workspace_root) + root_path = normalize_workspace_root(workspace_root) LOGGER.info("Starting publish workflow for workspace %s", root_path) effective_options = PublishOptions() if options is None else options _validate_publication_options(effective_options) diff --git a/lading/commands/publish_diagnostics.py b/lading/commands/publish_diagnostics.py index 45fa2bc0..febde0b4 100644 --- a/lading/commands/publish_diagnostics.py +++ b/lading/commands/publish_diagnostics.py @@ -1,4 +1,4 @@ -"""Compiletest stderr artifact discovery and diagnostics formatting.""" +"""Compiletest stderr artefact discovery and diagnostics formatting.""" from __future__ import annotations @@ -8,22 +8,22 @@ _STDERR_PATTERN = re.compile(r"(/[^\s)]+\.stderr)") -def _trim_artifact_token(token: str) -> str: - """Normalise compiletest artifact tokens by stripping punctuation.""" +def _trim_artefact_token(token: str) -> str: + """Normalize compiletest artefact tokens by stripping punctuation.""" return token.rstrip(")]:,.;'\"") -def _discover_stderr_artifacts(stream: str) -> tuple[Path, ...]: +def _discover_stderr_artefacts(stream: str) -> tuple[Path, ...]: """Return ``Path`` objects extracted from compiletest output stream.""" - artifacts: list[Path] = [] + artefacts: list[Path] = [] seen: set[str] = set() for match in _STDERR_PATTERN.finditer(stream): - raw = _trim_artifact_token(match.group(1)) + raw = _trim_artefact_token(match.group(1)) if raw in seen: continue seen.add(raw) - artifacts.append(Path(raw)) - return tuple(artifacts) + artefacts.append(Path(raw)) + return tuple(artefacts) def _read_tail_lines(path: Path, count: int) -> tuple[str, ...]: @@ -38,13 +38,13 @@ def _read_tail_lines(path: Path, count: int) -> tuple[str, ...]: return tuple(lines[-count:]) if lines else () -def _format_artifact_diagnostics(artifact: Path, tail_lines: int) -> list[str]: - """Return formatted diagnostic lines for a compiletest stderr artifact.""" - lines = [f"- {artifact}"] - if not artifact.exists(): +def _format_artefact_diagnostics(artefact: Path, tail_lines: int) -> list[str]: + """Return formatted diagnostic lines for a compiletest stderr artefact.""" + lines = [f"- {artefact}"] + if not artefact.exists(): lines.append(" (file not found)") return lines - tail = _read_tail_lines(artifact, tail_lines) + tail = _read_tail_lines(artefact, tail_lines) if not tail: return lines header = f" Last {tail_lines} line(s):" @@ -60,22 +60,22 @@ def _append_compiletest_diagnostics( *, tail_lines: int, ) -> str: - """Append compiletest stderr artifact hints to ``message`` when present.""" - artifacts: list[Path] = [] + """Append compiletest stderr artefact hints to ``message`` when present.""" + artefacts: list[Path] = [] seen: set[Path] = set() for candidate in ( - *_discover_stderr_artifacts(stdout), - *_discover_stderr_artifacts(stderr), + *_discover_stderr_artefacts(stdout), + *_discover_stderr_artefacts(stderr), ): if candidate in seen: continue seen.add(candidate) - artifacts.append(candidate) - if not artifacts: + artefacts.append(candidate) + if not artefacts: return message - lines = [message, "Compiletest stderr artifacts:"] - for artifact in artifacts: - lines.extend(_format_artifact_diagnostics(artifact, tail_lines)) + lines = [message, "Compiletest stderr artefacts:"] + for artefact in artefacts: + lines.extend(_format_artefact_diagnostics(artefact, tail_lines)) return "\n".join(lines) diff --git a/lading/commands/publish_index_check.py b/lading/commands/publish_index_check.py index b5da7b86..f36afc5d 100644 --- a/lading/commands/publish_index_check.py +++ b/lading/commands/publish_index_check.py @@ -211,7 +211,7 @@ def _raise_unpublished_dependency_override_required( def _canonical_crate_name(name: str) -> str: - """Return the canonical crate name by normalising hyphens to underscores.""" + """Return the canonical crate name by normalizing hyphens to underscores.""" return name.replace("-", "_") diff --git a/lading/commands/publish_preflight.py b/lading/commands/publish_preflight.py index 1a8d79e2..30213366 100644 --- a/lading/commands/publish_preflight.py +++ b/lading/commands/publish_preflight.py @@ -271,7 +271,7 @@ def _preflight_argument_sets( return check_arguments, test_arguments -def _normalise_test_excludes(entries: cabc.Sequence[str]) -> tuple[str, ...]: +def _normalize_test_excludes(entries: cabc.Sequence[str]) -> tuple[str, ...]: """Return sorted, deduplicated, trimmed crate names for ``--exclude`` flags.""" return tuple(sorted({crate.strip() for crate in entries if crate.strip()})) @@ -281,7 +281,7 @@ def _build_test_arguments( ) -> list[str]: """Return cargo test arguments derived from ``options``.""" arguments = list(base_arguments) - for crate_name in _normalise_test_excludes(options.test_excludes): + for crate_name in _normalize_test_excludes(options.test_excludes): # Sorted unique values keep cargo invocations deterministic for tests/logging. arguments.extend(("--exclude", crate_name)) if options.unit_tests_only: diff --git a/lading/config.py b/lading/config.py index 238543f4..5d93635e 100644 --- a/lading/config.py +++ b/lading/config.py @@ -13,7 +13,7 @@ from lading import toml_coerce from lading.exceptions import LadingError -from lading.utils import normalise_workspace_root +from lading.utils import normalize_workspace_root if typ.TYPE_CHECKING: # pragma: no cover - type checking only from pathlib import Path @@ -385,7 +385,7 @@ def build_loader(workspace_root: Path) -> Toml: >>> build_loader(Path("workspace")).path.name 'lading.toml' """ - resolved = normalise_workspace_root(workspace_root) + resolved = normalize_workspace_root(workspace_root) return Toml( path=resolved / CONFIG_FILENAME, must_exist=False, @@ -516,7 +516,7 @@ def current_configuration() -> LadingConfig: def _strip_patches(value: object) -> StripPatchesSetting: - """Normalise the ``publish.strip_patches`` value.""" + """Normalize the ``publish.strip_patches`` value.""" if value is None: return "per-crate" if value in {"all", "per-crate"}: diff --git a/lading/runtime/runner.py b/lading/runtime/runner.py index 64db4a05..db85dc32 100644 --- a/lading/runtime/runner.py +++ b/lading/runtime/runner.py @@ -8,12 +8,12 @@ def coerce_text(value: str | bytes) -> str: - """Normalise process output to text. + """Normalize process output to text. Parameters ---------- value : str | bytes - Process output to normalise, as returned by a subprocess call. + Process output to normalize, as returned by a subprocess call. Returns ------- diff --git a/lading/runtime/subprocess_runner.py b/lading/runtime/subprocess_runner.py index e0f07ccd..cacdaa6a 100644 --- a/lading/runtime/subprocess_runner.py +++ b/lading/runtime/subprocess_runner.py @@ -132,7 +132,7 @@ def _spawn_process( program: str, command: tuple[str, ...], context: SubprocessContext, - normalised_env: dict[str, str] | None, + normalized_env: dict[str, str] | None, ) -> subprocess.Popen[bytes]: """Create a ``Popen`` instance, mapping ``OSError`` to ``CommandSpawnError``.""" try: @@ -142,7 +142,7 @@ def _spawn_process( return subprocess.Popen( # noqa: S603 # pylint: disable=consider-using-with command, cwd=None if context.cwd is None else str(context.cwd), - env=normalised_env, + env=normalized_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE if context.stdin_data is not None else None, @@ -208,8 +208,8 @@ def invoke_via_subprocess( # ``subprocess_runner`` via ``log_command_invocation``; only the # environment overrides are worth an extra DEBUG record here. _log_subprocess_environment(context.env) - normalised_env = normalise_environment(context.env) - process = _spawn_process(program, command, context, normalised_env) + normalized_env = normalize_environment(context.env) + process = _spawn_process(program, command, context, normalized_env) stdout_chunks: list[str] = [] stderr_chunks: list[str] = [] threads = [ @@ -236,7 +236,7 @@ def invoke_via_subprocess( return exit_code, "".join(stdout_chunks), "".join(stderr_chunks) -def normalise_environment( +def normalize_environment( env: cabc.Mapping[str, object] | None, ) -> dict[str, str] | None: """Return ``env`` with stringified values to satisfy ``subprocess``. @@ -255,9 +255,9 @@ def normalise_environment( Examples -------- - >>> normalise_environment({"PATH": "/usr/bin", "PORT": 8080}) + >>> normalize_environment({"PATH": "/usr/bin", "PORT": 8080}) {'PATH': '/usr/bin', 'PORT': '8080'} - >>> normalise_environment(None) is None + >>> normalize_environment(None) is None True """ if env is None: diff --git a/lading/testing/cmd_mox_runner.py b/lading/testing/cmd_mox_runner.py index 266e0154..6364a0f6 100644 --- a/lading/testing/cmd_mox_runner.py +++ b/lading/testing/cmd_mox_runner.py @@ -5,7 +5,7 @@ invocations through recorded cmd-mox expectations instead of spawning real subprocesses. :func:`cmd_mox_runner` is the adapter entry point: it validates the cmd-mox environment (the IPC socket path and the ``CMOX_IPC_TIMEOUT`` -timeout), normalises cargo subcommands to the namespaced names cmd-mox +timeout), normalizes cargo subcommands to the namespaced names cmd-mox expects, sends the invocation over the IPC socket, and runs passthrough directives locally through :mod:`lading.runtime.subprocess_runner` so streaming output is preserved. @@ -105,7 +105,7 @@ def cmd_mox_runner( Notes ----- - Timeout validation, command splitting, command normalisation, environment + Timeout validation, command splitting, command normalization, environment construction, IPC invocation, passthrough handling, and response processing are delegated to the focused helpers in this module. @@ -117,7 +117,7 @@ def cmd_mox_runner( """ timeout = _prepare_cmd_mox_context() program, args = split_command(command) - invocation_program, invocation_args = normalise_cmd_mox_command(program, args) + invocation_program, invocation_args = normalize_cmd_mox_command(program, args) invocation = ipc.Invocation( command=invocation_program, args=invocation_args, @@ -198,7 +198,7 @@ def _process_cmd_mox_response( return exit_code, stdout_text, stderr_text -def normalise_cmd_mox_command( +def normalize_cmd_mox_command( program: str, args: tuple[str, ...], ) -> tuple[str, list[str]]: diff --git a/lading/utils/__init__.py b/lading/utils/__init__.py index 705c52f2..9022a829 100644 --- a/lading/utils/__init__.py +++ b/lading/utils/__init__.py @@ -3,6 +3,6 @@ from __future__ import annotations from .commands import CARGO, GIT, LADING_CATALOGUE -from .path import normalise_workspace_root +from .path import normalize_workspace_root -__all__ = ["CARGO", "GIT", "LADING_CATALOGUE", "normalise_workspace_root"] +__all__ = ["CARGO", "GIT", "LADING_CATALOGUE", "normalize_workspace_root"] diff --git a/lading/utils/path.py b/lading/utils/path.py index 775cb2fe..54bac21e 100644 --- a/lading/utils/path.py +++ b/lading/utils/path.py @@ -5,7 +5,7 @@ from pathlib import Path -def normalise_workspace_root(value: Path | str | None) -> Path: +def normalize_workspace_root(value: Path | str | None) -> Path: """Return an absolute workspace path with ``~`` expanded. Parameters @@ -22,9 +22,9 @@ def normalise_workspace_root(value: Path | str | None) -> Path: Examples -------- - >>> normalise_workspace_root("~/workspace").is_absolute() + >>> normalize_workspace_root("~/workspace").is_absolute() True - >>> normalise_workspace_root(None) == Path.cwd().resolve() + >>> normalize_workspace_root(None) == Path.cwd().resolve() True """ if value is None: diff --git a/lading/workspace/graph_build.py b/lading/workspace/graph_build.py index 4343c921..698979e7 100644 --- a/lading/workspace/graph_build.py +++ b/lading/workspace/graph_build.py @@ -107,7 +107,7 @@ def build_workspace_graph( workspace_root_value = metadata["workspace_root"] except KeyError as exc: raise WorkspaceModelError(WORKSPACE_ROOT_MISSING_MSG) from exc - workspace_root = _normalise_workspace_root(workspace_root_value) + workspace_root = _normalize_workspace_root(workspace_root_value) packages = _expect_sequence(metadata.get("packages"), "packages", allow_none=False) workspace_members = _expect_sequence( metadata.get("workspace_members"), "workspace_members", allow_none=False @@ -165,7 +165,7 @@ def _build_crate( package_id = _expect_string(package.get("id"), "packages[].id") name = _expect_string(package.get("name"), f"package {package_id!r} name") version = _expect_string(package.get("version"), f"package {package_id!r} version") - manifest_path = _normalise_manifest_path( + manifest_path = _normalize_manifest_path( package.get("manifest_path"), f"package {package_id!r} manifest_path" ) dependencies = _build_dependencies(package, workspace_index) @@ -246,7 +246,7 @@ def _validate_workspace_dependency_path( return True if not isinstance(dependency_path, str): return False - target_manifest_path = _normalise_manifest_path( + target_manifest_path = _normalize_manifest_path( target_package.get("manifest_path"), "dependency target manifest_path", ) @@ -350,19 +350,19 @@ def _dependency_manifest_name( ) -def _normalise_workspace_root(value: object) -> Path: +def _normalize_workspace_root(value: object) -> Path: """Return ``value`` as an absolute workspace root path.""" if not isinstance(value, str | Path): message = ( f"workspace_root must be a path string; received {type(value).__name__}" ) raise WorkspaceModelError(message) - from lading.utils.path import normalise_workspace_root + from lading.utils.path import normalize_workspace_root - return normalise_workspace_root(value) + return normalize_workspace_root(value) -def _normalise_manifest_path(value: object, field_name: str) -> Path: +def _normalize_manifest_path(value: object, field_name: str) -> Path: """Return ``value`` as an absolute :class:`Path` to a manifest.""" if not isinstance(value, str | Path): message = f"{field_name} must be a path string; received {type(value).__name__}" diff --git a/lading/workspace/metadata.py b/lading/workspace/metadata.py index 3e36e4c8..f0a21f7a 100644 --- a/lading/workspace/metadata.py +++ b/lading/workspace/metadata.py @@ -31,7 +31,7 @@ coerce_text, subprocess_runner, ) -from lading.utils import normalise_workspace_root +from lading.utils import normalize_workspace_root from lading.utils.process import command_detail if typ.TYPE_CHECKING: # pragma: no cover - import-time typing aids only @@ -170,7 +170,7 @@ def load_cargo_metadata( >>> metadata["workspace_root"] # doctest: +SKIP '...' """ # noqa: DOC502 -- propagated from the two _*_cargo_metadata helpers - root_path = normalise_workspace_root(workspace_root) + root_path = normalize_workspace_root(workspace_root) command_runner = _active_command_runner(runner) exit_code, stdout_text, stderr_text = _invoke_cargo_metadata( command_runner, root_path diff --git a/tests/bdd/features/cli.feature b/tests/bdd/features/cli.feature index 644d23f9..5cffc6a2 100644 --- a/tests/bdd/features/cli.feature +++ b/tests/bdd/features/cli.feature @@ -295,14 +295,14 @@ Feature: Lading CLI scaffolding When I invoke lading publish with that workspace Then the cargo test pre-flight env includes "--extern lint_macro" in RUSTFLAGS - Scenario: Publish surfaces compiletest stderr artifacts + Scenario: Publish surfaces compiletest stderr artefacts Given a workspace directory with configuration And cargo metadata describes a sample workspace And preflight.stderr_tail_lines is 1 - And cargo test fails with compiletest artifact "ui.stderr" + And cargo test fails with compiletest artefact "ui.stderr" When I invoke lading publish with that workspace Then the CLI exits with code 1 - And the stderr contains "Compiletest stderr artifacts" + And the stderr contains "Compiletest stderr artefacts" And the stderr contains "ui.stderr" And the stderr contains "line2" diff --git a/tests/bdd/steps/test_bump_steps.py b/tests/bdd/steps/test_bump_steps.py index b1d2070c..e7735dd8 100644 --- a/tests/bdd/steps/test_bump_steps.py +++ b/tests/bdd/steps/test_bump_steps.py @@ -304,9 +304,9 @@ def then_documentation_contains( ) -> None: """Assert that ``expected`` appears in the specified documentation file.""" doc_path = cli_run["workspace"] / relative_path - normalised_expected = expected.replace(r"\"", '"') + normalized_expected = expected.replace(r"\"", '"') contents = doc_path.read_text(encoding="utf-8") - assert normalised_expected in contents + assert normalized_expected in contents @then(parsers.parse('the crate "{crate_name}" README contains "{expected}"')) @@ -315,9 +315,9 @@ def then_crate_readme_contains( ) -> None: """Assert that the adopted crate README contains ``expected``.""" readme_path = cli_run["workspace"] / "crates" / crate_name / "README.md" - normalised_expected = expected.replace(r"\"", '"') + normalized_expected = expected.replace(r"\"", '"') contents = readme_path.read_text(encoding="utf-8") - assert normalised_expected in contents + assert normalized_expected in contents @given(parsers.parse('the workspace README contains a relative link to "{target}"')) diff --git a/tests/bdd/steps/test_publish_given_steps.py b/tests/bdd/steps/test_publish_given_steps.py index 1878adf0..3812a897 100644 --- a/tests/bdd/steps/test_publish_given_steps.py +++ b/tests/bdd/steps/test_publish_given_steps.py @@ -127,19 +127,19 @@ def given_publish_preflight_finds_multiple_stale_lockfiles( ) -@given(parsers.parse('cargo test fails with compiletest artifact "{relative_path}"')) -def given_cargo_test_fails_with_artifact( +@given(parsers.parse('cargo test fails with compiletest artefact "{relative_path}"')) +def given_cargo_test_fails_with_artefact( workspace_directory: Path, preflight_overrides: dict[tuple[str, ...], ResponseProvider], relative_path: str, ) -> None: """Create ``relative_path`` and configure cargo test to reference it.""" - artifact = workspace_directory / relative_path - artifact.parent.mkdir(parents=True, exist_ok=True) - artifact.write_text("line1\nline2\n", encoding="utf-8") + artefact = workspace_directory / relative_path + artefact.parent.mkdir(parents=True, exist_ok=True) + artefact.write_text("line1\nline2\n", encoding="utf-8") preflight_overrides["cargo", "test", "--workspace"] = _CommandResponse( exit_code=1, - stderr=f"diff at {artifact}", + stderr=f"diff at {artefact}", ) diff --git a/tests/bdd/steps/test_publish_infrastructure.py b/tests/bdd/steps/test_publish_infrastructure.py index 439582ca..894b6f66 100644 --- a/tests/bdd/steps/test_publish_infrastructure.py +++ b/tests/bdd/steps/test_publish_infrastructure.py @@ -10,7 +10,7 @@ import pytest -from lading.testing.cmd_mox_runner import normalise_cmd_mox_command +from lading.testing.cmd_mox_runner import normalize_cmd_mox_command try: from cmd_mox import CmdMox @@ -132,11 +132,11 @@ def _resolve_preflight_expectation( program, *args = command argument_tuple = tuple(args) if program == "cargo": - normalised_program, invocation_args = normalise_cmd_mox_command( + normalized_program, invocation_args = normalize_cmd_mox_command( program, argument_tuple, ) - return normalised_program, tuple(invocation_args) + return normalized_program, tuple(invocation_args) return program, argument_tuple @@ -250,7 +250,7 @@ def _create_stub_config( ) -def _normalise_preflight_responses( +def _normalize_preflight_responses( config: _PreflightStubConfig, ) -> dict[tuple[str, ...], ResponseProvider]: """First publish override wins; package/publish --allow-dirty follows config.""" @@ -318,7 +318,7 @@ def _register_preflight_commands( config: _PreflightStubConfig, ) -> None: """Install cmd-mox doubles for publish pre-flight commands.""" - defaults = _normalise_preflight_responses(config) + defaults = _normalize_preflight_responses(config) git_responses = { command[1:]: response for command, response in defaults.items() @@ -435,12 +435,12 @@ def _invoke_publish_with_options( ), ], ) -def test_resolve_preflight_expectation_normalises_cargo_commands( +def test_resolve_preflight_expectation_normalizes_cargo_commands( command: tuple[str, ...], expected_program: str, expected_args_prefix: tuple[str, ...], ) -> None: - """Ensure cmd-mox expectations follow publish command normalisation.""" + """Ensure cmd-mox expectations follow publish command normalization.""" program, args_prefix = _resolve_preflight_expectation(command) assert program == expected_program diff --git a/tests/unit/publish/test_command_helpers.py b/tests/unit/publish/test_command_helpers.py index e9caeb05..59f129fa 100644 --- a/tests/unit/publish/test_command_helpers.py +++ b/tests/unit/publish/test_command_helpers.py @@ -9,15 +9,15 @@ from lading import cli from lading.runtime import subprocess_runner from lading.testing import cmd_mox_runner -from lading.testing.cmd_mox_runner import normalise_cmd_mox_command +from lading.testing.cmd_mox_runner import normalize_cmd_mox_command execution = importlib.import_module("lading.runtime.subprocess_runner") -def test_normalise_environment_handles_none_and_values() -> None: - """Environment normalisation should coerce values to strings.""" - assert execution.normalise_environment(None) is None - assert execution.normalise_environment({"ALPHA": 1}) == {"ALPHA": "1"} +def test_normalize_environment_handles_none_and_values() -> None: + """Environment normalization should coerce values to strings.""" + assert execution.normalize_environment(None) is None + assert execution.normalize_environment({"ALPHA": 1}) == {"ALPHA": "1"} def test_format_thread_name_sanitises_paths() -> None: @@ -96,15 +96,15 @@ def test_echo_buffered_output_skips_empty_payloads() -> None: ), ], ) -def test_normalise_cmd_mox_command_forwards_non_cargo_commands( +def test_normalize_cmd_mox_command_forwards_non_cargo_commands( command: tuple[str, ...], expected_program: str, expected_args: list[str], ) -> None: - """cmd-mox normalisation preserves non-cargo commands and arguments.""" + """cmd-mox normalization preserves non-cargo commands and arguments.""" program, args = command[0], tuple(command[1:]) - rewritten_program, rewritten_args = normalise_cmd_mox_command(program, args) + rewritten_program, rewritten_args = normalize_cmd_mox_command(program, args) assert rewritten_program == expected_program assert rewritten_args == expected_args diff --git a/tests/unit/publish/test_formatting_helpers.py b/tests/unit/publish/test_formatting_helpers.py index c6bca89a..cca4634d 100644 --- a/tests/unit/publish/test_formatting_helpers.py +++ b/tests/unit/publish/test_formatting_helpers.py @@ -154,7 +154,7 @@ def test_render_section_invariants( ) -def _normalise_plan_message(message: str, root: Path) -> str: +def _normalize_plan_message(message: str, root: Path) -> str: """Replace the absolute workspace root so snapshots stay deterministic.""" return message.replace(str(root), "") @@ -174,7 +174,7 @@ def test_format_plan_snapshot_with_publishable( message = publish_plan.format_plan(plan, strip_patches="all") - assert snapshot == _normalise_plan_message(message, root), ( + assert snapshot == _normalize_plan_message(message, root), ( "rendered plan with publishable and skipped crates matches the snapshot" ) @@ -194,6 +194,6 @@ def test_format_plan_snapshot_without_publishable( message = publish_plan.format_plan(plan, strip_patches="per-crate") - assert snapshot == _normalise_plan_message(message, root), ( + assert snapshot == _normalize_plan_message(message, root), ( "empty publish set renders the empty-state plan snapshot" ) diff --git a/tests/unit/publish/test_packaging.py b/tests/unit/publish/test_packaging.py index 56d1d9f6..38303c70 100644 --- a/tests/unit/publish/test_packaging.py +++ b/tests/unit/publish/test_packaging.py @@ -464,9 +464,9 @@ def runner( env: cabc.Mapping[str, str] | None = None, ) -> tuple[int, str, str]: del env - normalised = tuple(command) - calls.append((normalised, cwd)) - if normalised[:2] == ("cargo", "package") and cwd == beta_root: + normalized = tuple(command) + calls.append((normalized, cwd)) + if normalized[:2] == ("cargo", "package") and cwd == beta_root: return 1, "", "packaging failed" return 0, "", "" diff --git a/tests/unit/publish/test_phase_dispatch.py b/tests/unit/publish/test_phase_dispatch.py index 2875ff12..6c580d03 100644 --- a/tests/unit/publish/test_phase_dispatch.py +++ b/tests/unit/publish/test_phase_dispatch.py @@ -126,7 +126,7 @@ def test_missing_dep_later_in_publish_order_raises( ) -def test_missing_dep_in_plan_allows_cargo_name_normalisation( +def test_missing_dep_in_plan_allows_cargo_name_normalization( tmp_path: Path, caplog: pytest.LogCaptureFixture, ) -> None: diff --git a/tests/unit/publish/test_preflight_arguments.py b/tests/unit/publish/test_preflight_arguments.py index e7de428a..ee884aba 100644 --- a/tests/unit/publish/test_preflight_arguments.py +++ b/tests/unit/publish/test_preflight_arguments.py @@ -83,22 +83,22 @@ def test_build_test_arguments_skips_blank_entries_with_valid_names() -> None: assert result[-4:] == ["--exclude", "alpha", "--exclude", "beta"] -def test_normalise_test_excludes_sorts_and_deduplicates() -> None: +def test_normalize_test_excludes_sorts_and_deduplicates() -> None: """The normalization helper returns trimmed, sorted unique names.""" entries = (" beta", "alpha ", "alpha", "gamma") - assert publish_preflight._normalise_test_excludes(entries) == ( + assert publish_preflight._normalize_test_excludes(entries) == ( "alpha", "beta", "gamma", ) -def test_normalise_test_excludes_handles_empty_values() -> None: +def test_normalize_test_excludes_handles_empty_values() -> None: """Blank strings are ignored when normalizing test excludes.""" entries = ("", " \t", "alpha", "", "beta") - assert publish_preflight._normalise_test_excludes(entries) == ("alpha", "beta") + assert publish_preflight._normalize_test_excludes(entries) == ("alpha", "beta") # --------------------------------------------------------------------------- diff --git a/tests/unit/publish/test_preflight_cargo_runner.py b/tests/unit/publish/test_preflight_cargo_runner.py index 111d1ee0..a35e3b2d 100644 --- a/tests/unit/publish/test_preflight_cargo_runner.py +++ b/tests/unit/publish/test_preflight_cargo_runner.py @@ -215,10 +215,10 @@ def test_run_cargo_preflight_command_arguments( def test_compiletest_diagnostic_details( monkeypatch: pytest.MonkeyPatch, tmp_path: Path ) -> None: - """Failing cargo test pre-flight lists stderr artifacts with tail output.""" + """Failing cargo test pre-flight lists stderr artefacts with tail output.""" monkeypatch.setattr(publish_preflight, "_run_preflight_checks", ORIGINAL_PREFLIGHT) - artifact = tmp_path / "ui.stderr" - artifact.write_text("line1\nline2\nline3\n", encoding="utf-8") + artefact = tmp_path / "ui.stderr" + artefact.write_text("line1\nline2\nline3\n", encoding="utf-8") def failing_runner( command: tuple[str, ...], @@ -226,7 +226,7 @@ def failing_runner( cwd: Path | None = None, env: cabc.Mapping[str, str] | None = None, ) -> tuple[int, str, str]: - return 1, f"diff at {artifact}", "" + return 1, f"diff at {artefact}", "" options = publish_preflight._CargoPreflightOptions( extra_args=("--workspace",), @@ -242,6 +242,6 @@ def failing_runner( ) message = str(excinfo.value) - assert str(artifact) in message + assert str(artefact) in message assert "line2" in message assert "line3" in message diff --git a/tests/unit/publish/test_preflight_checks.py b/tests/unit/publish/test_preflight_checks.py index cfde892e..c88767cf 100644 --- a/tests/unit/publish/test_preflight_checks.py +++ b/tests/unit/publish/test_preflight_checks.py @@ -232,9 +232,9 @@ def test_preflight_append_compiletest_externs( monkeypatch.setattr(publish_preflight, "_run_preflight_checks", ORIGINAL_PREFLIGHT) root = tmp_path / "workspace" root.mkdir() - artifact = root / "target" / "lint" / "liblint_macro.so" - artifact.parent.mkdir(parents=True, exist_ok=True) - artifact.touch() + artefact = root / "target" / "lint" / "liblint_macro.so" + artefact.parent.mkdir(parents=True, exist_ok=True) + artefact.touch() rustflags: list[str] = [] def recording_runner( @@ -259,7 +259,7 @@ def recording_runner( ) configuration = make_config( preflight=make_preflight_config( - compiletest_externs=(("lint_macro", artifact.relative_to(root).as_posix()),) + compiletest_externs=(("lint_macro", artefact.relative_to(root).as_posix()),) ) ) @@ -273,7 +273,7 @@ def recording_runner( assert rustflags, "Expected cargo test env to include RUSTFLAGS" last_flags = rustflags[-1] assert "--extern lint_macro" in last_flags - assert str(artifact) in last_flags + assert str(artefact) in last_flags def test_verify_clean_working_tree_detects_dirty_state( diff --git a/tests/unit/publish/test_publish_diagnostics.py b/tests/unit/publish/test_publish_diagnostics.py index 65fc5294..08f3bf48 100644 --- a/tests/unit/publish/test_publish_diagnostics.py +++ b/tests/unit/publish/test_publish_diagnostics.py @@ -12,31 +12,31 @@ def test_append_compiletest_diagnostics_includes_tail_lines(tmp_path: Path) -> None: - """When artifacts exist, the tail of the file should be appended.""" - artifact = tmp_path / "ui.stderr" - artifact.write_text("line1\nline2\n", encoding="utf-8") + """When artefacts exist, the tail of the file should be appended.""" + artefact = tmp_path / "ui.stderr" + artefact.write_text("line1\nline2\n", encoding="utf-8") message = publish_diagnostics._append_compiletest_diagnostics( "Pre-flight failed", - stdout=str(artifact), + stdout=str(artefact), stderr="", tail_lines=1, ) - assert "Compiletest stderr artifacts" in message + assert "Compiletest stderr artefacts" in message assert "ui.stderr" in message assert "line2" in message -def test_append_compiletest_diagnostics_handles_missing_artifact( +def test_append_compiletest_diagnostics_handles_missing_artefact( tmp_path: Path, ) -> None: - """Missing artifacts should still be reported without raising.""" - artifact = tmp_path / "missing.stderr" + """Missing artefacts should still be reported without raising.""" + artefact = tmp_path / "missing.stderr" message = publish_diagnostics._append_compiletest_diagnostics( "Failure", - stdout=str(artifact), + stdout=str(artefact), stderr="", tail_lines=2, ) @@ -45,7 +45,7 @@ def test_append_compiletest_diagnostics_handles_missing_artifact( def test_append_compiletest_diagnostics_no_matches_returns_message() -> None: - """When no artifacts are present the original message should be returned.""" + """When no artefacts are present the original message should be returned.""" message = publish_diagnostics._append_compiletest_diagnostics( "Failure", stdout="", stderr="", tail_lines=2 ) @@ -53,11 +53,11 @@ def test_append_compiletest_diagnostics_no_matches_returns_message() -> None: assert message == "Failure" -def test_append_compiletest_diagnostics_deduplicates_artifacts(tmp_path: Path) -> None: - """Duplicate artifact tokens should only be reported once.""" - artifact = tmp_path / "dupe.stderr" - artifact.write_text("line\n", encoding="utf-8") - stdout = f"{artifact} {artifact})" +def test_append_compiletest_diagnostics_deduplicates_artefacts(tmp_path: Path) -> None: + """Duplicate artefact tokens should only be reported once.""" + artefact = tmp_path / "dupe.stderr" + artefact.write_text("line\n", encoding="utf-8") + stdout = f"{artefact} {artefact})" message = publish_diagnostics._append_compiletest_diagnostics( "Failure", stdout=stdout, stderr="", tail_lines=1 @@ -81,11 +81,11 @@ def _raise(*args: object, **kwargs: object) -> str: assert publish_diagnostics._read_tail_lines(bogus_path, 2) == () -def test_format_artifact_diagnostics_when_no_tail(tmp_path: Path) -> None: - """Artifacts without content should still list the path.""" - artifact = tmp_path / "empty.stderr" - artifact.write_text("", encoding="utf-8") +def test_format_artefact_diagnostics_when_no_tail(tmp_path: Path) -> None: + """Artefacts without content should still list the path.""" + artefact = tmp_path / "empty.stderr" + artefact.write_text("", encoding="utf-8") - lines = publish_diagnostics._format_artifact_diagnostics(artifact, tail_lines=2) + lines = publish_diagnostics._format_artefact_diagnostics(artefact, tail_lines=2) - assert lines == [f"- {artifact}"] + assert lines == [f"- {artefact}"] diff --git a/tests/unit/publish/test_publish_execution_helpers.py b/tests/unit/publish/test_publish_execution_helpers.py index 38f13a62..66fca56c 100644 --- a/tests/unit/publish/test_publish_execution_helpers.py +++ b/tests/unit/publish/test_publish_execution_helpers.py @@ -342,9 +342,9 @@ def test_invoke_via_subprocess_writes_stdin() -> None: assert stderr == "" -def test_normalise_environment_stringifies_values() -> None: +def test_normalize_environment_stringifies_values() -> None: """Environment dictionaries should be coerced to string values.""" - result = subprocess_runner.normalise_environment({"PATH": Path.cwd()}) + result = subprocess_runner.normalize_environment({"PATH": Path.cwd()}) assert result == {"PATH": str(Path.cwd())} diff --git a/tests/unit/publish/test_run_preflight.py b/tests/unit/publish/test_run_preflight.py index 54241526..9f60b2fe 100644 --- a/tests/unit/publish/test_run_preflight.py +++ b/tests/unit/publish/test_run_preflight.py @@ -22,7 +22,7 @@ @dc.dataclass(frozen=True) class _ExcludeScenario: - """Bundled parameters for a single exclude-normalisation scenario.""" + """Bundled parameters for a single exclude-normalization scenario.""" configured_excludes: tuple[str, ...] expected_excludes: tuple[str, ...] @@ -110,7 +110,7 @@ def fake_invoke( ) -# Run every exclude-normalisation scenario in both ``unit_tests_only`` modes so +# Run every exclude-normalization scenario in both ``unit_tests_only`` modes so # the builder's exclude handling is verified to be identical regardless of the # target-narrowing flag. EXCLUDE_MODE_SCENARIOS = tuple( diff --git a/tests/unit/publish/test_run_workspace_config.py b/tests/unit/publish/test_run_workspace_config.py index 86d9a01b..36ac7068 100644 --- a/tests/unit/publish/test_run_workspace_config.py +++ b/tests/unit/publish/test_run_workspace_config.py @@ -18,7 +18,7 @@ from syrupy.assertion import SnapshotAssertion -def test_run_normalises_workspace_root( +def test_run_normalizes_workspace_root( monkeypatch: pytest.MonkeyPatch, tmp_path: Path ) -> None: """The run helper resolves the workspace root before planning.""" @@ -94,13 +94,13 @@ def capture_load(path: Path) -> config_module.LadingConfig: ) -def _normalise_summary(message: str, root: Path) -> str: +def _normalize_summary(message: str, root: Path) -> str: """Redact non-deterministic paths so snapshots are stable across runs.""" - normalised = message.replace(str(root), "") + normalized = message.replace(str(root), "") return re.sub( r"^Staged workspace at: .*$", "Staged workspace at: ", - normalised, + normalized, flags=re.MULTILINE, ) @@ -116,7 +116,7 @@ def test_run_formats_plan_summary(tmp_path: Path, snapshot: SnapshotAssertion) - message = publish.run(root, configuration, workspace) - assert _normalise_summary(message, root) == snapshot + assert _normalize_summary(message, root) == snapshot def test_run_reports_no_publishable_crates( @@ -134,7 +134,7 @@ def test_run_reports_no_publishable_crates( message = publish.run(root, configuration, workspace) - assert _normalise_summary(message, root) == snapshot + assert _normalize_summary(message, root) == snapshot def test_run_surfaces_missing_workspace( diff --git a/tests/unit/test_bump_lockfile_path_resolution.py b/tests/unit/test_bump_lockfile_path_resolution.py index 4004ddb7..b7ab8c99 100644 --- a/tests/unit/test_bump_lockfile_path_resolution.py +++ b/tests/unit/test_bump_lockfile_path_resolution.py @@ -62,7 +62,7 @@ def _inside_dir(draw: st.DrawFn) -> list[str]: for _ in range(length): options = [_SEGMENT, st.just(".")] # Emit ".." only while a real segment remains to cancel it. This - # exercises safe traversal without allowing normalisation above root. + # exercises safe traversal without allowing normalization above root. if depth > 0: options.append(st.just("..")) segment = draw(st.one_of(*options)) @@ -75,7 +75,7 @@ def _inside_dir(draw: st.DrawFn) -> list[str]: # Relative directory paths that stay inside the workspace, optionally with -# redundant "." segments and safe ".." traversals which normalise away. +# redundant "." segments and safe ".." traversals which normalize away. _INSIDE_DIR = _inside_dir() @@ -112,7 +112,7 @@ def test_inside_manifests_resolve_to_sibling_lockfiles( f"resolved path must be a sibling Cargo.lock: {lockfile_path}" ) assert lockfile_path.parent == lockfile_path.parent.resolve(), ( - f"lockfile parent must be a normalised path: {lockfile_path}" + f"lockfile parent must be a normalized path: {lockfile_path}" ) assert lockfile_path.is_relative_to(resolved_root), ( f"lockfile must stay within the workspace root: {lockfile_path}" diff --git a/tests/unit/test_bump_manifest_updates.py b/tests/unit/test_bump_manifest_updates.py index 2024b06a..fd3e0bd6 100644 --- a/tests/unit/test_bump_manifest_updates.py +++ b/tests/unit/test_bump_manifest_updates.py @@ -192,7 +192,7 @@ def test_run_updates_renamed_internal_dependency_versions( ) -def test_run_normalises_workspace_root( +def test_run_normalizes_workspace_root( tmp_path: pathlib.Path, monkeypatch: MonkeyPatch ) -> None: """The command resolves the workspace root before applying updates.""" @@ -208,7 +208,7 @@ def test_run_normalises_workspace_root( ) manifest_path = workspace_root / "Cargo.toml" assert _load_version(manifest_path, ("workspace", "package")) == "3.4.5", ( - "workspace version not updated after root normalisation" + "workspace version not updated after root normalization" ) diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index ff08640f..08048197 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -23,7 +23,7 @@ from lading.commands import bump as bump_command from lading.commands import bump_lockfiles from lading.commands import publish as publish_command -from lading.utils import normalise_workspace_root +from lading.utils import normalize_workspace_root from lading.workspace import WorkspaceCrate, WorkspaceGraph if typ.TYPE_CHECKING: @@ -82,7 +82,7 @@ class ExceptionHandlingCase: ], ) def test_resolve_log_level_parsing(value: str | None, expected: int) -> None: - """``_resolve_log_level`` should normalise supported variants.""" + """``_resolve_log_level`` should normalize supported variants.""" assert cli._resolve_log_level(value) == expected @@ -160,13 +160,13 @@ def test_extract_workspace_override_requires_value_equals() -> None: cli._extract_workspace_override(["--workspace-root="]) -def test_normalise_workspace_root_defaults_to_cwd( +def test_normalize_workspace_root_defaults_to_cwd( monkeypatch: pytest.MonkeyPatch, tmp_path: Path, ) -> None: """Default workspace resolution uses the current working directory.""" monkeypatch.chdir(tmp_path) - resolved = normalise_workspace_root(None) + resolved = normalize_workspace_root(None) assert resolved == tmp_path.resolve() diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index dd041a3a..688154ab 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -186,7 +186,7 @@ def test_preflight_config_from_mapping_defaults() -> None: def test_bump_config_from_mapping_parses_lockfile_fields() -> None: - """BumpConfig.from_mapping normalises lockfile settings.""" + """BumpConfig.from_mapping normalizes lockfile settings.""" mapping = { "lockfile_manifests": ["crates/nested/Cargo.toml"], "rebuild_lockfiles": True, @@ -241,7 +241,7 @@ def test_use_configuration_sets_context(tmp_path: Path) -> None: def test_preflight_config_parses_extended_fields() -> None: - """Aux build commands, externs, and env overrides should be normalised.""" + """Aux build commands, externs, and env overrides should be normalized.""" mapping = { "test_exclude": ["alpha", "alpha", "beta"], "unit_tests_only": False, @@ -292,7 +292,7 @@ def test_string_tuple_and_matrix_validation() -> None: def test_string_mapping_and_optional_mapping_validation() -> None: - """Mapping helpers should normalise values and reject invalid structures.""" + """Mapping helpers should normalize values and reject invalid structures.""" mapping = {"alpha": "one"} assert config_module._string_mapping(mapping, "table") == (("alpha", "one"),) with pytest.raises(config_module.ConfigurationError): @@ -301,7 +301,7 @@ def test_string_mapping_and_optional_mapping_validation() -> None: config_module._optional_mapping(["not", "mapping"], "table") -def test_integer_and_boolean_normalisation() -> None: +def test_integer_and_boolean_normalization() -> None: """Numeric and boolean helpers should enforce allowed shapes.""" assert config_module._non_negative_int(None, "lines", 3) == 3 assert config_module._non_negative_int("7", "lines", 0) == 7 diff --git a/tests/unit/test_publish_staging.py b/tests/unit/test_publish_staging.py index 31d86203..979b9331 100644 --- a/tests/unit/test_publish_staging.py +++ b/tests/unit/test_publish_staging.py @@ -17,19 +17,19 @@ from pathlib import Path -def test_normalise_build_directory_defaults_to_tempdir(tmp_path: Path) -> None: - """Normalisation creates a temporary directory when none is provided.""" +def test_normalize_build_directory_defaults_to_tempdir(tmp_path: Path) -> None: + """Normalization creates a temporary directory when none is provided.""" workspace_root = tmp_path / "workspace" workspace_root.mkdir() - build_directory = publish._normalise_build_directory(workspace_root, None) + build_directory = publish._normalize_build_directory(workspace_root, None) assert build_directory.exists() assert build_directory.is_absolute() assert not build_directory.is_relative_to(workspace_root) -def test_normalise_build_directory_resolves_relative_paths( +def test_normalize_build_directory_resolves_relative_paths( monkeypatch: pytest.MonkeyPatch, tmp_path: Path ) -> None: """Relative build directories are resolved against the current directory.""" @@ -37,24 +37,24 @@ def test_normalise_build_directory_resolves_relative_paths( workspace_root.mkdir() monkeypatch.chdir(tmp_path) - build_directory = publish._normalise_build_directory(workspace_root, "staging") + build_directory = publish._normalize_build_directory(workspace_root, "staging") expected = (tmp_path / "staging").resolve() assert build_directory == expected assert build_directory.exists() -def test_normalise_build_directory_rejects_workspace_descendants( +def test_normalize_build_directory_rejects_workspace_descendants( tmp_path: Path, ) -> None: - """Normalisation rejects build directories nested under the workspace.""" + """Normalization rejects build directories nested under the workspace.""" workspace_root = tmp_path / "workspace" workspace_root.mkdir() build_directory = workspace_root / "target" with pytest.raises(publish.PublishPreparationError) as excinfo: - publish._normalise_build_directory(workspace_root, build_directory) + publish._normalize_build_directory(workspace_root, build_directory) assert "cannot reside within the workspace root" in str(excinfo.value) diff --git a/tests/unit/test_workspace_models_validation.py b/tests/unit/test_workspace_models_validation.py index 10973f3e..a91bf5df 100644 --- a/tests/unit/test_workspace_models_validation.py +++ b/tests/unit/test_workspace_models_validation.py @@ -191,12 +191,12 @@ def test_lookup_workspace_target_handles_missing_entries() -> None: assert result is None -def test_path_normalisation_rejects_invalid_types() -> None: +def test_path_normalization_rejects_invalid_types() -> None: """Non-path types should be rejected for manifest and root paths.""" with pytest.raises(models.WorkspaceModelError): - graph_build._normalise_workspace_root(123) + graph_build._normalize_workspace_root(123) with pytest.raises(models.WorkspaceModelError): - graph_build._normalise_manifest_path(123, "field") + graph_build._normalize_manifest_path(123, "field") def test_expect_sequence_validation() -> None: diff --git a/tests/unit/utils/test_metrics.py b/tests/unit/utils/test_metrics.py index b192f31e..0e26a6c2 100644 --- a/tests/unit/utils/test_metrics.py +++ b/tests/unit/utils/test_metrics.py @@ -60,7 +60,7 @@ def test_zero_amount_increment_does_not_break_quiet_run( def test_label_order_does_not_matter() -> None: - """Label ordering is normalised in the registry key.""" + """Label ordering is normalized in the registry key.""" metrics.increment_counter("demo.pair", a="1", b="2") assert metrics.counter_value("demo.pair", b="2", a="1") == 1 @@ -86,7 +86,7 @@ def test_emit_summary_logs_structured_payload( """The summary line carries a JSON payload of every counter. Snapshotting the rendered message locks the exact structured output format - operators see, including counter ordering and label-key normalisation. + operators see, including counter ordering and label-key normalization. """ caplog.set_level(logging.INFO, logger="lading.utils.metrics") metrics.increment_counter("demo.total", subcommand="package") diff --git a/tests/unit/utils/test_path.py b/tests/unit/utils/test_path.py index 9118a273..36819076 100644 --- a/tests/unit/utils/test_path.py +++ b/tests/unit/utils/test_path.py @@ -9,7 +9,7 @@ import hypothesis.strategies as st from hypothesis import given -from lading.utils import normalise_workspace_root +from lading.utils import normalize_workspace_root _path_segment: st.SearchStrategy[str] = st.text( alphabet=string.ascii_lowercase + string.digits + "_-", @@ -26,12 +26,12 @@ def test_none_defaults_to_cwd() -> None: """``None`` selects the resolved current working directory.""" - assert normalise_workspace_root(None) == Path.cwd().resolve() + assert normalize_workspace_root(None) == Path.cwd().resolve() def test_tilde_is_expanded() -> None: """A leading ``~`` expands to the user home directory.""" - result = normalise_workspace_root(str(Path("~", "workspace"))) + result = normalize_workspace_root(str(Path("~", "workspace"))) assert result == Path.home().resolve() / "workspace" @@ -39,36 +39,36 @@ def test_tilde_is_expanded() -> None: def test_accepts_path_instances() -> None: """`Path` inputs behave identically to string inputs.""" candidate = Path("~", "ws") - result = normalise_workspace_root(candidate) + result = normalize_workspace_root(candidate) assert result == Path.home().resolve() / "ws" - assert result == normalise_workspace_root(str(candidate)) + assert result == normalize_workspace_root(str(candidate)) @given(segments=_relative_segments) def test_relative_inputs_resolve_to_absolute_paths(segments: list[str]) -> None: - """Relative inputs resolve to a fully normalised, cwd-anchored path.""" + """Relative inputs resolve to a fully normalized, cwd-anchored path.""" value = str(Path(*segments)) - result = normalise_workspace_root(value) + result = normalize_workspace_root(value) # Independent invariants rather than a pathlib mirror of the implementation: # the output is absolute, retains no unresolved ``.``/``..`` segments, # anchors relative inputs at the cwd, and is a fixed point of further - # normalisation. + # normalization. assert result.is_absolute() assert ".." not in result.parts assert "." not in result.parts - assert result == normalise_workspace_root(Path.cwd() / value) - assert normalise_workspace_root(result) == result + assert result == normalize_workspace_root(Path.cwd() / value) + assert normalize_workspace_root(result) == result @given(segments=_relative_segments) -def test_redundant_separators_are_normalised(segments: list[str]) -> None: +def test_redundant_separators_are_normalized(segments: list[str]) -> None: """Doubling separators does not change the resolved path.""" value = str(Path(*segments)) doubled = value.replace(os.sep, os.sep * 2) - assert normalise_workspace_root(doubled) == normalise_workspace_root(value) + assert normalize_workspace_root(doubled) == normalize_workspace_root(value) @given(segments=_relative_segments) @@ -76,10 +76,10 @@ def test_tilde_prefix_expands_for_arbitrary_suffixes(segments: list[str]) -> Non """Expanding ``~`` is equivalent to substituting the literal home path.""" tilde_value = str(Path("~", *segments)) home_value = str(Path(Path.home(), *segments)) - result = normalise_workspace_root(tilde_value) + result = normalize_workspace_root(tilde_value) # Independent invariants: the output is absolute, fully resolved, and the # ``~`` prefix expands to exactly the home directory. assert result.is_absolute() assert ".." not in result.parts - assert result == normalise_workspace_root(home_value) + assert result == normalize_workspace_root(home_value) diff --git a/typos.toml b/typos.toml index 3fb9200e..579f8441 100644 --- a/typos.toml +++ b/typos.toml @@ -32,7 +32,6 @@ locale = "en-gb" extend-ignore-re = [ "(?s)```.*?```", "\\brust-analyzer\\b", - "`[^`\\n]+`", ] [default.extend-words]