Skip to content

Replace manual --version validation with argparse choices using dynamic version discovery#410

Open
budaesandrei wants to merge 1 commit intoaws:mainfrom
budaesandrei:feature/argparse-version-choices
Open

Replace manual --version validation with argparse choices using dynamic version discovery#410
budaesandrei wants to merge 1 commit intoaws:mainfrom
budaesandrei:feature/argparse-version-choices

Conversation

@budaesandrei
Copy link
Copy Markdown
Contributor

Summary

Replaces the manual path-existence validation for the --version argument in create_venvs.py with argparse's built-in choices parameter, populated dynamically from the filesystem.

Changes

  • Added get_airflow_versions() function that scans ./images/airflow/ and returns only directory names matching a semver pattern (^\d+\.\d+\.\d+$), so non-version folders (e.g. docs, temp directories) are excluded.
  • Changed --version argument from type=str to choices=available_versions, delegating validation to argparse.
  • Removed the manual version_path.exists() check and associated error handling block, since argparse now handles invalid input with a clear error message listing valid choices.

Testing

Verified the following scenarios:

  • --version 2.10.1 (valid) — works as expected
  • --version omitted — creates venvs for all versions (unchanged behavior)
  • --version invalid — argparse rejects with clear error listing available choices

…ic version discovery

Added get_airflow_versions() to scan ./images/airflow/ for directories matching semver pattern (x.x.x). The --version argument now uses argparse choices instead of manual path existence checks, letting argparse handle validation and error messaging natively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant