-
Couldn't load subscription status.
- Fork 2
error msg if version is missing #35
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - package_no_version_not_in_exclude |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,22 @@ def parse_environment(text): | |
| return specs, warnings | ||
|
|
||
|
|
||
| def assert_spec_has_version(environments): | ||
| # packages in policy.exclude were already removed | ||
|
|
||
| for env, specs in environments.items(): | ||
| for spec in specs: | ||
| if spec.version is None: | ||
|
|
||
| msg = ( | ||
| f"No minimum version found for '{spec.name}' in '{env}'. Either" | ||
| " add a version or add to the list of excluded packages in the" | ||
| " policy file." | ||
| ) | ||
|
|
||
| raise ValueError(msg) | ||
|
|
||
|
|
||
| def parse_policy(file): | ||
| policy = yaml.safe_load(file) | ||
| try: | ||
|
|
@@ -344,6 +360,10 @@ def parse_date(string): | |
| @click.option("--today", type=parse_date, default=None) | ||
| @click.option("--policy", "policy_file", type=click.File(mode="r"), required=True) | ||
| def main(today, policy_file, environment_paths): | ||
| _main(today, policy_file, environment_paths) | ||
|
|
||
|
|
||
| def _main(today, policy_file, environment_paths): | ||
| console = Console() | ||
|
|
||
| policy = parse_policy(policy_file) | ||
|
|
@@ -360,6 +380,8 @@ def main(today, policy_file, environment_paths): | |
| for env, (specs, _) in parsed_environments.items() | ||
| } | ||
|
|
||
| assert_spec_has_version(environments) | ||
|
|
||
|
Comment on lines
+383
to
+384
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this should be done at the same time as applying |
||
| all_packages = list( | ||
| dict.fromkeys(spec.name for spec in concat(environments.values())) | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might need to clean this up a bit: currently
_mainwould callsys.exit, which is not great for testing. It also should take the contents of the files instead of file handles / paths, which avoids the need to do I/O in the tests.Additionally,
_mainis not really a descriptive name. How about something likevalidate_environmentinstead?