Skip to content

Commit

Permalink
Switch to ruff linter
Browse files Browse the repository at this point in the history
  • Loading branch information
boidolr committed May 28, 2023
1 parent 54f7fa2 commit 17baf1a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 34 deletions.
2 changes: 0 additions & 2 deletions .bandit.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.pytest_cache
*.pyc
.mypy_cache/
.ruff_cache/
.eggs
.venv
.tox
Expand Down
26 changes: 3 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,16 @@ repos:
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
files: \.(py|yaml)$
args: [--fix=lf]
- id: pretty-format-json
args: [--autofix, --indent=4, --no-sort-keys]
- id: trailing-whitespace

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.270
hooks:
- id: flake8

- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py39-plus]

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
args: [--py39-plus]
- id: ruff

- repo: https://github.com/psf/black
rev: 23.3.0
Expand All @@ -68,9 +54,3 @@ repos:
rev: v1.3.0
hooks:
- id: mypy

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: [--configfile, .bandit.yaml]
41 changes: 39 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ dependencies = [
[project.optional-dependencies]
dev = [
"black",
"flake8",
"pre-commit",
"ruff",
"tox",
"tox-pyenv",
]
tests = [
"pytest",
"pytest-clarity",
"pytest-ruff",
"pytest-mypy",
]

Expand All @@ -57,6 +58,42 @@ packages = ["pre_commit_images"]
target-version = ["py39"]
line-length = 120

[tool.ruff]
target-version = "py39"
line-length = 120
fix = true
select = [
# Pyflakes
"F",
# Pycodestyle
"E",
"W",
# pyupgrade
"UP",
# flake8-bandit
"S",
# flake8-comprehensions
"C4",
# flake8-annotations
"ANN",
# flynt
"FLY",
# isort
"I001",
# Unneeded noqa
"RUF100"
]

[tool.ruff.per-file-ignores]
"tests/*.py" = ["S101"]

[tool.ruff.flake8-annotations]
ignore-fully-untyped = true

[tool.ruff.isort]
force-single-line = true
order-by-type = false

[tool.mypy]
check_untyped_defs = true
disallow_any_generics = true
Expand All @@ -66,7 +103,7 @@ no_implicit_optional = true
ignore_missing_imports = true

[tool.pytest.ini_options]
addopts = "--mypy"
addopts = "--mypy --ruff"
filterwarnings = [
"error",
]
Expand Down
8 changes: 1 addition & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38,py39,py310,py311,pre-commit
envlist = py39,py310,py311,pre-commit
isolated_build = True

[testenv]
Expand All @@ -14,11 +14,5 @@ commands = pre-commit run --all-files

[testenv:static]
extras = tests
deps = bandit
commands =
pytest --ignore tests
bandit --recursive pre_commit_images

[flake8]
max-line-length = 120
extend-ignore = E203

0 comments on commit 17baf1a

Please sign in to comment.