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

Support range in required-version setting #10192

Closed
kujenga opened this issue Mar 2, 2024 · 6 comments · Fixed by #10216
Closed

Support range in required-version setting #10192

kujenga opened this issue Mar 2, 2024 · 6 comments · Fixed by #10216
Assignees
Labels
configuration Related to settings and configuration good first issue Good for newcomers help wanted Contributions especially welcome

Comments

@kujenga
Copy link

kujenga commented Mar 2, 2024

Currently, it appears that the required-version [1] setting allows just a single specific version to be specified. When a version of ruff is present that differs from this version, the ruff tool errors, preventing checks from running.

The ask here is to allow range syntax, e.g. >=, ~, etc., or perhaps treat the required-version as a minimum similar to target-version, so that ruff does not fail to run in the scenario that e.g. a developer upgrades ruff in their environment but is working within a repo that wants to ensure that everyone is on some minimum version of ruff.

$ ruff --version
ruff 0.3.0

$ cat ruff.toml
required-version = "0.2.2"

$ ruff check ./src/example/file.py
ruff failed
  Cause: Required version `0.2.2` does not match the running version `0.3.0`

[1] https://docs.astral.sh/ruff/settings/#required-version

@charliermarsh
Copy link
Member

I think it'd be reasonable to support >= here.

@charliermarsh charliermarsh added the configuration Related to settings and configuration label Mar 2, 2024
@charliermarsh
Copy link
Member

(We just need to make it backwards-compatible such that "0.2.2" means "==0.2.2".)

@charliermarsh charliermarsh added the good first issue Good for newcomers label Mar 2, 2024
@MichaReiser
Copy link
Member

MichaReiser commented Mar 2, 2024

I think it'd be reasonable to support >= here.

I think we would need to support a full semver syntax similar to package.json engines or it might be surprising that e.g. `<= isn't supported which, IMO, is entirely reasonable too

A first step before a PR is to spec out the exact behavior of that field with the supported syntax to avoid long discussions on the PR

@MichaReiser MichaReiser added help wanted Contributions especially welcome and removed good first issue Good for newcomers labels Mar 2, 2024
@charliermarsh
Copy link
Member

Correct, that’s what I meant — we should use Python’s PEP 440 and PEP 508 specifiers since they’re already native, standardized, used in the same TOML file, and we have parsers for them. I don’t think there needs to be any more decision-making than that, personally!

@MichaReiser
Copy link
Member

Seems reasonable, although PEP440 is probably more flexible than what we need (local versions). PEP508 seems unrelated because we don't need a name portion.

@charliermarsh
Copy link
Member

👍 The gist of it is: it should just function identically to requires-python which is a standardized field that we already parse and support (see: crates/ruff_workspace/src/pyproject.rs).

@MichaReiser MichaReiser added the good first issue Good for newcomers label Mar 2, 2024
@charliermarsh charliermarsh self-assigned this Mar 3, 2024
charliermarsh added a commit that referenced this issue Mar 3, 2024
## Summary

Allows `required-version` to be set with a version specifier, like
`>=0.3.1`.

If a single version is provided, falls back to assuming `==0.3.1`, for
backwards compatibility.

Closes #10192.
nkxxll pushed a commit to nkxxll/ruff that referenced this issue Mar 10, 2024
)

## Summary

Allows `required-version` to be set with a version specifier, like
`>=0.3.1`.

If a single version is provided, falls back to assuming `==0.3.1`, for
backwards compatibility.

Closes astral-sh#10192.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Related to settings and configuration good first issue Good for newcomers help wanted Contributions especially welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants