Module continuous_delivery_scripts.utils.project_config_schema
Schema-based validation for [ProjectConfig] entries in pyproject.toml.
Functions
def validate_project_config(config_file: str | None = None) ‑> list[str]-
Expand source code
def validate_project_config(config_file: Optional[str] = None) -> list[str]: """Validate the project's ``[ProjectConfig]`` section against CDS' schema.""" config_path = FileConfig._find_config_file(config_file) if not config_path: return ["Could not find pyproject.toml."] raw = toml.load(config_path) project_config = raw.get(FileConfig.CONFIG_SECTION) if project_config is None: return [f"{config_path}: missing [{FileConfig.CONFIG_SECTION}] section."] if not isinstance(project_config, dict): return [f"{config_path}: [{FileConfig.CONFIG_SECTION}] must be a TOML table."] project_dir = Path(config_path).resolve().parent errors = [] known_keys = set(PROJECT_CONFIG_SCHEMA) for key in sorted(set(project_config) - known_keys): errors.append(f"Unknown ProjectConfig key: {key}") for key, schema in PROJECT_CONFIG_SCHEMA.items(): if key not in project_config: continue errors.extend(schema.validator(key, project_config[key], project_dir)) errors.extend(_validate_licence_assessment_policy(project_config, project_dir)) return errorsValidate the project's
[ProjectConfig]section against CDS' schema.
Classes
class FieldSchema (validator: Callable[[str, Any, pathlib.Path], list[str]])-
Expand source code
@dataclass(frozen=True) class FieldSchema: """Validation rules for one ``ProjectConfig`` key.""" validator: ValidatorValidation rules for one
ProjectConfigkey.Instance variables
var validator : Callable[[str, Any, pathlib.Path], list[str]]-
The type of the None singleton.