Add ruff pre-commit hook, remove flake8 configuration and port settings to ruff's

This commit is contained in:
Yoann Schneider 2024-01-23 16:42:10 +01:00 коммит произвёл Sebastian Hengst
Родитель e91eb1cd66
Коммит 10b8ba2b6d
5 изменённых файлов: 43 добавлений и 17 удалений

Просмотреть файл

@ -1,9 +1,4 @@
repos: repos:
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--append-config=tox.ini]
- repo: https://github.com/shellcheck-py/shellcheck-py - repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.5 rev: v0.9.0.5
hooks: hooks:
@ -17,6 +12,11 @@ repos:
hooks: hooks:
- id: markdownlint - id: markdownlint
args: [--fix] args: [--fix]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 23.3.0 rev: 23.3.0
hooks: hooks:

Просмотреть файл

@ -5,6 +5,7 @@
![Node dependencies Status](https://shields.io/librariesio/github/mozilla/treeherder) ![Node dependencies Status](https://shields.io/librariesio/github/mozilla/treeherder)
[![Documentation Status](https://readthedocs.org/projects/treeherder/badge/?version=latest)](https://treeherder.readthedocs.io/?badge=latest) [![Documentation Status](https://readthedocs.org/projects/treeherder/badge/?version=latest)](https://treeherder.readthedocs.io/?badge=latest)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
## Description ## Description

Просмотреть файл

@ -33,3 +33,40 @@ exclude = '''
| treeherder/changelog/migrations | treeherder/changelog/migrations
)/ )/
''' '''
[tool.ruff]
# Same as Black.
line-length = 100
# Assume Python 3.9
target-version = "py39"
# In addition to the standard set of exclusions, omit all tests, plus a specific file.
extend-exclude = ["*/.*/",".*/","__pycache__","node_modules"]
select = [
# pycodestyle
"E",
"W",
# pyflakes
"F",
]
ignore = [
# E203 whitespace before ':'
"E203",
# E231: missing whitespace after ','
"E231",
# E501: line too long
"E501"
]
[tool.ruff.per-file-ignores]
# Ignore `module-import-not-at-top-of-file` rule of `pycodestyle`
"treeherder/model/models.py" = ["E402"]
# Ignore `not-is-test` rule of `pycodestyle`
"treeherder/perf/sheriffing_criteria/criteria_tracking.py" = ["E714"]
# Ignore `not-in-test` rule of `pycodestyle`
"treeherder/push_health/utils.py" = ["E713"]

Просмотреть файл

@ -1,12 +1,3 @@
[flake8]
exclude = */.*/,.*/,__pycache__,node_modules
# E129: visually indented line with same indent as next logical line
# E203 whitespace before ':'
# E231: missing whitespace after ','
# E501: line too long
extend_ignore = E129,E203,E231,E501
max-line-length = 100
[tool:pytest] [tool:pytest]
testpaths = tests testpaths = tests
norecursedirs = __pycache__ ui norecursedirs = __pycache__ ui

Просмотреть файл

@ -54,6 +54,3 @@ whitelist_externals=
docker-compose docker-compose
commands = commands =
docker-compose run -e TREEHERDER_DEBUG=False -e DATABASE_URL=psql://postgres:mozilla1234@postgres:5432/treeherder backend bash -c "pytest --cov --cov-report=xml tests/ --runslow -p no:unraisableexception" docker-compose run -e TREEHERDER_DEBUG=False -e DATABASE_URL=psql://postgres:mozilla1234@postgres:5432/treeherder backend bash -c "pytest --cov --cov-report=xml tests/ --runslow -p no:unraisableexception"
[flake8]
per-file-ignores = treeherder/model/models.py:E402