diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2b4ba7b..1b883da5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: run: | scripts/generate-translation-binaries.sh - - uses: hynek/build-and-inspect-python-package@d44ca7d91762de7a7d5436ddae667c6da6d1c3df # v2.18.0 + - uses: hynek/build-and-inspect-python-package@2abe76da66d0a6a4a227101f9348ee855797cfa5 # v3.0.1 # Upload to Test PyPI on every commit on main. release-test-pypi: @@ -59,7 +59,7 @@ jobs: path: dist - name: Upload package to Test PyPI - uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1 + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 with: repository-url: https://test.pypi.org/legacy/ @@ -83,4 +83,4 @@ jobs: path: dist - name: Upload package to PyPI - uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1 + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 77b243c3..d8ee9721 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,78 +1,109 @@ +priorities: + fix: 0 + fix-py: 10 + fix-eol: 20 + fix-whitespace: 30 + check: 40 + repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.20 + rev: v0.16.5 hooks: - id: ruff-check args: [--exit-non-zero-on-fix] + priority: fix - repo: https://github.com/psf/black-pre-commit-mirror rev: 26.5.1 hooks: - id: black + priority: fix-py - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - id: check-added-large-files + priority: check - id: check-case-conflict + priority: check - id: check-merge-conflict + priority: check - id: check-json + priority: check - id: check-toml + priority: check - id: check-yaml + priority: check - id: debug-statements + priority: check - id: end-of-file-fixer + priority: fix-eol - id: forbid-submodules + priority: check - id: requirements-txt-fixer + priority: fix - id: trailing-whitespace exclude: \.github/ISSUE_TEMPLATE\.md|\.github/PULL_REQUEST_TEMPLATE\.md + priority: fix-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.37.4 + rev: 0.38.0 hooks: - id: check-github-workflows + priority: check - id: check-renovate + priority: check - repo: https://github.com/rhysd/actionlint rev: v1.7.12 hooks: - id: actionlint + priority: check - repo: https://github.com/zizmorcore/zizmor-pre-commit - rev: v1.26.1 + rev: v1.29.0 hooks: - id: zizmor + priority: check - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.25.1 + rev: v2.28.2 hooks: - id: pyproject-fmt + priority: fix - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.25 + rev: "0.26" hooks: - id: validate-pyproject + priority: check - repo: https://github.com/tox-dev/tox-ini-fmt - rev: 1.7.1 + rev: 1.9.0 hooks: - id: tox-ini-fmt + priority: fix - repo: https://github.com/google/yamlfmt rev: v0.21.0 hooks: - id: yamlfmt + priority: fix - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.9.4 + rev: v3.9.6 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] exclude: \.github/ISSUE_TEMPLATE\.md|\.github/PULL_REQUEST_TEMPLATE\.md + priority: fix - repo: meta hooks: - id: check-hooks-apply + priority: check - id: check-useless-excludes + priority: check ci: autoupdate_schedule: quarterly diff --git a/pyproject.toml b/pyproject.toml index 1843da19..e125c579 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,9 @@ lint.select = [ "PT", # flake8-pytest-style "PYI", # flake8-pyi "RUF022", # unsorted-dunder-all + "RUF046", # unnecessary-cast-to-int "RUF100", # unused noqa (yesqa) + "TID251", # flake8-tidy-imports: banned-api "UP", # pyupgrade "W", # pycodestyle warnings "YTT", # flake8-2020 @@ -91,6 +93,7 @@ lint.per-file-ignores."tests/*" = [ lint.flake8-import-conventions.aliases.datetime = "dt" lint.flake8-import-conventions.banned-from = [ "datetime" ] lint.flake8-pytest-style.parametrize-names-type = "csv" +lint.flake8-tidy-imports.banned-api."typing.TYPE_CHECKING".msg = "Use TYPE_CHECKING = False instead" lint.isort.known-first-party = [ "humanize" ] lint.isort.required-imports = [ "from __future__ import annotations" ] lint.pydocstyle.convention = "google" @@ -102,6 +105,7 @@ max_supported_python = "3.15" [tool.mypy] strict = true pretty = true +num_workers = 4 show_error_codes = true [tool.pytest] diff --git a/src/humanize/number.py b/src/humanize/number.py index 2fb22c60..78bb26f1 100644 --- a/src/humanize/number.py +++ b/src/humanize/number.py @@ -540,7 +540,7 @@ def metric(value: float, unit: str = "", precision: int = 3) -> str: if not math.isfinite(value): return _format_not_finite(value) - exponent = int(math.floor(math.log10(abs(value)))) if value != 0 else 0 + exponent = math.floor(math.log10(abs(value))) if value != 0 else 0 if exponent >= 33 or exponent < -30: return scientific(value, precision - 1) + unit