Skip to content

Commit 91bbf52

Browse files
committed
precommit
1 parent 8196bb6 commit 91bbf52

File tree

10 files changed

+67
-51
lines changed

10 files changed

+67
-51
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7+
exclude-paths:
8+
- "tests/assets/test_data"

.github/workflows/test_action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
uses: actions/checkout@v6
1111
- name: Generate version data using local action
1212
uses: ./
13-
with:
13+
with:
1414
project_file_name: tests/test_data/pyproject.toml
1515
create_pr: false
16-
schedule_path: tests/test_data/test_schedule.json
16+
schedule_path: tests/test_data/test_schedule.json

.pre-commit-config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,18 @@ repos:
1414
- id: end-of-file-fixer
1515
- id: mixed-line-ending
1616
- id: trailing-whitespace
17-
1817
- repo: https://github.com/rbubley/mirrors-prettier
1918
rev: 787fb9f542b140ba0b2aced38e6a3e68021647a3 # frozen: v3.5.3
2019
hooks:
2120
- id: prettier
2221
files: \.(css|html|md|yml|yaml|gql)
2322
args: [--prose-wrap=preserve]
24-
2523
- repo: https://github.com/astral-sh/ruff-pre-commit
2624
rev: 971923581912ef60a6b70dbf0c3e9a39563c9d47 # frozen: v0.11.4
2725
hooks:
2826
- id: ruff
2927
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
3028
- id: ruff-format
31-
3229
- repo: https://github.com/codespell-project/codespell
3330
rev: "63c8f8312b7559622c0d82815639671ae42132ac" # frozen: v2.4.1
3431
hooks:

action.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ inputs:
66
description: "Target branch for the pull request"
77
required: true
88
default: "main"
9-
project_file_name:
9+
project_file_name:
1010
description: "Path to the project file listing dependencies, relative to repository root. Defaults to 'pyproject.toml'. Currently only pyproject.toml is supported."
1111
required: true
1212
default: "pyproject.toml"
13-
create_pr:
13+
create_pr:
1414
description: "Whether the action should open a PR or not. Set to false for dry-run/testing."
1515
required: true
1616
default: true
17-
commit_msg:
17+
commit_msg:
1818
description: "Commit message for the commit to update the versions. by default 'Drop support for unsupported packages conform SPEC 0'. has no effect if `create_pr` is set to false"
1919
required: false
2020
default: "chore: Drop support for unsupported packages conform SPEC 0"
21-
pr_title:
21+
pr_title:
2222
description: "The title of the PR that will be opened. by default 'Drop support for unsupported packages conform SPEC 0'. has no effect if `create_pr` is set to false"
2323
required: false
2424
default: "chore: Drop support for unsupported packages conform SPEC 0"
@@ -66,7 +66,6 @@ runs:
6666
echo "Schedule file already exists at $SCHEDULE_FILE"
6767
fi
6868
69-
7069
- name: Run update script
7170
shell: bash
7271
run: |
@@ -94,5 +93,5 @@ runs:
9493
branch: update-spec0-dependencies-${{ github.run_id }}
9594

9695
branding:
97-
icon: 'check-square'
98-
color: 'blue'
96+
icon: "check-square"
97+
color: "blue"

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ pytest = "*"
3030

3131
[tool.pixi.environments]
3232
test = ["test"]
33-

readme.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
# SPEC 0 Versions Action
22

