Skip to content

Commit f14634c

Browse files
authored
Read the [project.optional-dependencies] and [dependency-groups] tables (#66)
I'd quite like to use `ruff-action`'s auto-detection feature, but it currently doesn't read the `[project.optional-dependency]` table, and support for the PEP 735 `[dependency-groups]` table is currently limited to only the special-cased `dev` key, and does not account for the possibility of `{include-group="..."}` inline tables, as [described by the PEP](https://peps.python.org/pep-0735/#dependency-group-include). I have guessed how to make the tests work, as the only JS development I do is plain JS (sans frameworks), so TypeScript is still quite new to me -- feel free to push required changes to this branch. A
1 parent 47de3de commit f14634c

File tree

12 files changed

+105
-10
lines changed

12 files changed

+105
-10
lines changed

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,40 @@ jobs:
8484
fi
8585
env:
8686
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
87+
test-default-version-from-pyproject-dependency-groups:
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v4
91+
- name: Use default version from pyproject.toml dependency groups
92+
id: ruff-action
93+
uses: ./
94+
with:
95+
src: __tests__/fixtures/pyproject-dependency-groups-project
96+
version-file: __tests__/fixtures/pyproject-dependency-groups-project/pyproject.toml
97+
- name: Correct version gets installed
98+
run: |
99+
if [ "$RUFF_VERSION" != "0.8.3" ]; then
100+
exit 1
101+
fi
102+
env:
103+
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
104+
test-default-version-from-pyproject-optional-dependencies:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v4
108+
- name: Use default version from pyproject.toml optional dependencies
109+
id: ruff-action
110+
uses: ./
111+
with:
112+
src: __tests__/fixtures/pyproject-optional-dependencies-project
113+
version-file: __tests__/fixtures/pyproject-optional-dependencies-project/pyproject.toml
114+
- name: Correct version gets installed
115+
run: |
116+
if [ "$RUFF_VERSION" != "0.8.3" ]; then
117+
exit 1
118+
fi
119+
env:
120+
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
87121
test-semver-range:
88122
runs-on: ubuntu-latest
89123
steps:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ This action adds ruff to the PATH, so you can use it in subsequent steps.
8181

8282
By default this action looks for a pyproject.toml file in the root of the repository to determine
8383
the ruff version to install. If no pyproject.toml file is found, or no ruff version is defined in
84-
either `dependencies` or `dependency-groups.dev` the latest version is installed.
84+
`project.dependencies`, `project.optional-dependencies`, or `dependency-groups`,
85+
the latest version is installed.
8586

8687
#### Install the latest version
8788

__tests__/fixtures/pyproject-dependency-groups-project/README.md

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "pyproject-dependency-groups-project"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
8+
[dependency-groups]
9+
dev = [
10+
{ include-group = "docs" },
11+
{ include-group = "lint" },
12+
]
13+
docs = [
14+
"sphinx",
15+
]
16+
lint = [
17+
"ruff==0.8.3",
18+
]
19+
20+
[build-system]
21+
requires = ["hatchling"]
22+
build-backend = "hatchling.build"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def hello() -> str:
2+
return "Hello from python-project!"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello world!")

__tests__/fixtures/pyproject-optional-dependencies-project/README.md

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[project]
2+
name = "pyproject-optional-dependencies-project"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
8+
[project.optional-dependencies]
9+
lint = [
10+
"ruff==0.8.3",
11+
]
12+
13+
[build-system]
14+
requires = ["hatchling"]
15+
build-backend = "hatchling.build"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def hello() -> str:
2+
return "Hello from python-project!"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello world!")

0 commit comments

Comments
 (0)