Skip to content

Commit b1e5d43

Browse files
authored
Replace deprecated pydocstyle with Ruff and update to Black 2024 style (#170)
2 parents c8a8d33 + 7cfa397 commit b1e5d43

8 files changed

Lines changed: 26 additions & 20 deletions

File tree

.pre-commit-config.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.1.9
3+
rev: v0.2.1
44
hooks:
55
- id: ruff
6-
args: [--fix, --exit-non-zero-on-fix]
6+
args: [--exit-non-zero-on-fix]
77

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

@@ -23,13 +23,6 @@ repos:
2323
- id: trailing-whitespace
2424
exclude: \.github/ISSUE_TEMPLATE\.md|\.github/PULL_REQUEST_TEMPLATE\.md
2525

26-
- repo: https://github.com/PyCQA/pydocstyle
27-
rev: 6.3.0
28-
hooks:
29-
- id: pydocstyle
30-
args: ["--convention", "google"]
31-
files: "src/"
32-
3326
- repo: https://github.com/pre-commit/mirrors-mypy
3427
rev: v1.8.0
3528
hooks:
@@ -38,13 +31,13 @@ repos:
3831
args: [--strict, --pretty, --show-error-codes]
3932

4033
- repo: https://github.com/tox-dev/pyproject-fmt
41-
rev: 1.5.3
34+
rev: 1.7.0
4235
hooks:
4336
- id: pyproject-fmt
4437
additional_dependencies: [tox]
4538

4639
- repo: https://github.com/abravalheri/validate-pyproject
47-
rev: v0.15
40+
rev: v0.16
4841
hooks:
4942
- id: validate-pyproject
5043

pyproject.toml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,23 @@ artifacts = [
6363
local_scheme = "no-local-version"
6464

6565
[tool.ruff]
66-
line-length = 88
66+
fix = true
67+
68+
[tool.ruff.lint]
6769
select = [
70+
"C4", # flake8-comprehensions
71+
"D", # pydocstyle
6872
"E", # pycodestyle errors
6973
"EM", # flake8-errmsg
7074
"F", # pyflakes errors
7175
"I", # isort
7276
"ISC", # flake8-implicit-str-concat
77+
"LOG", # flake8-logging
7378
"PGH", # pygrep-hooks
7479
"RUF100", # unused noqa (yesqa)
7580
"UP", # pyupgrade
7681
"W", # pycodestyle warnings
7782
"YTT", # flake8-2020
78-
# "LOG", # TODO: enable flake8-logging when it's not in preview anymore
7983
]
8084
extend-ignore = [
8185
"E203", # Whitespace before ':'
@@ -84,9 +88,15 @@ extend-ignore = [
8488
"E241", # Multiple spaces after ','
8589
]
8690

87-
[tool.ruff.isort]
88-
required-imports = ["from __future__ import annotations"]
91+
[tool.ruff.lint.isort]
8992
known-first-party = ["humanize"]
93+
required-imports = ["from __future__ import annotations"]
94+
95+
[tool.ruff.pydocstyle]
96+
convention = "google"
97+
98+
[tool.ruff.lint.per-file-ignores]
99+
"tests/*" = ["D"]
90100

91101
[tool.pytest.ini_options]
92102
addopts = "--color=yes"
@@ -95,6 +105,3 @@ filterwarnings = [
95105
# https://github.com/dateutil/dateutil/issues/1314
96106
"ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:dateutil.tz.tz",
97107
]
98-
99-
[tool.pydocstyle]
100-
convention = "google"

src/humanize/i18n.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Activate, get and deactivate translations."""
2+
23
from __future__ import annotations
34

45
import gettext as gettext_module

src/humanize/number.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Humanizing functions for numbers."""
2+
23
from __future__ import annotations
34

45
import math

src/humanize/time.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
These are largely borrowed from Django's `contrib.humanize`.
44
"""
5+
56
from __future__ import annotations
67

78
import collections.abc
@@ -109,7 +110,7 @@ def naturaldelta(
109110
Raises:
110111
OverflowError: If `value` is too large to convert to datetime.timedelta.
111112
112-
Examples
113+
Examples:
113114
Compare two timestamps in a custom local timezone::
114115
115116
import datetime as dt

tests/test_i18n.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Internationalisation tests."""
2+
23
from __future__ import annotations
34

45
import datetime as dt

tests/test_number.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Number tests."""
2+
23
from __future__ import annotations
34

45
import math

tests/test_time.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for time humanizing."""
2+
23
from __future__ import annotations
34

45
import datetime as dt

0 commit comments

Comments
 (0)