From 5f38fab0fce62fbefa7f7bc04f879c90d36aad87 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 00:46:11 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.0 → v0.8.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.0...v0.8.6) - [github.com/rhysd/actionlint: v1.7.4 → v1.7.6](https://github.com/rhysd/actionlint/compare/v1.7.4...v1.7.6) - [github.com/woodruffw/zizmor-pre-commit: v0.9.1 → v1.0.0](https://github.com/woodruffw/zizmor-pre-commit/compare/v0.9.1...v1.0.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 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 From 43abeeedf29229199e400413ae60151c33fd3784 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 00:46:21 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/humanize/__init__.py | 2 +- src/humanize/time.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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", ] From 225c8ac77871c84cb82e34c2c8fab4c06509c675 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:00:36 +0200 Subject: [PATCH 3/3] Fix UP031 Use format specifiers instead of percent format --- src/humanize/filesize.py | 4 ++-- src/humanize/number.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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: