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", ]