Skip to content

Commit bca3a92

Browse files
committed
chore: bump docformatter to v1.7.8
v1.7.8 drops the unmaintained `untokenize` dependency (replaced by stdlib `tokenize`), which was failing to install on Python 3.12+ runners due to `ast.Constant.s` removal. This unblocks pre-commit.ci without the `ci.skip: [docformatter]` workaround added in #376. v1.7.8 also introduced stricter docstring formatting decisions that conflict with ruff-format on a few patterns: - blank lines after docstring-only function bodies (prometheus.py) - blank lines between module docstring and first class (clients.py) - multi-line string literals used as `exec()` arguments that docformatter mistakes for docstrings (test_varargs.py) The 3 affected files are excluded from docformatter via a regex `exclude:` in the hook config until upstream reconciles the conventions or the patterns are restructured. Includes docstring rewrapping in 4 files (core.py, cores/base.py, conftest.py, test_general.py) that v1.7.8's defaults now produce. test_general.py also has misplaced docstring-style strings inside function bodies converted to `#` comments to fix oscillation with ruff-format.
1 parent ce16a58 commit bca3a92

5 files changed

Lines changed: 30 additions & 28 deletions

File tree

.pre-commit-config.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ ci:
66
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
77
autoupdate_schedule: quarterly
88
# submodules: true
9-
# docformatter v1.7.7 transitively pulls `untokenize`, whose setup.py
10-
# uses `ast.Constant.s` (removed in Python 3.12+) and fails to install
11-
# on pre-commit.ci's runners. The `pre-commit` GitHub Actions job still
12-
# runs docformatter, so coverage isn't lost. Remove this once docformatter
13-
# ships v1.7.8 (which drops the untokenize dep).
14-
skip: [docformatter]
159

1610
repos:
1711
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -36,11 +30,23 @@ repos:
3630
args: []
3731

3832
- repo: https://github.com/PyCQA/docformatter
39-
rev: v1.7.7
33+
rev: v1.7.8
4034
hooks:
4135
- id: docformatter
4236
additional_dependencies: [tomli]
4337
args: ["--in-place"]
38+
# docformatter v1.7.8 disagrees with ruff-format on these files
39+
# (blank lines after docstring-only function bodies, blank lines
40+
# between module docstring and first class, and a multi-line
41+
# string literal used as an `exec()` argument that docformatter
42+
# incorrectly treats as a docstring). Exclude until upstream
43+
# reconciles the conventions or the patterns are restructured.
44+
exclude: |
45+
(?x)^(
46+
src/cachier/exporters/prometheus\.py|
47+
tests/mongo_tests/clients\.py|
48+
tests/test_varargs\.py
49+
)$
4450
4551
- repo: https://github.com/executablebooks/mdformat
4652
rev: 1.0.0

src/cachier/core.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@
3939
class _CachierWrappedFunc(Protocol[_P, _R_co]):
4040
"""Callable returned by ``@cachier`` with the decorated function's signature.
4141
42-
Preserves the original function's parameter and return types via ``ParamSpec``
43-
while also exposing the cache-management attributes attached by the decorator.
44-
Per-call cachier options such as ``max_age`` and ``cachier__skip_cache`` are
45-
accepted at runtime but are not surfaced in the ``__call__`` signature here;
46-
PEP 612 does not permit mixing ParamSpec kwargs with additional keyword-only
47-
parameters.
42+
Preserves the original function's parameter and return types via ``ParamSpec`` while also exposing the cache-
43+
management attributes attached by the decorator. Per-call cachier options such as ``max_age`` and
44+
``cachier__skip_cache`` are accepted at runtime but are not surfaced in the ``__call__`` signature here; PEP 612
45+
does not permit mixing ParamSpec kwargs with additional keyword-only parameters.
4846
4947
"""
5048

@@ -85,9 +83,8 @@ async def _background_recalc_async(
8583
) -> None:
8684
"""Run async recomputation in background and clear processing flag.
8785
88-
This helper ensures that the cache entry's "being calculated" state is
89-
cleared only after the background recomputation and cache update
90-
(performed by ``_function_thread_async``) have completed.
86+
This helper ensures that the cache entry's "being calculated" state is cleared only after the background
87+
recomputation and cache update (performed by ``_function_thread_async``) have completed.
9188
9289
"""
9390
try:

src/cachier/cores/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def check_calc_timeout(self, time_spent):
121121
def get_entry_by_key(self, key: str) -> Tuple[str, Optional[CacheEntry]]:
122122
"""Get entry based on given key.
123123
124-
Return the key and the :class:`~cachier.config.CacheEntry` mapped
125-
to the given key in this core's cache, if such a mapping exists.
124+
Return the key and the :class:`~cachier.config.CacheEntry` mapped to the given key in this core's cache, if such
125+
a mapping exists.
126126
127127
"""
128128

tests/conftest.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ def _build_worker_url(original_url: str, schema_name: str) -> str:
4848
def worker_sql_connection(request: pytest.FixtureRequest) -> Optional[str]:
4949
"""Create the worker-specific PostgreSQL schema once per xdist worker session.
5050
51-
Returns the worker-specific connection URL, or None when schema isolation is not
52-
needed (serial run or non-PostgreSQL backend). The schema is created with
53-
``CREATE SCHEMA IF NOT EXISTS`` so this fixture is safe to run even if the schema
54-
already exists from a previous interrupted run.
55-
56-
A non-None return value means "use this URL"; schema creation is attempted but may
57-
fail silently (e.g. if SQLAlchemy is not installed or the DB is unreachable). Tests
58-
that depend on the schema will fail at the DB level with a diagnostic error.
51+
Returns the worker-specific connection URL, or None when schema isolation is not needed (serial run or non-
52+
PostgreSQL backend). The schema is created with ``CREATE SCHEMA IF NOT EXISTS`` so this fixture is safe to run even
53+
if the schema already exists from a previous interrupted run.
54+
55+
A non-None return value means "use this URL"; schema creation is attempted but may fail silently (e.g. if SQLAlchemy
56+
is not installed or the DB is unreachable). Tests that depend on the schema will fail at the DB level with a
57+
diagnostic error.
5958
6059
"""
6160
# Avoid touching SQL backends entirely when no SQL tests are collected.

tests/test_general.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _calls_wait_for_calc_timeout_fast(res_queue):
7777
res = _wait_for_calc_timeout_fast(1, 2)
7878
res_queue.put(res)
7979

80-
""" Testing calls that avoid timeouts store the values in cache. """
80+
# Testing calls that avoid timeouts store the values in cache.
8181
_wait_for_calc_timeout_fast.clear_cache()
8282
val1 = _wait_for_calc_timeout_fast(1, 2)
8383
val2 = _wait_for_calc_timeout_fast(1, 2)
@@ -123,7 +123,7 @@ def _calls_wait_for_calc_timeout_slow(res_queue):
123123
res = _wait_for_calc_timeout_slow(1, 2)
124124
res_queue.put(res)
125125

126-
"""Testing for calls timing out to be performed twice when needed."""
126+
# Testing for calls timing out to be performed twice when needed.
127127
_wait_for_calc_timeout_slow.clear_cache()
128128
res_queue = queue.Queue()
129129
thread1 = threading.Thread(

0 commit comments

Comments
 (0)