-
Notifications
You must be signed in to change notification settings - Fork 0
Bring oversized files under the 400-line guideline (#108) #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e53d6e1
Rebase issue-108 onto main; reconcile #108 extraction with main's ref…
37b847e
Route coercion errors through _reject; fix stale docstring cross-refs
00c3e21
Lock down canonical coercion-message contracts in tests
c95c4a9
Dedup coercion rejection-assert tail via a shared helper
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| """Cyclopts argument declarations for the :mod:`lading` CLI. | ||
|
|
||
| Extracted from :mod:`lading.cli` (issue #108) so option declarations live | ||
| apart from dispatch logic. ``cli`` re-imports every public name, so external | ||
| access through ``lading.cli`` keeps working. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| import typing as typ | ||
| from pathlib import Path | ||
|
|
||
| from cyclopts import Parameter | ||
|
|
||
| WORKSPACE_ROOT_ENV_VAR = "LADING_WORKSPACE_ROOT" | ||
| WORKSPACE_ROOT_REQUIRED_MESSAGE = "--workspace-root requires a value" | ||
| _WORKSPACE_PARAMETER = Parameter( | ||
| name="workspace-root", | ||
| env_var=WORKSPACE_ROOT_ENV_VAR, | ||
| help="Path to the Rust workspace root.", | ||
| ) | ||
| WorkspaceRootOption = typ.Annotated[Path, _WORKSPACE_PARAMETER] | ||
|
|
||
| _VERSION_PATTERN = re.compile( | ||
| r"^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$" | ||
| ) | ||
|
|
||
|
|
||
| def _validate_version_argument(_hint: object, version: str) -> None: | ||
| """Reject a non-semantic-version ``version`` via cyclopts' validator hook.""" | ||
| # Cyclopts calls validators as ``validator(type_hint, value)`` and converts a | ||
| # raised ValueError into a formatted ValidationError, so a bad version is | ||
| # reported through cyclopts' own error flow rather than a bare SystemExit. | ||
| if not _VERSION_PATTERN.fullmatch(version): | ||
| message = ( | ||
| "Invalid version argument " | ||
| f"{version!r}. Expected semantic version in the form " | ||
| "<major>.<minor>.<patch> with optional pre-release/build segments." | ||
| ) | ||
| raise ValueError(message) | ||
|
|
||
|
|
||
| _VERSION_PARAMETER = Parameter( | ||
| validator=_validate_version_argument, | ||
| help="Target semantic version (e.g., 1.2.3) to set across workspace manifests.", | ||
| ) | ||
| VersionArgument = typ.Annotated[str, _VERSION_PARAMETER] | ||
|
|
||
| _DRY_RUN_PARAMETER = Parameter( | ||
| name="dry-run", | ||
| help="Preview manifest changes without writing files.", | ||
| ) | ||
| DryRunFlag = typ.Annotated[bool, _DRY_RUN_PARAMETER] | ||
|
|
||
| _REBUILD_LOCKFILES_PARAMETER = Parameter( | ||
| name="rebuild-lockfiles", | ||
| negative="no-rebuild-lockfiles", | ||
| help="Regenerate Cargo.lock files after manifest updates.", | ||
| ) | ||
| RebuildLockfilesFlag = typ.Annotated[bool, _REBUILD_LOCKFILES_PARAMETER] | ||
|
|
||
| _LIVE_PARAMETER = Parameter( | ||
| name="live", | ||
| help="Run cargo publish without --dry-run; default behaviour is dry-run.", | ||
| ) | ||
| LiveFlag = typ.Annotated[bool, _LIVE_PARAMETER] | ||
|
|
||
| _FORBID_DIRTY_PARAMETER = Parameter( | ||
| name="forbid-dirty", | ||
| help=("Require a clean working tree before running publish pre-flight checks."), | ||
| ) | ||
| ForbidDirtyFlag = typ.Annotated[bool, _FORBID_DIRTY_PARAMETER] | ||
|
|
||
| _ALLOW_UNPUBLISHED_WORKSPACE_DEPS_PARAMETER = Parameter( | ||
| name="allow-unpublished-workspace-deps", | ||
| help=( | ||
| "Dry-run only: downgrade cargo package failures caused by a sibling " | ||
| "workspace crate version not yet on crates.io to a warning when the " | ||
| "missing crate is part of the planned publish set and appears earlier " | ||
| "in publish order. Defaults to enabled in dry-run mode. Cannot be " | ||
| "combined with --live." | ||
| ), | ||
| ) | ||
| AllowUnpublishedWorkspaceDepsFlag = typ.Annotated[ | ||
| bool | None, _ALLOW_UNPUBLISHED_WORKSPACE_DEPS_PARAMETER | ||
| ] | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "WORKSPACE_ROOT_ENV_VAR", | ||
| "WORKSPACE_ROOT_REQUIRED_MESSAGE", | ||
| "AllowUnpublishedWorkspaceDepsFlag", | ||
| "DryRunFlag", | ||
| "ForbidDirtyFlag", | ||
| "LiveFlag", | ||
| "RebuildLockfilesFlag", | ||
| "VersionArgument", | ||
| "WorkspaceRootOption", | ||
| ] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.