Skip to content

Commit

Permalink
Replace deprecated pydocstyle with Ruff and update to Black 2024 style (
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Feb 8, 2024
2 parents c8a8d33 + 7cfa397 commit b1e5d43
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 20 deletions.
17 changes: 5 additions & 12 deletions .pre-commit-config.yaml
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.2.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: [--exit-non-zero-on-fix]

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

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

- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
args: ["--convention", "google"]
files: "src/"

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
Expand All @@ -38,13 +31,13 @@ repos:
args: [--strict, --pretty, --show-error-codes]

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

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

Expand Down
21 changes: 14 additions & 7 deletions pyproject.toml
Expand Up @@ -63,19 +63,23 @@ artifacts = [
local_scheme = "no-local-version"

[tool.ruff]
line-length = 88
fix = true

[tool.ruff.lint]
select = [
"C4", # flake8-comprehensions
"D", # pydocstyle
"E", # pycodestyle errors
"EM", # flake8-errmsg
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"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 ':'
Expand All @@ -84,9 +88,15 @@ extend-ignore = [
"E241", # Multiple spaces after ','
]

[tool.ruff.isort]
required-imports = ["from __future__ import annotations"]
[tool.ruff.lint.isort]
known-first-party = ["humanize"]
required-imports = ["from __future__ import annotations"]

[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["D"]

[tool.pytest.ini_options]
addopts = "--color=yes"
Expand All @@ -95,6 +105,3 @@ filterwarnings = [
# https://github.com/dateutil/dateutil/issues/1314
"ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:dateutil.tz.tz",
]

[tool.pydocstyle]
convention = "google"
1 change: 1 addition & 0 deletions src/humanize/i18n.py
@@ -1,4 +1,5 @@
"""Activate, get and deactivate translations."""

from __future__ import annotations

import gettext as gettext_module
Expand Down
1 change: 1 addition & 0 deletions src/humanize/number.py
@@ -1,4 +1,5 @@
"""Humanizing functions for numbers."""

from __future__ import annotations

import math
Expand Down
3 changes: 2 additions & 1 deletion src/humanize/time.py
Expand Up @@ -2,6 +2,7 @@
These are largely borrowed from Django's `contrib.humanize`.
"""

from __future__ import annotations

import collections.abc
Expand Down Expand Up @@ -109,7 +110,7 @@ def naturaldelta(
Raises:
OverflowError: If `value` is too large to convert to datetime.timedelta.
Examples
Examples:
Compare two timestamps in a custom local timezone::
import datetime as dt
Expand Down
1 change: 1 addition & 0 deletions tests/test_i18n.py
@@ -1,4 +1,5 @@
"""Internationalisation tests."""

from __future__ import annotations

import datetime as dt
Expand Down
1 change: 1 addition & 0 deletions tests/test_number.py
@@ -1,4 +1,5 @@
"""Number tests."""

from __future__ import annotations

import math
Expand Down
1 change: 1 addition & 0 deletions tests/test_time.py
@@ -1,4 +1,5 @@
"""Tests for time humanizing."""

from __future__ import annotations

import datetime as dt
Expand Down

0 comments on commit b1e5d43

Please sign in to comment.