Skip to content

Commit

Permalink
Add ruff pre-commit hook, remove flake8 configuration and port settin…
Browse files Browse the repository at this point in the history
…gs to ruff's
  • Loading branch information
yschneider-sinneria authored and Archaeopteryx committed Jan 24, 2024
1 parent e91eb1c commit 10b8ba2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
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
rev: v0.9.0.5
hooks:
Expand All @@ -17,6 +12,11 @@ repos:
hooks:
- id: markdownlint
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
rev: 23.3.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
![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)
[![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

Expand Down
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,40 @@ exclude = '''
| 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"]
9 changes: 0 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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]
testpaths = tests
norecursedirs = __pycache__ ui
Expand Down
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,3 @@ whitelist_externals=
docker-compose
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"

[flake8]
per-file-ignores = treeherder/model/models.py:E402

0 comments on commit 10b8ba2

Please sign in to comment.