feat(dev): use ruff for python linting (#355)

This commit is contained in:
Patrick Decat
2023-09-01 00:29:59 +02:00
committed by GitHub
parent 8bf82ac144
commit 0a7775860c
5 changed files with 40 additions and 22 deletions

View File

@@ -23,10 +23,16 @@ repos:
- id: autoflake
args: [ '--remove-all-unused-imports', '--remove-unused-variables', '--in-place' , '--recursive']
# We would like to have a mypy pre-commit hook, but due to the fact that
# pre-commit runs in it's own isolated environment, we would need to install
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.286
hooks:
- id: ruff
# We would like to have a mypy pre-commit hook, but due to the fact that
# pre-commit runs in it's own isolated environment, we would need to install
# and keep in sync all dependencies so mypy has access to the appropriate type
# stubs. This does not seem worth it at the moment, so for now we will stick to
# stubs. This does not seem worth it at the moment, so for now we will stick to
# having mypy run via Github Actions / manually by contributors
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.1.1
@@ -38,15 +44,15 @@ repos:
# # with requirements/dev.txt + requirements/default.txt
# additional_dependencies: [
# alembic==1.10.4,
# types-beautifulsoup4==4.12.0.3,
# types-html5lib==1.1.11.13,
# types-oauthlib==3.2.0.9,
# types-psycopg2==2.9.21.10,
# types-python-dateutil==2.8.19.13,
# types-regex==2023.3.23.1,
# types-requests==2.28.11.17,
# types-retry==0.9.9.3,
# types-beautifulsoup4==4.12.0.3,
# types-html5lib==1.1.11.13,
# types-oauthlib==3.2.0.9,
# types-psycopg2==2.9.21.10,
# types-python-dateutil==2.8.19.13,
# types-regex==2023.3.23.1,
# types-requests==2.28.11.17,
# types-retry==0.9.9.3,
# types-urllib3==1.26.25.11
# ]
# # TODO: add back once errors are addressed
# # args: [--strict]
# # args: [--strict]

14
backend/pyproject.toml Normal file
View File

@@ -0,0 +1,14 @@
[tool.mypy]
plugins = "sqlalchemy.ext.mypy.plugin"
mypy_path = "$MYPY_CONFIG_FILE_DIR"
explicit_package_bases = true
disallow_untyped_defs = true
[tool.ruff]
ignore = []
line-length = 130
select = [
"E",
"F",
"W",
]

View File

@@ -3,6 +3,7 @@ mypy-extensions==1.0.0
mypy==1.1.1
pre-commit==3.2.2
reorder-python-imports==3.9.0
ruff==0.0.286
types-beautifulsoup4==4.12.0.3
types-html5lib==1.1.11.13
types-oauthlib==3.2.0.9

View File

@@ -1,8 +0,0 @@
[mypy]
plugins = sqlalchemy.ext.mypy.plugin
mypy_path = $MYPY_CONFIG_FILE_DIR
explicit_package_bases = True
disallow_untyped_defs = True
[flake8]
max-line-length = 88