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

Add config for ruff (#36503, unbundled) #37452

Merged
merged 3 commits into from
Mar 31, 2024

Conversation

mkoeppe
Copy link
Member

@mkoeppe mkoeppe commented Feb 24, 2024

Author: @mkoeppe, based on @tobiasdiez's config in #36503.

Adding a configuration for the ruff linter as proposed in #36503 is timely and uncontroversial.

However, #36503 bundled this gratuitously with the controversial design of creating a pyproject.toml file in SAGE_ROOT.

pyproject.toml -- by definition in PEP 518, PEP 621 -- marks a directory as a Python project, i.e., the source directory of a Python distribution package (#36503 (comment)).
Generalizing the use of pyproject.toml to "non-package projects" is still subject to discussion in the Python community in PEP 735 (Nov 2023).

The scope of PRs should be chosen to minimize friction, not to maximize friction.
#36726 (comment)
Here we remove the artificial friction from the gratuitous bundling, by configuring ruff in ruff.toml instead. Configuration in ruff.toml and pyproject.toml has equal validity / standing per ruff documentation. And this is the location of most of our other linter configuration files.

Reference on previous common denominator PRs: #36666 (comment), #36666 (comment), #36572 (comment), #36960 (comment), #36960 (comment), ...

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

@mkoeppe
Copy link
Member Author

mkoeppe commented Feb 24, 2024

@fchapoton Any comments on the specific configuration settings?

[Edit: More specific settings in #37453. If there's interest to discuss, let's do that over there.]

@mkoeppe
Copy link
Member Author

mkoeppe commented Feb 24, 2024

Marking #36503 as a duplicate. @vbraun @roed314

@mkoeppe
Copy link
Member Author

mkoeppe commented Feb 27, 2024

I've moved ruff.toml to the SAGE_ROOT now, to address the plausible concern in #36503 (comment) that source files outside of src/ should be addressed.

@mkoeppe
Copy link
Member Author

mkoeppe commented Feb 27, 2024

I don't find the other claims there, that somehow ruff.toml does not work when pyproject.toml works, believable.

@mkoeppe
Copy link
Member Author

mkoeppe commented Feb 27, 2024

The cherry-picked opinion in #36503 (comment) that pyproject.toml is OK for non–Python project directories does not outweigh my concern (#36503 (comment)) that pyproject.toml will mislead users into trying to use pip install .

@mkoeppe
Copy link
Member Author

mkoeppe commented Feb 27, 2024

And finally, the very point of this PR opened with the intent of reducing the gratuitous friction that halted #36503 is NOT to establish ruff.toml as the dogmatic final location of this configuration, but to merge something.

If/when a meaningful pyproject.toml is established in SAGE_ROOT, it will be trivial and obvious to merge ruff.toml into it.

@edgarcosta
Copy link
Member

It seems that @GiacomoPope and I are in agreement.
I would also not qualify myself as an expert, but I also don't think we need to be extra cautious with these small changes.

@GiacomoPope
Copy link
Contributor

Not sure I understand the build & test fail though...

@mkoeppe
Copy link
Member Author

mkoeppe commented Mar 14, 2024

The test failure is unrelated -- that's tracked in #37536

@jhpalmieri
Copy link
Member

I'm posting to record a vote of -1 on behalf of Tobias Diez.

@GiacomoPope
Copy link
Contributor

Did Tobias mention the root cause of the minus one? Are the current ruff settings insufficient for Sage, or does he believe ruff shouldn't be used at all? I would love ruff to become the default linter if only for saving global CPU time with all the CI testing.

@mkoeppe
Copy link
Member Author

mkoeppe commented Mar 14, 2024

@GiacomoPope See ticket description.

@GiacomoPope
Copy link
Contributor

I vaguely followed the linked PR but your comment was that extracting out the use of ruff was uncontroversial, so I don't really understand. This seems to make ruff functional for SageMath in a way which doesnt cause an issue -- my question was then why -1 unless there's something wrong with this was of including ruff?

@mkoeppe
Copy link
Member Author

mkoeppe commented Mar 14, 2024

your comment was that extracting out the use of ruff was uncontroversial,

Adding a ruff configuration is uncontroversial. #36503 demands that it be added in pyproject.toml. My interpretation of the -1 here is that Tobias continues his grandstanding about this.

@mkoeppe mkoeppe requested review from kiwifb and kwankyu March 14, 2024 22:25
@kwankyu
Copy link
Collaborator

kwankyu commented Mar 14, 2024

Regardless of the material of this PR, I am -1 because this part of the PR description

Author: @tobiasdiez

Reviewer: @mkoeppe

disrupts the conventional workflow of sage development. I have the same opinion to all such PRs.

@mkoeppe
Copy link
Member Author

mkoeppe commented Mar 14, 2024

@kwankyu How would you suggest to resolve this?

@mkoeppe
Copy link
Member Author

mkoeppe commented Mar 14, 2024

I've changed it to: "Author: @mkoeppe, based on @tobiasdiez's config in #36503."
Does this resolve your concern?

I do wish to give authorship credit (it is of course also reflected on the commit).

@kwankyu
Copy link
Collaborator

kwankyu commented Mar 15, 2024

I've changed it to: "Author: @mkoeppe, based on @tobiasdiez's config in #36503." Does this resolve your concern?

Yes. Then I retract my vote. That is, no vote.

@roed314
Copy link
Contributor

roed314 commented Mar 15, 2024

Based on @kwankyu's suggestion and discussion by the new Code of Conduct Committee, I'm setting this ticket to Needs Review so that all the disputed tickets start with a clean slate prior to being update based on voting. Starting at midnight US/Pacific time tonight anyone involved should feel free to set the status to positive review or needs review in accordance with the new policy.

@culler
Copy link
Contributor

culler commented Mar 16, 2024

I think this looks like a sensible way to add ruff support to Sage. I vote +1.

@edgarcosta
Copy link
Member

+1

1 similar comment
@saraedum
Copy link
Member

👍

@mkoeppe
Copy link
Member Author

mkoeppe commented Mar 26, 2024

I'm counting:

So I am setting to "positive review".

@vbraun vbraun merged commit d890829 into sagemath:develop Mar 31, 2024
23 of 24 checks passed
@mkoeppe mkoeppe added this to the sage-10.4 milestone Mar 31, 2024
vbraun pushed a commit to vbraun/sage that referenced this pull request May 18, 2024
…H Actions: run `ruff-minimal`

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

`./sage -tox` and the GH Actions "Lint" workflow now additionally run
`ruff-minimal`.

The "Lint" workflow outputs GitHub annotations for view in the "Files
changed" tab, as pioneered in sagemath#36512 (see screenshot there). Demo:
https://github.com/sagemath/sage/pull/37456/files

We use the built-in capability of ruff to output via
`RUFF_OUTPUT_FORMAT=github` (no problem matcher is needed; see
https://github.com/ChartBoost/ruff-
action/issues/7#issuecomment-1887780308). (This has been adopted in the
revised sagemath#36512.)

sagemath#36512 (comment) is
marked "disputed" because it builds upon the
sagemath#36503, which bundles a
controversial design choice, as explained in sagemath#37452.

In further contrast to sagemath#36512, we do not remove the pycodestyle-minimal
run from the "Lint" workflow. This can be done in a follow-up, once we
have gained the necessary experience with the new linter (see previous
info request in
sagemath#36512 (comment)).
Hence I am marking sagemath#36512 not as a "duplicate" but as "pending"; and
"disputed" because of its dependency on the "disputed" sagemath#36503. @roed314
@vbraun

And in further contrast to sagemath#36512, the minimal ruff configuration used
by the CI can be used locally with `./sage -tox -e ruff-minimal` and
also runs as part of the default tests in `./sage -tox`.

Authors: @mkoeppe, @tobiasdiez (credit for the first version of the
minimal ruff configuration taken from sagemath#36512, now regenerated)

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#37452

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37453
Reported by: Matthias Köppe
Reviewer(s): Frédéric Chapoton, Kwankyu Lee, Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request May 24, 2024
…H Actions: run `ruff-minimal`

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

`./sage -tox` and the GH Actions "Lint" workflow now additionally run
`ruff-minimal`.

The "Lint" workflow outputs GitHub annotations for view in the "Files
changed" tab, as pioneered in sagemath#36512 (see screenshot there). Demo:
https://github.com/sagemath/sage/pull/37456/files

We use the built-in capability of ruff to output via
`RUFF_OUTPUT_FORMAT=github` (no problem matcher is needed; see
https://github.com/ChartBoost/ruff-
action/issues/7#issuecomment-1887780308). (This has been adopted in the
revised sagemath#36512.)

sagemath#36512 (comment) is
marked "disputed" because it builds upon the
sagemath#36503, which bundles a
controversial design choice, as explained in sagemath#37452.

In further contrast to sagemath#36512, we do not remove the pycodestyle-minimal
run from the "Lint" workflow. This can be done in a follow-up, once we
have gained the necessary experience with the new linter (see previous
info request in
sagemath#36512 (comment)).
Hence I am marking sagemath#36512 not as a "duplicate" but as "pending"; and
"disputed" because of its dependency on the "disputed" sagemath#36503. @roed314
@vbraun

And in further contrast to sagemath#36512, the minimal ruff configuration used
by the CI can be used locally with `./sage -tox -e ruff-minimal` and
also runs as part of the default tests in `./sage -tox`.

Authors: @mkoeppe, @tobiasdiez (credit for the first version of the
minimal ruff configuration taken from sagemath#36512, now regenerated)

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#37452

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37453
Reported by: Matthias Köppe
Reviewer(s): Frédéric Chapoton, Kwankyu Lee, Matthias Köppe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: scripts disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants