constants
ruff_sync.constants ¶
Constants used across ruff-sync.
__all__
module-attribute
¶
__all__ = [
"DEFAULT_BRANCH",
"DEFAULT_EXCLUDE",
"DEFAULT_PATH",
"MISSING",
"ConfKey",
"MissingType",
"OutputFormat",
"resolve_defaults",
]
MissingType ¶
Bases: Enum
Used to represent a missing value sentinel.
This can be used to properly type fields that use the MissingType.SENTINEL as a default.
Example
from ruff_sync.constants import MissingType, MISSING def foo(bar: int | None | MissingType = MISSING) -> None: ... if bar is MissingType.SENTINEL: ... print("bar is missing") ... else: ... print(f"bar is {bar}")
Source code in src/ruff_sync/constants.py
OutputFormat ¶
Bases: str, Enum
Output formats for the CLI.
Source code in src/ruff_sync/constants.py
ConfKey ¶
Bases: str, Enum
Centralized configuration keys for [tool.ruff-sync].
These are the canonical names used in the pyproject.toml configuration file.
Source code in src/ruff_sync/constants.py
PRE_COMMIT_VERSION_SYNC
class-attribute
instance-attribute
¶
PRE_COMMIT_SYNC_LEGACY
class-attribute
instance-attribute
¶
__str__ ¶
to_attr
classmethod
¶
get_canonical
classmethod
¶
Map legacy or aliased configuration keys to their canonical names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The raw key from the configuration file. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The canonical ConfKey name (still as a string for use in logic). |
Source code in src/ruff_sync/constants.py
resolve_defaults ¶
Resolve MISSING sentinel values to their effective defaults.
This is the single source of truth for MISSING → default resolution across the CLI and internal logic, keeping the layers in sync.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
branch
|
str | MissingType
|
The resolved branch value or |
required |
path
|
str | MissingType
|
The resolved path value or |
required |
exclude
|
Iterable[str] | MissingType
|
The resolved exclude iterable or |
required |
Returns:
| Type | Description |
|---|---|
str
|
A |
str | None
|
|
Iterable[str]
|
it directly to :func: |