3-
This repository contains a Github Action to update Python dependencies in your `pyproject.toml` such that they conform to the SPEC 0 support schedule. You can find this schedule [here](https://scientific-python.org/specs/spec-0000/)
3+
This repository contains a Github Action to update Python dependencies in your `pyproject.toml` such that they conform to the SPEC 0 support schedule.
4+
[You can find this schedule here.](https://scientific-python.org/specs/spec-0000/)
45

56
## Using the action
67

7-
88
### Example workflow
99

10-
To use the action you can copy the yaml below, and paste it into `.github/workflows/update-spec0.yaml`. 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).
11-
10+
To use the action you can copy the yaml below, and paste it into `.github/workflows/update-spec0.yaml`.
11+
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.
12+
For this you will have to provide it with a PAT that has write permissions in the `contents` and `pull request` scopes.
13+
[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)
1214

1315
```yaml
1416
name: Update SPEC 0 dependencies
1517

1618
on:
1719
schedule:
1820
# At 00:00 on day-of-month 3 in every 3rd month. (i.e. every quarter)
19-
# Releases should happen on the second day of the quarter in savente93/SPEC0-schedule to
21+
# Releases should happen on the second day of the quarter in savente93/SPEC0-schedule to
2022
# avoid fence post errors, so allow one day as a buffer to avoid timing issues here as well.
2123
- cron: "0 0 3 */3 *"
22-
# On demand:
24+
# On demand:
2325
workflow_dispatch:
2426

2527
permissions:
@@ -30,33 +32,32 @@ jobs:
3032
update:
3133
runs-on: ubuntu-latest
3234
steps:
33-
- uses: savente93/update-spec0-dependencies@v1.0.0
35+
- uses: scientific-python/spec0-action@v1.0.0
3436
with:
3537
token: ${{ secrets.GH_PAT }} # <- GH_PAT you will have to configure in the repo as a secret
3638
```
3739
38-
It should update any of the packages listed in the `dependency`, or `tool.pixi.*` tables. For examples of before and after you can see [./tests/test_data/pyproject.toml](./tests/test_data/pyproject.toml) and [./tests/test_data/pyproject_updated.toml](./tests/test_data/pyproject_updated.toml) respectively. Other tools are not yet supported, but I am open to feature requests.
39-
40-
The newest lower bounds will be downloaded from [https://github.com/savente93/SPEC0-schedule](https://github.com/savente93/SPEC0-schedule) but you should not have to worry about this.
40+
It should update any of the packages listed in the `dependency`, or `tool.pixi.*` tables.
41+
For examples of before and after you can see [./tests/test_data/pyproject.toml](./tests/test_data/pyproject.toml) and [./tests/test_data/pyproject_updated.toml](./tests/test_data/pyproject_updated.toml) respectively.
42+
Other tools are not yet supported, but we are open to feature requests.
4143

44+
The newest lower bounds will be downloaded from [https://github.com/savente93/SPEC0-schedule](https://github.com/savente93/SPEC0-schedule) but you should not have to worry about this.
4245

4346
### Parameters
4447

45-
| Input | Required | Default | Description |
46-
| ------------------- | -------- | ------------------ | -------------------------------------------------------------------------------|
47-
| token | yes | — | Personal access token with `contents` & `pull-request` scopes |
48-
| project\_file\_name | no | `"pyproject.toml"` | File to update dependencies in |
49-
| schedule\_path | no | `"schedule.json"` | path to schedule json data. only relevant if you have it committed in your repo |
50-
| target\_branch | no | `"main"` | Branch to open PR against |
51-
| create_pr | no | `true` | Open a PR with new versions |
52-
| pr_title | no | `chore: Drop support for unsupported packages conform SPEC 0` | The title of the PR that will be opened |
53-
| commit_msg | no | `chore: Drop support for unsupported packages conform SPEC 0` | Commit message of the commit to update the versions. |
54-
48+
| Input | Required | Default | Description |
49+
| ----------------- | -------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------- |
50+
| token | yes | — | Personal access token with `contents` & `pull-request` scopes |
51+
| project_file_name | no | `"pyproject.toml"` | File to update dependencies in |
52+
| schedule_path | no | `"schedule.json"` | path to schedule json data. only relevant if you have it committed in your repo |
53+
| target_branch | no | `"main"` | Branch to open PR against |
54+
| create_pr | no | `true` | Open a PR with new versions |
55+
| pr_title | no | `chore: Drop support for unsupported packages conform SPEC 0` | The title of the PR that will be opened |
56+
| commit_msg | no | `chore: Drop support for unsupported packages conform SPEC 0` | Commit message of the commit to update the versions. |
5557

5658
## Limitations
5759

5860
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.
59-
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.
61+
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.
6062
Keeping the resulting environment solvable is outside the scope of this action, so you might have to adjust them manually.
61-
2. Currently only `pyproject.toml` is supported by this action, though other manifest files could be considered upon request.
62-
63+
2. Currently only `pyproject.toml` is supported by this action, though other manifest files could be considered upon request.

run_spec0_update.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,36 @@
33
from argparse import ArgumentParser
44

55

6-
if __name__ == '__main__':
6+
if __name__ == "__main__":
77
parser = ArgumentParser(
8-
description='A script to update your project dependencies to be in line with the scientific python SPEC 0 support schedule',
9-
)
10-
11-
parser.add_argument('toml_path', default="pyproject.toml", help="Path to the project file that lists the dependencies. defaults to 'pyproject.toml'.")
12-
parser.add_argument('schedule_path', default="schedule.json", help="Path to the schedule json payload. defaults to 'schedule.json'")
8+
description="A script to update your project dependencies to be in line with the scientific python SPEC 0 support schedule",
9+
)
10+
11+
parser.add_argument(
12+
"toml_path",
13+
default="pyproject.toml",
14+
help="Path to the project file that lists the dependencies. defaults to 'pyproject.toml'.",
15+
)
16+
parser.add_argument(
17+
"schedule_path",
18+
default="schedule.json",
19+
help="Path to the schedule json payload. defaults to 'schedule.json'",
20+
)
1321

1422
args = parser.parse_args()
1523

1624
toml_path = Path(args.toml_path)
1725
schedule_path = Path(args.schedule_path)
1826

1927
if not toml_path.exists():
20-
raise ValueError(f"{toml_path} was supplied as path to project file but it did not exist")
28+
raise ValueError(
29+
f"{toml_path} was supplied as path to project file but it did not exist"
30+
)
2131

2232
if not schedule_path.exists():
23-
raise ValueError(f"{schedule_path} was supplied as path to schedule file but it did not exist")
33+
raise ValueError(
34+
f"{schedule_path} was supplied as path to schedule file but it did not exist"
35+
)
2436

2537
project_data = read_toml(toml_path)
2638
schedule_data = read_schedule(schedule_path)

spec0_action/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
parse_version_spec,
1212
read_schedule,
1313
read_toml,
14-
write_toml
14+
write_toml,
1515
)
1616
from packaging.version import Version
1717

1818

1919
__all__ = ["read_schedule", "read_toml", "write_toml", "update_pyproject_toml"]
2020

21+
2122
def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule):
2223
# Iterate by idx because we want to update it inplace
2324
for i in range(len(dependencies)):
@@ -75,15 +76,17 @@ def update_dependency_table(dep_table: dict, new_versions: dict):
7576

