Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated pydocstyle with Ruff and update to Black 2024 style #170

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Number tests."""

from __future__ import annotations

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

from __future__ import annotations

import datetime as dt
Expand Down
Loading