From 03af6b2e9a80d70c73d6413ac435411c51dbf718 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 00:39:33 +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.3.5 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.3.5...v0.5.0) - [github.com/psf/black-pre-commit-mirror: 24.3.0 → 24.4.2](https://github.com/psf/black-pre-commit-mirror/compare/24.3.0...24.4.2) - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.5.0...v4.6.0) - [github.com/pre-commit/mirrors-mypy: v1.9.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.9.0...v1.10.1) - [github.com/tox-dev/pyproject-fmt: 1.7.0 → 2.1.3](https://github.com/tox-dev/pyproject-fmt/compare/1.7.0...2.1.3) - [github.com/abravalheri/validate-pyproject: v0.16 → v0.18](https://github.com/abravalheri/validate-pyproject/compare/v0.16...v0.18) --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ca741e..6b492d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,17 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.5 + rev: v0.5.0 hooks: - id: ruff args: [--exit-non-zero-on-fix] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.3.0 + rev: 24.4.2 hooks: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-case-conflict - id: check-merge-conflict @@ -24,7 +24,7 @@ repos: exclude: \.github/ISSUE_TEMPLATE\.md|\.github/PULL_REQUEST_TEMPLATE\.md - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.9.0 + rev: v1.10.1 hooks: - id: mypy additional_dependencies: [pytest, types-freezegun, types-setuptools] @@ -32,13 +32,13 @@ repos: pass_filenames: false - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.7.0 + rev: 2.1.3 hooks: - id: pyproject-fmt additional_dependencies: [tox] - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.16 + rev: v0.18 hooks: - id: validate-pyproject From aa3a94e011a795a0551717c5a78a566bc2672390 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 2 Jul 2024 09:04:23 +0300 Subject: [PATCH 2/3] Configure pyproject-fmt for 3.13 Trove classifier --- .pre-commit-config.yaml | 3 +- pyproject.toml | 78 ++++++++++++++++++++++------------------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b492d1..8bbe542 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: + - id: check-added-large-files - id: check-case-conflict - id: check-merge-conflict - id: check-json @@ -20,6 +21,7 @@ repos: - id: check-yaml - id: debug-statements - id: end-of-file-fixer + - id: forbid-submodules - id: trailing-whitespace exclude: \.github/ISSUE_TEMPLATE\.md|\.github/PULL_REQUEST_TEMPLATE\.md @@ -35,7 +37,6 @@ repos: rev: 2.1.3 hooks: - id: pyproject-fmt - additional_dependencies: [tox] - repo: https://github.com/abravalheri/validate-pyproject rev: v0.18 diff --git a/pyproject.toml b/pyproject.toml index 6337f8f..71ecdf1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,9 +12,13 @@ readme = "README.md" keywords = [ "humanize time size", ] -license = {text = "MIT"} -maintainers = [{name = "Hugo van Kemenade"}] -authors = [{name = "Jason Moiron", email = "jmoiron@jmoiron.net"}] +license = { text = "MIT" } +maintainers = [ + { name = "Hugo van Kemenade" }, +] +authors = [ + { name = "Jason Moiron", email = "jmoiron@jmoiron.net" }, +] requires-python = ">=3.8" classifiers = [ "Development Status :: 5 - Production/Stable", @@ -37,19 +41,17 @@ classifiers = [ dynamic = [ "version", ] -[project.optional-dependencies] -tests = [ +optional-dependencies.tests = [ "freezegun", "pytest", "pytest-cov", ] -[project.urls] -Documentation = "https://humanize.readthedocs.io/" -Funding = "https://tidelift.com/subscription/pkg/pypi-humanize?utm_source=pypi-humanize&utm_medium=pypi" -Homepage = "https://github.com/python-humanize/humanize" -"Issue tracker" = "https://github.com/python-humanize/humanize/issues" -"Release notes" = "https://github.com/python-humanize/humanize/releases" -Source = "https://github.com/python-humanize/humanize" +urls.Documentation = "https://humanize.readthedocs.io/" +urls.Funding = "https://tidelift.com/subscription/pkg/pypi-humanize?utm_source=pypi-humanize&utm_medium=pypi" +urls.Homepage = "https://github.com/python-humanize/humanize" +urls."Issue tracker" = "https://github.com/python-humanize/humanize/issues" +urls."Release notes" = "https://github.com/python-humanize/humanize/releases" +urls.Source = "https://github.com/python-humanize/humanize" [tool.hatch] version.source = "vcs" @@ -65,38 +67,42 @@ local_scheme = "no-local-version" [tool.ruff] 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 +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 + "PYI", # flake8-pyi + "RUF022", # unsorted-dunder-all "RUF100", # unused noqa (yesqa) - "UP", # pyupgrade - "W", # pycodestyle warnings - "YTT", # flake8-2020 + "UP", # pyupgrade + "W", # pycodestyle warnings + "YTT", # flake8-2020 ] -extend-ignore = [ +lint.extend-ignore = [ "E203", # Whitespace before ':' "E221", # Multiple spaces before operator "E226", # Missing whitespace around arithmetic operator "E241", # Multiple spaces after ',' ] +lint.per-file-ignores."tests/*" = [ + "D", +] +lint.isort.known-first-party = [ + "humanize", +] +lint.isort.required-imports = [ + "from __future__ import annotations", +] +pydocstyle.convention = "google" -[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.pyproject-fmt] +max_supported_python = "3.13" [tool.pytest.ini_options] addopts = "--color=yes" From cae4163791e6553240293d80acc75ee71c24f892 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 2 Jul 2024 09:06:31 +0300 Subject: [PATCH 3/3] Ruff updates --- pyproject.toml | 2 +- src/humanize/number.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 71ecdf1..e151cd6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,7 +99,7 @@ lint.isort.known-first-party = [ lint.isort.required-imports = [ "from __future__ import annotations", ] -pydocstyle.convention = "google" +lint.pydocstyle.convention = "google" [tool.pyproject-fmt] max_supported_python = "3.13" diff --git a/src/humanize/number.py b/src/humanize/number.py index 19b397e..7bf7c55 100644 --- a/src/humanize/number.py +++ b/src/humanize/number.py @@ -424,7 +424,7 @@ def scientific(value: NumberOrString, precision: int = 2) -> str: return _format_not_finite(value) except (ValueError, TypeError): return str(value) - fmt = "{:.%se}" % str(int(precision)) + fmt = f"{{:.{str(int(precision))}e}}" n = fmt.format(value) part1, part2 = n.split("e") # Remove redundant leading '+' or '0's (preserving the last '0' for 10⁰).