mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-05-20 16:00:14 +02:00
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
This commit is contained in:
+6
-3
@@ -30745,9 +30745,12 @@ function getRuffVersionFromPyproject(filePath) {
|
||||
return undefined;
|
||||
}
|
||||
const dependencies = pyproject?.project?.dependencies || [];
|
||||
const devDependencies = pyproject?.["dependency-groups"]?.dev || [];
|
||||
const ruffVersionDefinition = dependencies.find((dep) => dep.startsWith("ruff")) ||
|
||||
devDependencies.find((dep) => dep.startsWith("ruff"));
|
||||
const optionalDependencies = Object.values(pyproject?.project?.["optional-dependencies"] || {}).flat();
|
||||
const devDependencies = Object.values(pyproject?.["dependency-groups"] || {})
|
||||
.flat()
|
||||
.filter((item) => typeof item === "string");
|
||||
const allDependencies = dependencies.concat(optionalDependencies, devDependencies);
|
||||
const ruffVersionDefinition = allDependencies.find((dep) => dep.startsWith("ruff"));
|
||||
if (ruffVersionDefinition) {
|
||||
const ruffVersion = ruffVersionDefinition
|
||||
.match(/^ruff([^A-Z0-9._-]+.*)$/)?.[1]
|
||||
|
||||
Reference in New Issue
Block a user