Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Default to Ruff version from project setup #9

Closed
cknowles opened this issue Oct 2, 2024 · 5 comments · Fixed by #30
Closed

Feature request: Default to Ruff version from project setup #9

cknowles opened this issue Oct 2, 2024 · 5 comments · Fixed by #30

Comments

@cknowles
Copy link

cknowles commented Oct 2, 2024

At the moment the action defaults to the latest version of Ruff. In order to match local behaviour, it would be good if the action defaulted to the version matching that inside pyproject.toml / poetry.lock.

@Avasam
Copy link

Avasam commented Oct 11, 2024

There's some issues and hidden complexity with that:

  • Support for different tools
    • you just mentioned poetry as an example
    • there's uv dev dependencies too for another
    • Good ol' requirements files
  • Finding it in extras (like .[test] or .[dev])
  • Mixed version ranges
  • What to do about system and platforms restrictions ?

It'd be nice, but I don't think you should hold your breath on this, and instead just find the version string yourself with an easy string search srcipt.
Here's an example with powershell: https://github.com/Avasam/typed-D3DShot/blob/24954b8122448926b9afddc1c245796b5e9165a0/.github/workflows/checks.yml#L24-L34
Here's one with Bash: https://github.com/Toufool/AutoSplit/blob/bd6cf54fdd3569c769e5c9d4ef9aab64344fca84/.github/workflows/lint-and-build.yml#L81-L94

Note that you'll have to extract an exact version (see #11)

@pjonsson
Copy link

My guess is that some mechanism that attempts to pick the Ruff version from the project setup, and fail with an error message if the version can't be determined automatically would satisfy most people. The few projects that have complex setups that use different versions of Ruff for different platform/systems can then set the version in the action instead.

Here's how the black action does it: psf/black#4294. It would be nice if the Ruff action just works without having to add some other action to get Python 3.11 configured first.

@Samuel-Therrien-Beslogic

I think searching from a pyproject.toml would cover most cases. With the following priority, highest Ruff version match found in:

  • project.dependencies
  • project.dependency-groups.dev (new canonical dev dependencies)
  • project.optional-dependencies.dev (old common dev dependencies)
  • Any other project.dependency-groups
  • Any other project.optional-dependencies
  • (optional) Some (.+?-)?requirements(-.+?)?.txt (maybe only if a requirements file is indicated as the source to find the version?)

@eifinger
Copy link
Collaborator

#30 changes the default behavior to:

  • Search for a pyproject.toml in the repo root
  • Search in project.dependencies and dependency-groups.dev for ruff
  • If none is found use latest

Support for requirements.txt files can be added later

@AA-Turner
Copy link
Contributor

AA-Turner commented Jan 2, 2025

Would it be possible to explicitly provide the name of an extra or dependency group? In Sphinx, we use a lint extra currently for Ruff, and will likely move to a lint dependency group when the tools we use support them. We currently use an awk command in GitHub Actions to extract the Ruff version, which clearly isn't ideal.

Thank you very much for your work on this project!

A


https://github.com/sphinx-doc/sphinx/blob/90d50c1320e6f0767cf022ff44204739e0d52bbc/pyproject.toml#L79-L84

https://github.com/sphinx-doc/sphinx/blob/90d50c1320e6f0767cf022ff44204739e0d52bbc/.github/workflows/lint.yml#L29-L32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
@Avasam @eifinger @pjonsson @cknowles @AA-Turner @Samuel-Therrien-Beslogic and others