From fb61d5aae902e4526cd733a90d7a96ecded11b0e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:05:03 +0200 Subject: [PATCH] Update pre-commit (#226) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- src/humanize/__init__.py | 2 +- src/humanize/filesize.py | 4 ++-- src/humanize/number.py | 2 +- src/humanize/time.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d089b05..5c7906b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.0 + rev: v0.8.6 hooks: - id: ruff args: [--exit-non-zero-on-fix] @@ -32,12 +32,12 @@ repos: - id: check-renovate - repo: https://github.com/rhysd/actionlint - rev: v1.7.4 + rev: v1.7.6 hooks: - id: actionlint - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v0.9.1 + rev: v1.0.0 hooks: - id: zizmor diff --git a/src/humanize/__init__.py b/src/humanize/__init__.py index 224c483..6fb9959 100644 --- a/src/humanize/__init__.py +++ b/src/humanize/__init__.py @@ -36,10 +36,10 @@ "intcomma", "intword", "metric", + "natural_list", "naturaldate", "naturalday", "naturaldelta", - "natural_list", "naturalsize", "naturaltime", "ordinal", diff --git a/src/humanize/filesize.py b/src/humanize/filesize.py index 560754c..bdadd55 100644 --- a/src/humanize/filesize.py +++ b/src/humanize/filesize.py @@ -91,10 +91,10 @@ def naturalsize( abs_bytes = abs(bytes_) if abs_bytes == 1 and not gnu: - return "%d Byte" % bytes_ + return f"{bytes_} Byte" if abs_bytes < base: - return ("%dB" if gnu else "%d Bytes") % bytes_ + return f"{bytes_}B" if gnu else f"{bytes_} Bytes" for i, s in enumerate(suffix, 2): unit = base**i diff --git a/src/humanize/number.py b/src/humanize/number.py index 3f42f64..084d6a6 100644 --- a/src/humanize/number.py +++ b/src/humanize/number.py @@ -564,7 +564,7 @@ def metric(value: float, unit: str = "", precision: int = 3) -> str: ordinal_ = "mμnpfazyrq"[(-exponent - 1) // 3] else: ordinal_ = "" - value_ = format(value, ".%if" % max(0, precision - (exponent % 3) - 1)) + value_ = format(value, f".{int(max(0, precision - exponent % 3 - 1))}f") if not (unit or ordinal_) or unit in ("°", "′", "″"): space = "" else: diff --git a/src/humanize/time.py b/src/humanize/time.py index 1f53950..b40d76e 100644 --- a/src/humanize/time.py +++ b/src/humanize/time.py @@ -18,10 +18,10 @@ from .number import intcomma __all__ = [ + "naturaldate", + "naturalday", "naturaldelta", "naturaltime", - "naturalday", - "naturaldate", "precisedelta", ]