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

Replace pycodestyle by ruff in ci #36512

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6283126
Add config for ruff
tobiasdiez Oct 22, 2023
75996df
Replace pycodestyle by ruff in ci
tobiasdiez Oct 23, 2023
d7a4bf2
Ignore style rules that are failing
tobiasdiez Oct 23, 2023
4bf15a2
Remove wrong arg
tobiasdiez Oct 23, 2023
4281e8f
Improve problem matcher
tobiasdiez Oct 23, 2023
6d4a971
Fix problem matcher
tobiasdiez Oct 23, 2023
fd04e63
Ignore last failing rules
tobiasdiez Oct 23, 2023
3a3a5ed
Merge branch 'develop' into ruff-vscode
tobiasdiez Nov 5, 2023
8523cc6
Merge branch 'develop' into ruff-vscode
tobiasdiez Nov 10, 2023
9a7b5d6
Merge branch 'develop' into ruff-ci
tobiasdiez Nov 15, 2023
48ba573
Merge branch 'develop' into ruff-vscode
tobiasdiez Nov 17, 2023
1170198
Merge branch 'develop' into ruff-vscode
tobiasdiez Dec 10, 2023
8c1c34d
Merge branch 'develop' into ruff-vscode
tobiasdiez Jan 22, 2024
f55c9aa
Merge branch 'develop' into ruff-ci
tobiasdiez Feb 11, 2024
11d563c
Merge branch 'develop' into ruff-vscode
tobiasdiez Feb 11, 2024
4314ba5
Merge branch 'develop' into ruff-vscode
tobiasdiez Feb 25, 2024
e4dccd8
Merge branch 'develop' into ruff-ci
tobiasdiez Feb 25, 2024
7e1377d
Remove outdated workaround for problem matcher
tobiasdiez Feb 26, 2024
70b5415
Delete .github/workflows/ruff-problem-matcher.json
tobiasdiez Feb 26, 2024
3389e5c
Merge branch 'develop' into ruff-ci
tobiasdiez Mar 10, 2024
259f429
Put select and ignore in `lint` section to silence deprecation warning
tobiasdiez Mar 10, 2024
e41f1e1
Merge branch 'ruff-vscode' into ruff-ci
tobiasdiez Mar 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
"vscode": {
"extensions": [
"guyskk.language-cython",
"ms-python.isort",
"ms-toolsai.jupyter",
"ms-python.vscode-pylance",
"ms-python.pylint",
"ms-python.python",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst"
"trond-snekvik.simple-rst",
"charliermarsh.ruff"
]
}
}
Expand Down
52 changes: 49 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,55 @@ jobs:
id: deps
run: pip install tox

