From fd7b96b857caddd5ccbd6f87d414cf65764d239b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 26 Jan 2026 11:20:42 +0000 Subject: [PATCH] Replace docformatter with pydocstringformatter - Replace docformatter==1.7.7 with pydocstringformatter==0.7.3 - Replace [tool.docformatter] with [tool.pydocstringformatter] config - Update ruff ignore comments (D200 -> D205/D212) - Don't use linewrap-full-docstring to avoid breaking URLs (https://github.com/DanielNoord/pydocstringformatter/issues/540) --- .pre-commit-config.yaml | 8 ++++---- conftest.py | 8 ++------ docs/source/__init__.py | 4 +--- docs/source/conf.py | 4 +--- pyproject.toml | 18 ++++++++++++------ src/vws_auth_tools/__init__.py | 10 +++++----- tests/__init__.py | 4 +--- tests/test_vws_auth_tools.py | 10 +++++----- 8 files changed, 31 insertions(+), 35 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e7c3a66e..ce63f39d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ ci: - check-manifest - deptry - doc8 - - docformatter + - pydocstringformatter - docs - interrogate - interrogate-docs @@ -103,9 +103,9 @@ repos: additional_dependencies: [uv==0.9.5] stages: [pre-commit] - - id: docformatter - name: docformatter - entry: uv run --extra=dev -m docformatter --in-place + - id: pydocstringformatter + name: pydocstringformatter + entry: uv run --extra=dev pydocstringformatter language: python types_or: [python] additional_dependencies: [uv==0.9.5] diff --git a/conftest.py b/conftest.py index b73b4e5c..ad57c824 100644 --- a/conftest.py +++ b/conftest.py @@ -1,6 +1,4 @@ -""" -Setup for test suite. -""" +"""Setup for test suite.""" import uuid from collections.abc import Generator @@ -63,9 +61,7 @@ def fixture_mock_vws( @beartype def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: - """ - Apply the beartype decorator to all collected test functions. - """ + """Apply the beartype decorator to all collected test functions.""" for item in items: if isinstance(item, pytest.Function): item.obj = beartype(obj=item.obj) diff --git a/docs/source/__init__.py b/docs/source/__init__.py index b63eed5f..535ceb2e 100644 --- a/docs/source/__init__.py +++ b/docs/source/__init__.py @@ -1,3 +1 @@ -""" -Documentation. -""" +"""Documentation.""" diff --git a/docs/source/conf.py b/docs/source/conf.py index 6a322fc9..bade81f0 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -""" -Configuration for Sphinx. -""" +"""Configuration for Sphinx.""" import importlib.metadata from pathlib import Path diff --git a/pyproject.toml b/pyproject.toml index 469f9cac..7511876e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,13 +38,13 @@ optional-dependencies.dev = [ "deptry==0.24.0", "doc8==2.0.0", "doccmd==2026.1.23.4", - "docformatter==1.7.7", "freezegun==1.5.5", "furo==2025.12.19", "interrogate==1.7.0", "mypy[faster-cache]==1.19.1", "mypy-strict-kwargs==2026.1.12", "prek==0.3.0", + "pydocstringformatter==0.7.3", "pylint[spelling]==4.0.4", "pylint-per-file-ignores==3.2.0", "pyproject-fmt==2.11.1", @@ -112,8 +112,8 @@ lint.select = [ lint.ignore = [ # Ruff warns that this conflicts with the formatter. "COM812", - # Allow our chosen docstring line-style - no one-line summary. - "D200", + # Allow our chosen docstring line-style - pydocstringformatter handles formatting + # but doesn't enforce D205 (blank line after summary) or D212 (summary on first line). "D205", "D212", # Ruff warns that this conflicts with the formatter. @@ -124,6 +124,9 @@ lint.ignore = [ ] lint.per-file-ignores."doccmd_*.py" = [ + # Allow our chosen docstring line-style - pydocstringformatter handles + # formatting but docstrings in docs may not match this style. + "D200", # Allow asserts in docs. "S101", ] @@ -264,9 +267,6 @@ spelling-private-dict-file = 'spelling_private_dict.txt' # --spelling-private-dict-file option instead of raising a message. spelling-store-unknown-words = 'no' -[tool.docformatter] -make-summary-multi-line = true - [tool.check-manifest] ignore = [ @@ -331,6 +331,12 @@ enableTypeIgnoreComments = false reportUnnecessaryTypeIgnoreComment = true typeCheckingMode = "strict" +[tool.pydocstringformatter] +write = true +split-summary-body = false +max-line-length = 75 +linewrap-full-docstring = true + [tool.interrogate] fail-under = 100 omit-covered-files = true diff --git a/src/vws_auth_tools/__init__.py b/src/vws_auth_tools/__init__.py index 2033acf1..3542b2fc 100644 --- a/src/vws_auth_tools/__init__.py +++ b/src/vws_auth_tools/__init__.py @@ -1,6 +1,4 @@ -""" -Authorization helpers. -""" +"""Authorization helpers.""" import base64 import email.utils @@ -13,7 +11,8 @@ @beartype def _compute_hmac_base64(key: bytes, data: bytes) -> bytes: """ - Return the Base64 encoded HMAC-SHA1 hash of `data` using the `key`. + Return the Base64 encoded HMAC-SHA1 hash of `data` using the + `key`. """ hashed = hmac.new(key=key, msg=None, digestmod=hashlib.sha1) hashed.update(msg=data) @@ -22,7 +21,8 @@ def _compute_hmac_base64(key: bytes, data: bytes) -> bytes: @beartype def rfc_1123_date() -> str: - """Return the date formatted as per RFC 2616, section 3.3.1, rfc1123-date. + """Return the date formatted as per RFC 2616, section 3.3.1, + rfc1123-date. This is the date needed by the VWS API, as described in https://developer.vuforia.com/library/web-api/vuforia-web-api-authentication. diff --git a/tests/__init__.py b/tests/__init__.py index 650d7b1a..3640385e 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1 @@ -""" -Tests for authorization tools. -""" +"""Tests for authorization tools.""" diff --git a/tests/test_vws_auth_tools.py b/tests/test_vws_auth_tools.py index 0779f4f9..018dbe4c 100644 --- a/tests/test_vws_auth_tools.py +++ b/tests/test_vws_auth_tools.py @@ -1,6 +1,4 @@ -""" -Tests for authorization tools. -""" +"""Tests for authorization tools.""" import datetime from zoneinfo import ZoneInfo @@ -12,7 +10,8 @@ def test_rfc_1123_date() -> None: - """The date is returned in the format described in the VWS documentation. + """The date is returned in the format described in the VWS + documentation. See https://developer.vuforia.com/library/web-api/vuforia-web-api-authentication: @@ -74,7 +73,8 @@ def test_authorization_header(content: bytes | str) -> None: @pytest.mark.parametrize(argnames="content", argvalues=[b"", None]) def test_authorization_header_none_content(content: bytes | None) -> None: """ - The Authorization header is the same whether the content is None or b"". + The Authorization header is the same whether the content is None or + b"". """ access_key = "my_access_key" # Ignore "Possible hardcoded password" as it is appropriate here.