MCPcopy Create free account
hub / github.com/astral-sh/python-build-standalone / validate_pull_request_defaults

Function validate_pull_request_defaults

ci-matrix.py:457–498  ·  view source on GitHub ↗

Validate the pull_request defaults in ci-defaults.yaml.

(
    ci_config: dict[str, Any], pull_request_defaults: dict[str, Any]
)

Source from the content-addressed store, hash-verified

455
456
457def validate_pull_request_defaults(
458 ci_config: dict[str, Any], pull_request_defaults: dict[str, Any]
459) -> None:
460 """Validate the pull_request defaults in ci-defaults.yaml."""
461 all_triples = set()
462 for platform_config in ci_config.values():
463 all_triples.update(platform_config.keys())
464
465 for triple in pull_request_defaults["targets"]:
466 if triple not in all_triples:
467 print(
468 f"error: target triple {triple!r} in {CI_DEFAULTS_YAML}:pull_request "
469 f"not found in {CI_TARGETS_YAML}",
470 file=sys.stderr,
471 )
472 sys.exit(1)
473
474 # Validate that each build option listed is valid for the target.
475 all_options = set(get_all_build_options(ci_config, triple))
476 for option in pull_request_defaults["targets"][triple]["build_options"]:
477 if option not in all_options:
478 print(
479 f"error: build option {option!r} for {triple} in "
480 f"{CI_DEFAULTS_YAML}:pull_request not found in {CI_TARGETS_YAML} "
481 f"(valid: {sorted(all_options)})",
482 file=sys.stderr,
483 )
484 sys.exit(1)
485
486 # Validate that the default python version exists in ci-targets.yaml.
487 default_version = pull_request_defaults["python_version"]
488 for triple in pull_request_defaults["targets"]:
489 platform = find_target_platform(ci_config, triple)
490 ci_versions = ci_config[platform][triple]["python_versions"]
491 if default_version not in ci_versions:
492 print(
493 f"error: python version {default_version!r} in "
494 f"{CI_DEFAULTS_YAML}:pull_request not available for {triple} in "
495 f"{CI_TARGETS_YAML} (valid: {ci_versions})",
496 file=sys.stderr,
497 )
498 sys.exit(1)
499
500
501def parse_args() -> argparse.Namespace:

Callers 1

mainFunction · 0.85

Calls 3

get_all_build_optionsFunction · 0.85
find_target_platformFunction · 0.85
updateMethod · 0.80

Tested by

no test coverage detected