Moved from flake8 / black / isort to ruff

This commit is contained in:
Amritanshu Agrawal 2023-12-25 10:50:51 +05:30
parent bf363c220c
commit 8b65e85641
3 changed files with 52 additions and 62 deletions

View File

@ -1,4 +0,0 @@
[flake8]
ignore = E203, W503, E501
max-line-length = 120
exclude = .git,__pycache__,__init__.py,.mypy_cache,.pytest_cache

View File

@ -1,23 +1,15 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.9
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: ['--config=brewman/.flake8']
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
exclude: ^.*/?setup\.py$
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
@ -28,10 +20,3 @@ repos:
- id: check-added-large-files
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.280
hooks:
- id: ruff
# To autofix, enable this
# args: [ --fix, --exit-non-zero-on-fix ]

View File

@ -25,13 +25,10 @@ openpyxl = "^3.1.2"
gunicorn = "^21.2.0"
[tool.poetry.group.dev.dependencies]
flake8 = "^6.0.0"
black = "^23.7.0"
isort = {extras = ["toml"], version = "^5.12.0"}
pre-commit = "^3.3.3"
mypy = "^1.4.1"
types-python-jose = "^3.3.4.8"
ruff = "^0.0.280"
ruff = "^0.1.9"
bandit = "^1.7.5"
safety = "^2.3.5"
@ -43,6 +40,49 @@ build-backend = "poetry.core.masonry.api"
line-length = 120
# Assume Python 3.11.
target-version = "py311"
exclude = [
".eggs",
".git",
".hg",
".mypy_cache",
".tox",
".venv",
"_build",
"buck-out",
"build",
]
[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = ["E203", "E501"]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
# Avoid trying to fix flake8-bugbear (`B`) violations.
unfixable = ["B", "F401"]
[tool.ruff.isort]
# include-trailing-comma = true
lines-after-imports = 2
lines-between-types = 1
# use-parentheses = true
[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
[tool.mypy]
# --strict
@ -61,34 +101,3 @@ warn_unused_configs = true
strict_equality = true
plugins = ["sqlalchemy.ext.mypy.plugin"]
# --strict end
[tool.isort]
profile = "black"
atomic = true
include_trailing_comma = true
lines_after_imports = 2
lines_between_types = 1
use_parentheses = true
src_paths = ["poetry", "tests"]
skip_glob = ["*/setup.py"]
filter_files = true
known_first_party = "poetry"
[tool.black]
line-length = 120
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| tests/.*/setup.py
)/
'''