Skip to content

Commit 067a70f

Browse files
committed
Replace Flake8 with Ruff
1 parent e0a6aaf commit 067a70f

File tree

5 files changed

+48
-53
lines changed

5 files changed

+48
-53
lines changed

.flake8

Lines changed: 0 additions & 2 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,24 @@
11
repos:
2-
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.14.0
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.1.6
44
hooks:
5-
- id: pyupgrade
6-
args: [--py38-plus]
5+
- id: ruff
6+
args: [--fix, --exit-non-zero-on-fix]
77

88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 23.9.1
9+
rev: 23.11.0
1010
hooks:
1111
- id: black
1212

13-
- repo: https://github.com/PyCQA/isort
14-
rev: 5.12.0
15-
hooks:
16-
- id: isort
17-
args: [--add-import=from __future__ import annotations]
18-
19-
- repo: https://github.com/PyCQA/autoflake
20-
rev: v2.2.1
21-
hooks:
22-
- id: autoflake
23-
name: autoflake
24-
args:
25-
[
26-
"--in-place",
27-
"--remove-unused-variables",
28-
"--remove-all-unused-imports",
29-
]
30-
language: python
31-
files: \.py$
32-
33-
- repo: https://github.com/PyCQA/flake8
34-
rev: 6.1.0
35-
hooks:
36-
- id: flake8
37-
additional_dependencies:
38-
[flake8-2020, flake8-errmsg, flake8-implicit-str-concat]
39-
40-
- repo: https://github.com/pre-commit/pygrep-hooks
41-
rev: v1.10.0
42-
hooks:
43-
- id: python-check-blanket-noqa
44-
- id: python-no-log-warn
45-
4613
- repo: https://github.com/pre-commit/pre-commit-hooks
47-
rev: v4.4.0
14+
rev: v4.5.0
4815
hooks:
4916
- id: check-case-conflict
5017
- id: check-merge-conflict
5118
- id: check-json
5219
- id: check-toml
5320
- id: check-yaml
21+
- id: debug-statements
5422
- id: end-of-file-fixer
5523
- id: trailing-whitespace
5624
exclude: \.github/ISSUE_TEMPLATE\.md|\.github/PULL_REQUEST_TEMPLATE\.md
@@ -63,20 +31,20 @@ repos:
6331
files: "src/"
6432

6533
- repo: https://github.com/pre-commit/mirrors-mypy
66-
rev: v1.5.1
34+
rev: v1.7.0
6735
hooks:
6836
- id: mypy
6937
additional_dependencies: [pytest, types-freezegun, types-setuptools]
7038
args: [--strict, --pretty, --show-error-codes]
7139

7240
- repo: https://github.com/tox-dev/pyproject-fmt
73-
rev: 1.2.0
41+
rev: 1.5.1
7442
hooks:
7543
- id: pyproject-fmt
7644
additional_dependencies: [tox]
7745

7846
- repo: https://github.com/abravalheri/validate-pyproject
79-
rev: v0.14
47+
rev: v0.15
8048
hooks:
8149
- id: validate-pyproject
8250

@@ -85,5 +53,10 @@ repos:
8553
hooks:
8654
- id: tox-ini-fmt
8755

56+
- repo: meta
57+
hooks:
58+
- id: check-hooks-apply
59+
- id: check-useless-excludes
60+
8861
ci:
8962
autoupdate_schedule: quarterly

pyproject.toml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,33 @@ artifacts = [
6262
[tool.hatch.version.raw-options]
6363
local_scheme = "no-local-version"
6464

65-
[tool.isort]
66-
profile = "black"
65+
[tool.ruff]
66+
line-length = 88
67+
select = [
68+
"E", # pycodestyle errors
69+
"EM", # flake8-errmsg
70+
"F", # pyflakes errors
71+
"I", # isort
72+
"ISC", # flake8-implicit-str-concat
73+
"PGH", # pygrep-hooks
74+
"RUF100", # unused noqa (yesqa)
75+
"UP", # pyupgrade
76+
"W", # pycodestyle warnings
77+
"YTT", # flake8-2020
78+
# "LOG", # TODO: enable flake8-logging when it's not in preview anymore
79+
]
80+
extend-ignore = [
81+
"E203", # Whitespace before ':'
82+
"E221", # Multiple spaces before operator
83+
"E226", # Missing whitespace around arithmetic operator
84+
"E241", # Multiple spaces after ','
85+
]
86+
87+
[tool.ruff.isort]
88+
required-imports = ["from __future__ import annotations"]
89+
90+
[tool.ruff.lint.isort]
91+
known-first-party = ["humanize"]
6792

6893
[tool.pytest.ini_options]
6994
addopts = "--color=yes"

src/humanize/number.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
from typing import TYPE_CHECKING
99

1010
from .i18n import _gettext as _
11-
from .i18n import _ngettext
11+
from .i18n import _ngettext, decimal_separator, thousands_separator
1212
from .i18n import _ngettext_noop as NS_
1313
from .i18n import _pgettext as P_
14-
from .i18n import decimal_separator, thousands_separator
1514

1615
if TYPE_CHECKING:
1716
if sys.version_info >= (3, 10):

tests/test_number.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ def test_fractional(test_input: float | str, expected: str) -> None:
190190
([5781651000], "5.78 x 10⁹"),
191191
(["1000"], "1.00 x 10³"),
192192
(["99"], "9.90 x 10¹"),
193-
([float(0.3)], "3.00 x 10⁻¹"),
193+
([0.3], "3.00 x 10⁻¹"),
194194
(["foo"], "foo"),
195195
([None], "None"),
196196
([1000, 1], "1.0 x 10³"),
197-
([float(0.3), 1], "3.0 x 10⁻¹"),
197+
([0.3, 1], "3.0 x 10⁻¹"),
198198
([1000, 0], "1 x 10³"),
199-
([float(0.3), 0], "3 x 10⁻¹"),
200-
([float(1e20)], "1.00 x 10²⁰"),
201-
([float(2e-20)], "2.00 x 10⁻²⁰"),
199+
([0.3, 0], "3 x 10⁻¹"),
200+
([1e20], "1.00 x 10²⁰"),
201+
([2e-20], "2.00 x 10⁻²⁰"),
202202
([float(-3e20)], "-3.00 x 10²⁰"),
203203
([float(-4e-20)], "-4.00 x 10⁻²⁰"),
204204
([math.nan], "NaN"),

0 commit comments

Comments
 (0)