diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2205219..8f03842 100644 --- a/.pre-commit-config.yaml +++ b/.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 @@ -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: @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 68d3119..fc81573 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ':' @@ -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" @@ -95,6 +105,3 @@ filterwarnings = [ # https://github.com/dateutil/dateutil/issues/1314 "ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:dateutil.tz.tz", ] - -[tool.pydocstyle] -convention = "google" diff --git a/src/humanize/i18n.py b/src/humanize/i18n.py index e391b9f..55f809f 100644 --- a/src/humanize/i18n.py +++ b/src/humanize/i18n.py @@ -1,4 +1,5 @@ """Activate, get and deactivate translations.""" + from __future__ import annotations import gettext as gettext_module diff --git a/src/humanize/number.py b/src/humanize/number.py index 034144a..19b397e 100644 --- a/src/humanize/number.py +++ b/src/humanize/number.py @@ -1,4 +1,5 @@ """Humanizing functions for numbers.""" + from __future__ import annotations import math diff --git a/src/humanize/time.py b/src/humanize/time.py index 52828c1..84759d5 100644 --- a/src/humanize/time.py +++ b/src/humanize/time.py @@ -2,6 +2,7 @@ These are largely borrowed from Django's `contrib.humanize`. """ + from __future__ import annotations import collections.abc @@ -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 diff --git a/tests/test_i18n.py b/tests/test_i18n.py index d4f1e49..004b3f5 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -1,4 +1,5 @@ """Internationalisation tests.""" + from __future__ import annotations import datetime as dt diff --git a/tests/test_number.py b/tests/test_number.py index 00d9a9c..2eaa6eb 100644 --- a/tests/test_number.py +++ b/tests/test_number.py @@ -1,4 +1,5 @@ """Number tests.""" + from __future__ import annotations import math diff --git a/tests/test_time.py b/tests/test_time.py index 0396be2..2690fff 100644 --- a/tests/test_time.py +++ b/tests/test_time.py @@ -1,4 +1,5 @@ """Tests for time humanizing.""" + from __future__ import annotations import datetime as dt