Skip to content

Commit ae30e05

Browse files
savente93nabobalis
andauthored
Apply suggestions from code review
Co-authored-by: Nabil Freij <[email protected]>
1 parent 5764a23 commit ae30e05

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches: main
55
pull_request:
66
branches: main
7-
# on demand
7+
# On demand
88
workflow_dispatch:
99

1010
jobs:

action.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ runs:
4444
gh release download -R "scientific-python/spec0-action" --pattern schedule.json -O "$SCHEDULE_FILE"
4545
fi
4646
47-
# make user pixi is available
4847
- uses: prefix-dev/[email protected]
4948
name: Setup pixi
5049
with:
@@ -61,7 +60,6 @@ runs:
6160
# let's cleanup after ourselves so it doesn't end up in the PR
6261
rm "${{inputs.schedule_path}}"
6362
64-
6563
- name: Create Pull Request
6664
if: ${{ inputs.create_pr == 'true' }}
6765
uses: peter-evans/create-pull-request@v6

readme.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# SPEC-0 Versions Action
22

3-
This repository contains a Github Action to update python dependencies conform the SPEC 0 support schedule.
3+
This repository contains a Github Action to update Python dependencies such that they conform to the SPEC 0 support schedule.
44
It also contains released versions of the schedule in various formats that that action can use to open PRs in your repository.
55

66
## Using the action
77

8-
To use the action you can copy the yaml below, and paste it into `.github/workflows/update-spec-0.yaml`. The arguments bewlow are filled with heir default value, in most cases you won't have to fill them. All except for `token` are optional.
8+
To use the action you can copy the yaml below, and paste it into `.github/workflows/update-spec-0.yaml`.
9+
The arguments below are filled with their default value, in most cases you won't have to fill them.
10+
All except for `token` are optional.
911

10-
Whenever the action is triggered it will open a PR in your repository that will update the dependencies of SPEC 0 to the new lower bound. For this you will have to provide it with a PAT that has write permissions in the `contents` and `pull request` scopes. Please refer to the GitHub documentation for instructions on how to do this [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
12+
Whenever the action is triggered it will open a PR in your repository that will update the dependencies of SPEC 0 to the new lower bound.
13+
For this you will have to provide it with a PAT that has write permissions in the `contents` and `pull request` scopes.
14+
Please refer to the GitHub documentation for instructions on how to do this [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
1115

1216

1317
```yaml
@@ -29,7 +33,7 @@ jobs:
2933
update:
3034
runs-on: ubuntu-latest
3135
steps:
32-
- uses: scientific-python/spec0-action@v1
36+
- uses: scientific-python/spec0-action@v1
3337
with:
3438
token: ${{ secrets.GH_PAT }}
3539
project_file_name: "pyproject.toml"
@@ -40,6 +44,8 @@ It should update any of the packages listed in the `dependency`, or `tool.pixi.*
4044

4145
## Limitations
4246

43-
1. since this action simply parses the toml to do the upgrade and leaves any other bounds in tackt, it is possible that the environment of the PR becomes unsolvable. For example if you have a numpy dependency like so: `numpy = ">=1.25.0,<2"` this will get updated in the PR to `numpy = "2.0.0,<2"` which is infeasable. Keeping the resulting environment solvable is outside the scope of this action, so they might have to be adjusted manually.
44-
2. Currently on `pyproject.toml` is supported by this action, though other manifest files could be considered upon request.
47+
1. Since this action simply parses the toml to do the upgrade and leaves any other bounds intact, it is possible that the environment of the PR becomes unsolvable.
48+
For example if you have a numpy dependency like so: `numpy = ">=1.25.0,<2"` this will get updated in the PR to `numpy = "2.0.0,<2"` which is infeasible.
49+
Keeping the resulting environment solvable is outside the scope of this action, so you might have to be adjusted manually.
50+
2. Currently only `pyproject.toml` is supported by this action, though other manifest files could be considered upon request.
4551

spec0_action/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
__all__ = ["read_schedule", "read_toml", "write_toml", "update_pyproject_toml"]
2020

2121
def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule):
22-
# iterate by idx because we want to update it inplace
22+
# Iterate by idx because we want to update it inplace
2323
for i in range(len(dependencies)):
2424
dep_str = dependencies[i]
2525
pkg, extras, spec = parse_pep_dependency(dep_str)
@@ -30,9 +30,7 @@ def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule)
3030
new_lower_bound = Version(schedule["packages"][pkg])
3131
try:
3232
spec = tighten_lower_bound(spec or SpecifierSet(), new_lower_bound)
33-
# will raise a value error if bound is already tigheter, in this case we just do nothing and continue
34-
35-
33+
# Will raise a value error if bound is already tighter, in this case we just do nothing and continue
3634
except ValueError:
3735
continue
3836

@@ -46,11 +44,11 @@ def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule)
4644

4745
def update_dependency_table(dep_table: dict, new_versions: dict):
4846
for pkg, pkg_data in dep_table.items():
49-
# don't do anything for pkgs that aren't in our schedule
47+
# Don't do anything for pkgs that aren't in our schedule
5048
if pkg not in new_versions:
5149
continue
5250

53-
# like pkg = ">x.y.z,<a"
51+
# Like pkg = ">x.y.z,<a"
5452
if isinstance(pkg_data, str):
5553
if not is_url_spec(pkg_data):
5654
spec = parse_version_spec(pkg_data)
@@ -61,12 +59,12 @@ def update_dependency_table(dep_table: dict, new_versions: dict):
6159
dep_table[pkg] = repr_spec_set(spec)
6260

6361
else:
64-
# we don't do anything with url spec dependencies
62+
# We don't do anything with url spec dependencies
6563
continue
6664
else:
67-
# table like in tests = {path = "."}
65+
# Table like in tests = {path = "."}
6866
if "path" in pkg_data:
69-
# we don't do anything with path dependencies
67+
# We don't do anything with path dependencies
7068
continue
7169

7270
spec = SpecifierSet(pkg_data["version"])

spec0_action/parsing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from pathlib import Path
99
from re import compile
1010

11-
# we won't actually do anything with URLs we just need to detect them
11+
# We won't actually do anything with URLs we just need to detect them
1212
Url: TypeAlias = ParseResult
1313

14-
# slightly modified version of https://packaging.python.org/en/latest/specifications/dependency-specifiers/#names
14+
# Slightly modified version of https://packaging.python.org/en/latest/specifications/dependency-specifiers/#names
1515
PEP_PACKAGE_IDENT_RE = compile(r"(?im)^([A-Z0-9][A-Z0-9._-]*)(\[[A-Z0-9._,-]+\])?(.*)$")
1616

1717

@@ -22,11 +22,11 @@ class SupportSchedule(TypedDict):
2222

2323
def parse_version_spec(s: str) -> SpecifierSet:
2424
if s.strip() == "*":
25-
# python version numeric components must be non-negative so this is ookay
25+
# Python version numeric components must be non-negative so this is okay
2626
# see https://packaging.python.org/en/latest/specifications/version-specifiers/
2727
return SpecifierSet(">=0")
2828
try:
29-
# if we can simply parse it return it
29+
# If we can simply parse it return it
3030
return SpecifierSet(s)
3131
except InvalidSpecifier:
3232
try:

0 commit comments

Comments
 (0)