Switch to ruff to handle linting and formatting

Ruff handles black, flake8 and isort in one package, and is way faster.
The isort rules had not been enforced, so this commit includes a lot
of import resorting changes.

I switched to flake8-bugbear and the standard black-compatible line
length of 80 + 10% (so max 88 characters), so some line reflowing is
included too.

Finally, because bugbear rightly points out that `setattr()` is less
performant, I've switched the `__signature__` assigment back to using
a direct assignment with type ignore comment.
This commit is contained in:
Martijn Pieters
2023-05-16 12:09:50 +01:00
parent 707b4aec95
commit 1d9e126037
12 changed files with 89 additions and 165 deletions

View File

@@ -29,13 +29,11 @@ aiohttp = { version = ">=3.8.3", markers = "python_version >= \"3.11\"" }
optional = true
[tool.poetry.group.linting.dependencies]
flake8 = { version = "*", markers = "python_version >= \"3.10\"" }
isort = { version = "*", markers = "python_version >= \"3.10\"" }
black = { version = "*", markers = "python_version >= \"3.10\"" }
mypy = { version = "^1.2.0", markers = "python_version >= \"3.10\"" }
pyright = { version = "^1.1.306", markers="python_version >= \"3.10\"" }
types-aiobotocore = { extras = ["dynamodb"], version = "^2.5.0.post2", markers = "python_version >= \"3.10\"" }
types-redis = { version = "^4.5.4.2", markers = "python_version >= \"3.10\"" }
ruff = { version = "^0.0.267", markers = "python_version >= \"3.10\"" }
[tool.poetry.group.dev.dependencies]
pytest = "*"
@@ -50,10 +48,6 @@ memcache = ["aiomcache"]
dynamodb = ["aiobotocore"]
all = ["redis", "aiomcache", "aiobotocore"]
[tool.black]
line-length = 100
target-version = ['py36', 'py37', 'py38', 'py39']
[tool.mypy]
files = ["fastapi_cache", "examples", "tests"]
python_version = "3.7"
@@ -82,6 +76,21 @@ include = ["fastapi_cache", "tests", "examples"]
strict = ["fastapi_cache", "tests"]
pythonVersion = "3.7"
[tool.pytest]
addopts = "-p no:warnings"
[tool.ruff]
ignore = ["E501"]
line-length = 80
select = [
"B", # flake8-bugbear
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"W", # pycodestyle warnings
]
target-version = "py37"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"