mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-05-12 20:50:14 +02:00
Add support for reading the ruff version from Poetry groups (#127)
Not sure if this is a desired feature since this was requested already (https://github.com/astral-sh/ruff-action/issues/40#issuecomment-2581207691) without any sort of response. Unfortunately Poetry doesn't yet support PEP 735 (https://github.com/python-poetry/poetry/issues/9751) and it doesn't make sense to add ruff as a project dependency.
This commit is contained in:
+14
-1
@@ -30933,7 +30933,20 @@ function parsePyproject(pyprojectContent) {
|
||||
const devDependencies = Object.values(pyproject?.["dependency-groups"] || {})
|
||||
.flat()
|
||||
.filter((item) => typeof item === "string");
|
||||
return getRuffVersionFromAllDependencies(dependencies.concat(optionalDependencies, devDependencies));
|
||||
return (getRuffVersionFromAllDependencies(dependencies.concat(optionalDependencies, devDependencies)) || getRuffVersionFromPoetryGroups(pyproject));
|
||||
}
|
||||
function getRuffVersionFromPoetryGroups(pyproject) {
|
||||
// Special handling for Poetry until it supports PEP 735
|
||||
// See: <https://github.com/python-poetry/poetry/issues/9751>
|
||||
const poetryGroups = Object.values(pyproject?.tool?.poetry?.group || {});
|
||||
return poetryGroups
|
||||
.flatMap((group) => Object.entries(group.dependencies))
|
||||
.map(([name, spec]) => {
|
||||
if (name === "ruff" && typeof spec === "string")
|
||||
return spec;
|
||||
return undefined;
|
||||
})
|
||||
.find((version) => version !== undefined);
|
||||
}
|
||||
function getRuffVersionFromRequirementsFile(filePath) {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
|
||||
Reference in New Issue
Block a user