Skip to content

Commit 4138d30

Browse files
committed
Switch to ruff
because: 1. it's faster (i.e., energy and time usages) 2. it's more flexible (i.e., good for mental health) 3. flake8 with Flake8-pyproject per-file-ignores with a comment per line wouldn't work à la: per-file-ignores = [ '**/__init__.py:F401', # imported but unused # the following ignored rules allow for tabular data in the tests (mostly) 'tests/test_*.py:E203', # whitespace before ',' 'tests/test_*.py:E202', # whitespace before ']' 'tests/test_*.py:E126', # continuation line over-indented for hanging indent 'tests/test_*.py:E121', # continuation line under-indented for hanging indent 'tests/test_*.py:E128', # continuation line under-indented for visual indent 'tests/test_*.py:E231', # missing whitespace after {',', ':'} # gallery examples also divert from standard style 'docs/examples/*/*.py:E402', # module level import not at top of file ]
1 parent e47deee commit 4138d30

5 files changed

Lines changed: 35 additions & 56 deletions

File tree

.github/workflows/flake8-linter-matcher.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/flake8.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/ruff.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Lint Python code
2+
on:
3+
pull_request:
4+
jobs:
5+
flake8-linter:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout source
9+
uses: actions/checkout@v4
10+
- uses: astral-sh/ruff-action@v4.0.0
11+
# https://github.com/astral-sh/ruff-action

pyproject.toml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,40 @@ all = ["pvlib[optional,doc,test,lint]"]
8888
Documentation = "https://pvlib-python.readthedocs.io/"
8989
"Source Code" = "https://github.com/pvlib/pvlib-python"
9090

91-
[tool.flake8]
92-
ignore = [
93-
'E201', # Whitespace after '('
94-
'E241', # Multiple spaces after ','
95-
'E226', # Missing whitespace around arithmetic operator
96-
'W503', # Line break occurred before a binary operator
97-
'W504', # Line break occurred after a binary operator
98-
]
99-
per-file-ignores = [
100-
'**/__init__.py:F401',
101-
]
102-
max-line-length = 79
91+
[tool.ruff]
92+
line-length = 79
10393
exclude = [
10494
# speed up .py files discovery
10595
'.git',
96+
'build', # created during local packaging
10697
# cache directories
10798
'__pycache__',
10899
# Virtual environment folders (same as in .gitignore)
109100
'venv', 'env',
110101
# built documentation generates .py examples files for their download, skip them
111102
'docs/sphinx/build',
103+
'docs/sphinx/source/gallery',
104+
# .ipynb outdated tutorials
105+
'docs/tutorials/',
106+
]
107+
108+
[tool.ruff.lint]
109+
ignore = [
110+
'E201', # Whitespace after '('
111+
'E241', # Multiple spaces after ','
112+
'E226', # Missing whitespace around arithmetic operator
112113
]
114+
per-file-ignores = {
115+
'**/__init__.py' = ['F401'], # imported but unused
116+
# the following ignored rules allow for tabular data in the tests (mostly)
117+
'tests/**/test_*.py' = [
118+
'E203', # whitespace before ','
119+
'E202', # whitespace before ']'
120+
'E231', # missing whitespace after {',', ':'}
121+
],
122+
# gallery examples also divert from standard style
123+
'docs/examples/**/*.py' = ['E402'], # module level import not at top of file
124+
}
113125

114126
[tool.setuptools]
115127
# do not include all non-python files in the bdist by default, but select them manually

setup.cfg

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)