Skip to content

Commit

Permalink
Remove keys from dynamic (internal attribute) as the values are deter…
Browse files Browse the repository at this point in the history
…mined.
  • Loading branch information
domdfcoding committed Mar 19, 2024
1 parent 2b000a2 commit b25accf
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
4 changes: 1 addition & 3 deletions tests/test_config_/test_parse_builders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ classifiers:
- 'Programming Language :: Python :: Implementation :: PyPy'
dependencies: []
description: A simple Python wheel builder for simple projects.
dynamic:
- classifiers
- requires-python
dynamic: []
entry-points: {}
gui-scripts: {}
keywords:
Expand Down
5 changes: 1 addition & 4 deletions tests/test_config_/test_parse_dynamic_requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ dependencies:
- shippinglabel>=0.10.0
- toml>=0.10.2
description: A simple Python wheel builder for simple projects.
dynamic:
- classifiers
- requires-python
- dependencies
dynamic: []
entry-points: {}
gui-scripts: {}
keywords:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_config_/test_parse_valid_config_COMPLETE_A_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ dependencies:
- gidgethub[httpx]>4.0.0
- httpx
description: A simple Python wheel builder for simple projects.
dynamic:
- classifiers
- requires-python
dynamic: []
entry-points: {}
gui-scripts: {}
keywords:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_config_/test_parse_valid_config_COMPLETE_B_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ dependencies:
- gidgethub[httpx]>4.0.0
- httpx
description: A simple Python wheel builder for simple projects.
dynamic:
- classifiers
- requires-python
dynamic: []
entry-points: {}
gui-scripts: {}
keywords:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ dependencies:
- gidgethub[httpx]>4.0.0
- httpx
description: A simple Python wheel builder for simple projects.
dynamic:
- classifiers
- requires-python
dynamic: []
entry-points: {}
gui-scripts: {}
keywords:
Expand Down
17 changes: 15 additions & 2 deletions whey/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,23 @@ def load_toml(filename: PathLike) -> Dict[str, Any]: # TODO: TypedDict
dynamic_fields = parsed_config.get("dynamic", [])

if "classifiers" in dynamic_fields:
dynamic_fields.remove("classifiers")
parsed_config["classifiers"] = backfill_classifiers(parsed_config)

if "requires-python" in dynamic_fields and parsed_config["python-versions"]:
parsed_config["requires-python"] = Specifier(f">={natmin(parsed_config['python-versions'])}")
if "requires-python" in dynamic_fields:
if parsed_config["python-versions"]:
dynamic_fields.remove("requires-python")
parsed_config["requires-python"] = Specifier(f">={natmin(parsed_config['python-versions'])}")
else:
raise BadConfigError(
"'requires-python' was listed in 'project.dynamic', "
"but whey cannot determine the minimum supported Python version. \n"
"Set 'tool.whey.python-versions' to a list of supported Python versions to fix this."
)

if "dependencies" in dynamic_fields:
dynamic_fields.remove("dependencies")

if (project_dir / "requirements.txt").is_file():
dependencies, comments, invalid = read_requirements(project_dir / "requirements.txt", include_invalid=True)

Expand All @@ -114,6 +125,8 @@ def load_toml(filename: PathLike) -> Dict[str, Any]: # TODO: TypedDict
"but no 'requirements.txt' file was found."
)

parsed_config["dynamic"] = dynamic_fields

if "base-classifiers" in parsed_config:
del parsed_config["base-classifiers"]

Expand Down

0 comments on commit b25accf

Please sign in to comment.