Skip to content

Commit

Permalink
Replace Flake8 with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Dec 9, 2023
1 parent 003ed05 commit 9e6cc10
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 33 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

40 changes: 14 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
hooks:
- id: pyupgrade
args: [--py38-plus]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
rev: 23.11.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
[flake8-2020, flake8-errmsg, flake8-implicit-str-concat, flake8-logging]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
Expand All @@ -38,17 +21,17 @@ repos:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: ^em/emojis.json$
exclude: ^src/em_keyboard/emojis.json$
- id: trailing-whitespace

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.2.0
rev: 1.5.3
hooks:
- id: pyproject-fmt
additional_dependencies: [tox]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.14
rev: v0.15
hooks:
- id: validate-pyproject

Expand All @@ -57,5 +40,10 @@ repos:
hooks:
- id: tox-ini-fmt

- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes

ci:
autoupdate_schedule: quarterly
28 changes: 24 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,28 @@ version.source = "vcs"
[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

[tool.isort]
profile = "black"
[tool.ruff]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle errors
"EM", # flake8-errmsg
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
# "LOG", # TODO: enable flake8-logging when it's not in preview anymore
]
extend-ignore = [
"E203", # Whitespace before ':'
"E221", # Multiple spaces before operator
"E226", # Missing whitespace around arithmetic operator
"E241", # Multiple spaces after ','
]

[tool.pytest.ini_options]
addopts = "--color=yes"
[tool.ruff.isort]
known-first-party = ["em_keyboard"]
required-imports = ["from __future__ import annotations"]
2 changes: 2 additions & 0 deletions scripts/run_command.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import shlex
import subprocess

Expand Down
2 changes: 1 addition & 1 deletion src/em_keyboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
automatically added to your clipboard.
- ✨ 🍰 ✨ (sparkles shortcake sparkles)
"""

from __future__ import annotations

import argparse
import importlib.metadata
Expand Down
2 changes: 2 additions & 0 deletions tests/test_em.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import random
from unittest.mock import call, patch
Expand Down

0 comments on commit 9e6cc10

Please sign in to comment.