7677

7778
def update_pixi_dependencies(pixi_tables: dict, schedule: SupportSchedule):
78-
if "pypi-dependencies" in pixi_tables:
79+
if "pypi-dependencies" in pixi_tables:
7980
update_dependency_table(pixi_tables["pypi-dependencies"], schedule["packages"])
80-
if "dependencies" in pixi_tables:
81+
if "dependencies" in pixi_tables:
8182
update_dependency_table(pixi_tables["dependencies"], schedule["packages"])
8283

8384
if "feature" in pixi_tables:
8485
for _, feature_data in pixi_tables["feature"].items():
8586
if "dependencies" in feature_data:
86-
update_dependency_table(feature_data["dependencies"], schedule["packages"])
87+
update_dependency_table(
88+
feature_data["dependencies"], schedule["packages"]
89+
)
8790

8891

8992
def update_pyproject_toml(
@@ -114,6 +117,6 @@ def update_pyproject_toml(
114117
pyproject_data["project"]["dependencies"], new_version
115118
)
116119

117-
if "tool" in pyproject_data and "pixi" in pyproject_data['tool']:
120+
if "tool" in pyproject_data and "pixi" in pyproject_data["tool"]:
118121
pixi_data = pyproject_data["tool"]["pixi"]
119122
update_pixi_dependencies(pixi_data, new_version)

spec0_action/parsing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def read_schedule(path: Path | str) -> Sequence[SupportSchedule]:
6262
return json.load(file)
6363

6464

65-
def parse_pep_dependency(dep_str: str) -> Tuple[str, str | None, SpecifierSet | Url | None]:
65+
def parse_pep_dependency(
66+
dep_str: str,
67+
) -> Tuple[str, str | None, SpecifierSet | Url | None]:
6668
match = PEP_PACKAGE_IDENT_RE.match(dep_str)
6769
if match is None:
6870
raise ValueError("Could not find any valid python package identifier")
@@ -81,7 +83,7 @@ def parse_pep_dependency(dep_str: str) -> Tuple[str, str | None, SpecifierSet |
8183
return (pkg, extras, spec)
8284

8385

84-
def is_url_spec(str_spec: str|None) -> bool:
86+
def is_url_spec(str_spec: str | None) -> bool:
8587
if str_spec is None:
8688
return False
8789

tests/test_parsing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_pep_dependency_parsing_with_spec_and_optional_dep():
3737
assert features == "[foo,bar]", features
3838
assert spec == SpecifierSet(">=3.7.0,<4"), spec
3939

40+
4041
def test_pep_dependency_parsing_with_spec():
4142
matplotlib_str = "matplotlib>=3.7.0,<4"
4243
pkg, features, spec = parse_pep_dependency(matplotlib_str)

0 commit comments

Comments
 (0)