Skip to content

Commit 4b24a34

Browse files
style: migrate to ruff
1 parent 390ba3c commit 4b24a34

9 files changed

+20
-31
lines changed

.devcontainer/Containerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2424
COPY .devcontainer/requirements.txt .
2525
RUN python3 -m venv /opt/venv
2626
ENV PATH="/opt/venv/bin:$PATH"
27-
RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel isort
27+
RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel
2828
RUN pip3 install --no-cache-dir -r requirements.txt
2929

3030
RUN find /opt/venv/lib/ -follow -type f -name '*.a' -delete \

.devcontainer/devcontainer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"bungcip.better-toml",
2727
"github.copilot",
2828
"ms-azuretools.vscode-docker",
29+
"charliermarsh.ruff",
2930
"ms-python.python",
3031
"ms-python.vscode-pylance",
3132
"ms-vscode-remote.remote-containers",
@@ -37,10 +38,7 @@
3738
],
3839
"settings": {
3940
"python.analysis.typeCheckingMode": "basic",
40-
"python.languageServer": "Jedi",
4141
"python.linting.enabled": true,
42-
"python.linting.pylintEnabled": true,
43-
"python.formatting.provider": "black",
4442
"python.testing.pytestArgs": [
4543
"tests"
4644
],
@@ -52,7 +50,8 @@
5250
"editor.formatOnSave": true,
5351
"editor.inlineSuggest.enabled": true,
5452
"editor.codeActionsOnSave": {
55-
"source.organizeImports": true
53+
"source.organizeImports": true,
54+
"source.fixAll": true
5655
},
5756
"workbench.editorAssociations": {
5857
"*.ipynb": "jupyter-notebook"

.devcontainer/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ black
22
mypy>=0.900
33
numpy>=1.22.0
44
pre-commit>=2.18.0
5-
pylint>=2.5.0
65
pytest>=6.0.0
6+
ruff
77
scipy>=1.10.0

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.pyc
77
.pytest_cache/
88
.mypy_cache/
9+
.ruff_cache/
910

1011
data/
1112
models/

.github/workflows/python.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
run: |
4141
python -m pip install --upgrade pip wheel setuptools
4242
python -m pip install -r .devcontainer/requirements.txt
43-
- name: Lint with pylint
43+
- name: Ruff
4444
run: |
45-
pylint src
45+
ruff check src
4646
- name: Test with PyTest
4747
run: |
4848
pytest -v .

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.pyc
55
.pytest_cache/
66
.mypy_cache/
7+
.ruff_cache/
78

89
venv/
910
data/

.pre-commit-config.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ repos:
1818
rev: v1.3.0
1919
hooks:
2020
- id: mypy
21-
- repo: https://github.com/pycqa/isort
22-
rev: 5.12.0
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: v0.0.269
2323
hooks:
24-
- id: isort
25-
args: ["--profile", "black"]
24+
- id: ruff

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ clean:
1010
find . -type f -name "__pycache__" -delete
1111
rm -rf .mypy_cache/
1212
rm -rf .pytest_cache/
13+
rm -rf .ruff_cache/
1314

1415
## Testing
1516
test:
@@ -18,6 +19,5 @@ test:
1819
## Basic linting
1920
lint:
2021
black src
21-
isort src --profile=black
22+
ruff check src
2223
mypy src
23-
pylint src

pyproject.toml

+6-17
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
[tool.isort]
2-
profile = "black"
3-
4-
[tool.black]
1+
[tool.ruff]
2+
select = ["E", "F"]
53
line-length = 88
64

7-
[tool.pylint.messages_control]
8-
disable = [
9-
"no-member",
10-
"too-many-arguments",
11-
"too-few-public-methods",
12-
"no-else-return",
13-
"duplicate-code",
14-
"too-many-branches",
15-
"redefined-builtin",
16-
"dangerous-default-value",
17-
]
5+
[tool.ruff.isort]
6+
lines-after-imports = 2
187

19-
[tool.pylint.format]
20-
max-line-length = 88
8+
[tool.black]
9+
line-length = 88
2110

2211
[[tool.mypy.overrides]]
2312
ignore_missing_imports = true

0 commit comments

Comments
 (0)