Skip to content

Commit b600e4b

Browse files
authored
Merge pull request #216 from yamap55/add/ruff
change linter from flake8 to Ruff
2 parents 1fa2994 + 06bea7e commit b600e4b

9 files changed

Lines changed: 503 additions & 595 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"python.pythonPath": "/project/.venv/bin/python",
2424
"python.linting.pylintEnabled": false,
2525
"python.linting.enabled": true,
26-
"python.linting.flake8Enabled": true,
27-
"python.linting.flake8Args": ["--config=.flake8"],
26+
"python.linting.flake8Enabled": false,
2827
"python.linting.lintOnSave": true,
2928
"python.formatting.provider": "black",
3029
"python.formatting.blackArgs": ["--line-length", "100"],
@@ -35,15 +34,18 @@
3534
"python.jediEnabled": false,
3635
"python.languageServer": "Pylance",
3736
"python.analysis.typeCheckingMode": "basic",
37+
"ruff.showNotifications": "always",
3838
"vsintellicode.python.completionsEnabled": true,
3939
"vsintellicode.features.python.deepLearning": "enabled",
4040
"vsintellicode.modify.editor.suggestSelection": "enabled",
4141
"editor.formatOnSave": true,
4242
"editor.codeActionsOnSave": {
43-
"source.organizeImports": true
43+
"source.organizeImports": false,
44+
"source.fixAll": true
4445
},
4546
"[python]": {
46-
"editor.tabSize": 4
47+
"editor.tabSize": 4,
48+
"editor.formatOnPaste": false
4749
},
4850
"[json]": {
4951
"editor.tabSize": 2
@@ -63,7 +65,8 @@
6365
"VisualStudioExptTeam.vscodeintellicode",
6466
"exiasr.hadolint",
6567
"bungcip.better-toml",
66-
"usernamehw.errorlens"
68+
"usernamehw.errorlens",
69+
"charliermarsh.ruff"
6770
]
6871
}
6972
},

.flake8

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

.github/actions/ruff.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
runner:
2+
ruff:
3+
cmd: poetry run ruff check . 2> /dev/null
4+
errorformat:
5+
- "%f:%l:%c: %m"
6+
- "%-G%.%#"

.github/workflows/flake8.yml

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

.github/workflows/ruff.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: ruff
2+
3+
on: [push]
4+
5+
jobs:
6+
ruff:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: set up python
11+
uses: ./.github/actions/python_setup
12+
- name: set up poetry
13+
uses: ./.github/actions/poetry_setup
14+
- name: Setup reviewdog
15+
uses: reviewdog/action-setup@v1.0.3
16+
- name: run analyze(use reviewdog)
17+
env:
18+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
run: reviewdog -conf=./.github/actions/ruff.yml -reporter=github-check -filter-mode=nofilter -fail-on-error

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,6 @@ Thumbs.db
145145
# log
146146
*.log.*
147147
*.log
148+
149+
# ruff
150+
.ruff_cache

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GitHub のリポジトリページの「Use this template」を押下して使
88

99
- [devcontainer](https://code.visualstudio.com/docs/remote/containers)
1010
- lint
11-
- [flake8](https://flake8.pycqa.org/en/latest/)
11+
- [ruff](https://beta.ruff.rs/docs/)
1212
- [black](https://black.readthedocs.io/en/stable/)
1313
- [Pylance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance), [pyright](https://github.com/microsoft/pyright)
1414
- [hadolint](https://github.com/hadolint/hadolint)

poetry.lock

Lines changed: 439 additions & 545 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ python = "^3.7"
1010

1111
[tool.poetry.dev-dependencies]
1212
# lint
13-
flake8 = "5.0.4"
1413
black = "23.1.0"
15-
flake8-docstrings = "1.7.0"
16-
flake8-quotes = "3.3.2"
17-
flake8-bugbear = "23.3.12"
14+
ruff = "^0.0.254"
1815

1916
# test
2017
pytest = "7.2.2"
@@ -29,3 +26,29 @@ addopts = "--verbose --cov --showlocals --durations=5"
2926

3027
[tool.coverage.run]
3128
omit = ["*/tests/*", "*/site-packages/*"]
29+
30+
[tool.ruff]
31+
line-length = 100
32+
select = ["E", "F", "W", "C90", "I", "D", "UP", "B", "Q"]
33+
# Rules to ignore:
34+
# D200 One-line docstring should fit on one line with quotes
35+
# D203 1 blank line required before class docstring
36+
# D212 Multi-line docstring summary should start at the first line
37+
# D400 First line should end with a period
38+
# D401 First line should be in imperative mood
39+
# D403 First word of the first line should be properly capitalized
40+
# D413 Missing blank line after last section
41+
# D415 First line should end with a period, question mark, or exclamation point
42+
ignore = ["D200", "D203", "D212", "D400", "D401", "D403", "D413", "D415"]
43+
exclude = ["__init__.py", "work", ".venv", ".git"]
44+
45+
[tool.ruff.per-file-ignores]
46+
"tests/*" = ["D"]
47+
48+
[tool.ruff.mccabe]
49+
max-complexity = 10
50+
51+
[tool.ruff.flake8-quotes]
52+
inline-quotes = "double"
53+
multiline-quotes = "double"
54+
docstring-quotes = "double"

0 commit comments

Comments
 (0)