Skip to content

Commit d890829

Browse files
author
Release Manager
committed
sagemathgh-37452: Add config for ruff (sagemath#36503, unbundled) <!-- ^^^^^ 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 --> Author: @mkoeppe, based on @tobiasdiez's config in sagemath#36503. Adding a configuration for the ruff linter as proposed in sagemath#36503 is timely and uncontroversial. However, sagemath#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 (sagemath#36503 (comment)). Generalizing the use of `pyproject.toml` to "[non-package projects](https://peps.python.org/pep-0735/#motivation)" is still subject to discussion in the Python community in [PEP 735](https://peps.python.org/pep-0735/) (Nov 2023). **The scope of PRs should be chosen to minimize friction, not to maximize friction.** sagemath#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](https://docs.astral.sh/ruff/configuration/#config-file- discovery). And this is the location of most of our other linter configuration files. Reference on previous common denominator PRs: sagemath#36666 (comment), sagemath#36666 (comment), sagemath#36572 (comment), sagemath#36960 (comment), sagemath#36960 (comment), ... <!-- 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: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#37452 Reported by: Matthias Köppe Reviewer(s): Giacomo Pope, Matthias Köppe
2 parents 3d59d9c + 9914a6c commit d890829

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

.devcontainer/devcontainer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@
2222
"vscode": {
2323
"extensions": [
2424
"guyskk.language-cython",
25-
"ms-python.isort",
2625
"ms-toolsai.jupyter",
2726
"ms-python.vscode-pylance",
28-
"ms-python.pylint",
2927
"ms-python.python",
3028
"lextudio.restructuredtext",
31-
"trond-snekvik.simple-rst"
29+
"trond-snekvik.simple-rst",
30+
"charliermarsh.ruff"
3231
]
3332
}
3433
}

.vscode/extensions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// List of extensions which should be recommended for developers when a workspace is opened for the first time.
33
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
44
"recommendations": [
5-
"ms-python.python"
5+
"ms-python.python",
6+
"charliermarsh.ruff"
67
],
78
}

.vscode/settings.json

-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
"--doctest-modules"
2525
],
2626
"python.testing.unittestEnabled": false,
27-
"python.linting.pycodestyleEnabled": true,
28-
"python.linting.enabled": true,
29-
// The following pycodestyle arguments are the same as the pycodestyle-minimal
30-
// tox environnment, see the file SAGE_ROOT/src/tox.ini
31-
"python.linting.pycodestyleArgs": ["--select= E111,E21,E222,E225,E227,E228,E25,E271,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605"],
3227
"cSpell.words": [
3328
"furo",
3429
"Conda",

ruff.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# https://docs.astral.sh/ruff/configuration/#config-file-discovery
2+
3+
# Assume Python 3.9
4+
target-version = "py39"
5+
6+
select = [
7+
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
8+
"F", # pyflakes - https://docs.astral.sh/ruff/rules/#pyflakes-f
9+
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
10+
"PL", # pylint - https://docs.astral.sh/ruff/rules/#pylint-pl
11+
]
12+
ignore = [
13+
"E501", # Line too long - hard to avoid in doctests, and better handled by black.
14+
]

0 commit comments

Comments
 (0)