Skip to content

Commit

Permalink
✨Maintenance: add Ruff (#4432)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg authored Jun 29, 2023
1 parent 52fb373 commit bab7026
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
48 changes: 48 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

select = [
"A", # [https://pypi.org/project/flake8-builtins/]
"ARG", # [https://pypi.org/project/flake8-unused-arguments/]
"ASYNC", # [https://pypi.org/project/flake8-async/]
"B", # [https://pypi.org/project/flake8-bugbear/]
"C4", # [https://pypi.org/project/flake8-comprehensions/]
"C90", # [https://pypi.org/project/mccabe/] (complexity)
"DTZ", # [https://pypi.org/project/flake8-datetimez/]
"E", # [https://pypi.org/project/pycodestyle/] errors
"EM", # [https://pypi.org/project/flake8-errmsg/]
"ERA", # [https://pypi.org/project/eradicate/]
"F", # [https://pypi.org/project/pyflakes/]
"FBT", # [https://pypi.org/project/flake8-boolean-trap/]
"FIX", # [https://github.com/tommilligan/flake8-fixme]
"G", # [https://pypi.org/project/flake8-logging-format/0.9.0/]
"I", # [https://pypi.org/project/isort/]
"ICN", # [https://github.com/joaopalmeiro/flake8-import-conventions]
"ISC", # [https://pypi.org/project/flake8-implicit-str-concat/]
"N", # [https://pypi.org/project/pep8-naming/]
"NPY", # NumPy-speficic rules
"PERF", # [https://pypi.org/project/perflint/]
"PIE", # [https://pypi.org/project/flake8-pie/]
"PL", # [https://pypi.org/project/pylint/]
"PT", # [https://pypi.org/project/flake8-pytest-style/]
"PTH", # [https://pypi.org/project/flake8-use-pathlib/]
"PYI", # [https://pypi.org/project/flake8-pyi/]
"RET", # [https://pypi.org/project/flake8-return/]
"RSE", # [https://pypi.org/project/flake8-raise/]
"RUF", # RUFF-specific rules
"S", # [https://pypi.org/project/flake8-bandit/] (Automated security testing)
"SIM", # [https://pypi.org/project/flake8-simplify/]
"SLF", # [https://pypi.org/project/flake8-self/]
"SLOT", # [https://pypi.org/project/flake8-slots/]
"T10", # https://pypi.org/project/flake8-debugger/
"T20", # [https://pypi.org/project/flake8-print/]
"TID", # [https://pypi.org/project/flake8-tidy-imports/]
"TRY", # [https://pypi.org/project/tryceratops/1.1.0/] (exception anti-patterns)
"UP", # [https://pypi.org/project/pyupgrade/]
"W", # [https://pypi.org/project/pycodestyle/] warnings
"YTT", # [https://pypi.org/project/flake8-2020/]
]
ignore = [
"E501", # line too long, handled by black
"S101", # use of `assert` detected hanbled by pylance, does not support noseq
"TID252", # [*] Relative imports from parent modules are banned
]
extend-exclude = ["**/tests", "**/generated_models", "**/director/"]
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"recommendations": [
"charliermarsh.ruff",
"eamodio.gitlens",
"exiasr.hadolint",
"ms-python.python",
"njpwerner.autodocstring",
"samuelcolvin.jinjahtml",
"timonwong.shellcheck"
"timonwong.shellcheck",
]
}
8 changes: 7 additions & 1 deletion .vscode/settings.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,11 @@
"--settings-path=${workspaceFolder}/.isort.cfg"
],
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "basic"
"python.analysis.typeCheckingMode": "basic",
"ruff.args": [
"--config=${workspaceFolder}/.ruff.toml"
],
"ruff.path": [
"${workspaceFolder}/.venv/bin/ruff"
]
}
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,13 @@ pylint: ## python linting
@pylint --rcfile=.pylintrc -v $(CURDIR)/tests --ignore=examples
# See exit codes and command line https://pylint.readthedocs.io/en/latest/user_guide/run.html#exit-codes

ruff: ## python ruffing
# ruff version info
@ruff --version
# Running ruff in packages and services (except director)
@ruff check \
$(CURDIR)/services \
$(CURDIR)/packages

.PHONY: new-service
new-service: .venv ## Bakes a new project from cookiecutter-simcore-pyservice and drops it under services/ [UNDER DEV]
Expand Down
3 changes: 3 additions & 0 deletions requirements/devenv.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ bump2version

# SEE `make pylint`
pylint

# ultra-fast linter
ruff

0 comments on commit bab7026

Please sign in to comment.