- name: Code style check with pycodestyle
if: (success() || failure()) && steps.deps.outcome == 'success'
run: tox -e pycodestyle-minimal
- name: Code style check with ruff
uses: chartboost/ruff-action@v1
with:
# Ignore the following code style checks (currently failing):
# 3617 I001 [*] Import block is un-sorted or un-formatted
# 3554 PLR2004 [ ] Magic value used in comparison, consider replacing -0.5 with a constant variable
# 2065 F401 [*] `.PyPolyBoRi.Monomial` imported but unused
# 1939 E741 [ ] Ambiguous variable name: `I`
# 1635 F821 [ ] Undefined name `AA`
# 1500 PLR0912 [ ] Too many branches (102 > 12)
# 1156 PLR0913 [ ] Too many arguments to function call (10 > 5)
# 865 E402 [ ] Module level import not at top of file
# 660 PLR0915 [ ] Too many statements (100 > 50)
# 471 PLW2901 [ ] Outer `for` loop variable `ext` overwritten by inner `for` loop target
# 432 PLR5501 [ ] Use `elif` instead of `else` then `if`, to reduce indentation
# 423 PLR0911 [ ] Too many return statements (10 > 6)
# 354 E731 [*] Do not assign a `lambda` expression, use a `def`
# 351 F405 [ ] `ComplexField` may be undefined, or defined from star imports
# 300 PLR1714 [*] Consider merging multiple comparisons. Use a `set` if the elements are hashable.
# 240 F403 [ ] `from .abelian_gps.all import *` used; unable to detect undefined names
# 125 PLR0402 [*] Use `from matplotlib import cm` in lieu of alias
# 111 PLW0603 [ ] Using the global statement to update `AA_0` is discouraged
# 90 E713 [*] Test for membership should be `not in`
# 69 F841 [*] Local variable `B` is assigned to but never used
# 48 PLW0602 [ ] Using global for `D` but no assignment is done
# 44 E714 [*] Test for object identity should be `is not`
# 35 PLR1711 [*] Useless `return` statement at end of function
# 19 PLR1701 [*] Merge `isinstance` calls
# 17 PLW3301 [ ] Nested `max` calls can be flattened
# 15 E721 [ ] Do not compare types, use `isinstance()`
# 15 PLW1510 [ ] `subprocess.run` without explicit `check` argument
# 14 F811 [ ] Redefinition of unused `CompleteDiscreteValuationRings` from line 44
# 14 PLW0120 [ ] `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
# 8 PLC0414 [*] Import alias does not rename original package
# 7 E743 [ ] Ambiguous function name: `I`
# 7 F541 [*] f-string without any placeholders
# 7 PLE0101 [ ] Explicit return in `__init__`
# 7 PLR0124 [ ] Name compared with itself, consider replacing `a == a`
# 5 PLW0127 [ ] Self-assignment of variable `a`
# 4 PLW1508 [ ] Invalid type for environment variable default; expected `str` or `None`
# 3 PLC3002 [ ] Lambda expression called directly. Execute the expression inline instead.
# 2 E742 [ ] Ambiguous class name: `I`
# 2 PLE0302 [ ] The special method `__len__` expects 1 parameter, 3 were given
# 1 E701 [ ] Multiple statements on one line (colon)
# 1 F402 [ ] Import `factor` from line 259 shadowed by loop variable
# 1 F823 [ ] Local variable `zero` referenced before assignment
# 1 PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
# 1 PLW0129 [ ] Asserting on a non-empty string literal will always pass
args: check --output-format github --ignore I001,PLR2004,F401,E741,F821,PLR0912,PLR0913,E402,PLR0915,PLW2901,PLR5501,PLR0911,E731,F405,PLR1714,F403,PLR0402,PLW0603,E713,F841,PLW0602,E714,PLR1711,PLR1701,PLW3301,E721,PLW1510,F811,PLW0120,PLC0414,E743,F541,PLE0101,PLR0124,PLW0127,PLW1508,PLC3002,E742,PLE0302,E701,F402,F823,PLC0208,PLW0129,E902

- name: Code style check with relint
if: (success() || failure()) && steps.deps.outcome == 'success'
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// List of extensions which should be recommended for developers when a workspace is opened for the first time.
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
"recommendations": [
"ms-python.python"
"ms-python.python",
"charliermarsh.ruff"
],
}
5 changes: 0 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
"--doctest-modules"
],
"python.testing.unittestEnabled": false,
"python.linting.pycodestyleEnabled": true,
"python.linting.enabled": true,
// The following pycodestyle arguments are the same as the pycodestyle-minimal
// tox environnment, see the file SAGE_ROOT/src/tox.ini
"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"],
"cSpell.words": [
"furo",
"Conda",
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.ruff]
# Assume Python 3.9
target-version = "py39"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
"F", # pyflakes - https://docs.astral.sh/ruff/rules/#pyflakes-f
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
"PL", # pylint - https://docs.astral.sh/ruff/rules/#pylint-pl
]
ignore = [
"E501", # Line too long - hard to avoid in doctests, and better handled by black.
]
Loading