|
10 | 10 | from collections.abc import AsyncIterator, Awaitable, Callable, Mapping, Sequence |
11 | 11 | from contextlib import asynccontextmanager |
12 | 12 | from types import TracebackType |
13 | | -from typing import Any |
| 13 | +from typing import Any, Final |
14 | 14 |
|
15 | 15 | from dqliteclient.exceptions import ( |
16 | 16 | DataError, |
|
43 | 43 | # and Go peer clients which also emit a bare ``BEGIN``. The constant |
44 | 44 | # pins the literal so a refactor can't silently upgrade to ``BEGIN |
45 | 45 | # IMMEDIATE`` without showing up in review. |
46 | | -_TRANSACTION_BEGIN_SQL = "BEGIN" |
| 46 | +_TRANSACTION_BEGIN_SQL: Final[str] = "BEGIN" |
47 | 47 |
|
48 | 48 | # ``COMMIT`` and ``ROLLBACK`` literals are pinned for the same reason as |
49 | 49 | # ``_TRANSACTION_BEGIN_SQL``: a refactor must not silently switch to a |
50 | 50 | # vendor-qualified form (``COMMIT TRANSACTION``) or a savepoint variant. |
51 | 51 | # Consistency between ``transaction()`` and the pool's reset-on-return |
52 | 52 | # path is a correctness invariant — if they diverge, a connection could |
53 | 53 | # be returned to the pool with a still-open server-side transaction. |
54 | | -_TRANSACTION_COMMIT_SQL = "COMMIT" |
55 | | -_TRANSACTION_ROLLBACK_SQL = "ROLLBACK" |
| 54 | +_TRANSACTION_COMMIT_SQL: Final[str] = "COMMIT" |
| 55 | +_TRANSACTION_ROLLBACK_SQL: Final[str] = "ROLLBACK" |
56 | 56 |
|
57 | 57 | # ``_TX_AUTO_ROLLBACK_PRIMARY_CODES`` is imported above from ``dqlitewire`` |
58 | 58 | # (canonical home for SQLite-side constants). It contains the primary |
|
78 | 78 | # a fresh transaction whose boundary the user code does not know about. |
79 | 79 |
|
80 | 80 |
|
81 | | -_BARE_IDENT_FIRST = frozenset(string.ascii_letters + "_") |
82 | | -_BARE_IDENT_REST = frozenset(string.ascii_letters + string.digits + "_") |
| 81 | +_BARE_IDENT_FIRST: Final[frozenset[str]] = frozenset(string.ascii_letters + "_") |
| 82 | +_BARE_IDENT_REST: Final[frozenset[str]] = frozenset(string.ascii_letters + string.digits + "_") |
83 | 83 |
|
84 | 84 | # Coupled to dqlite-upstream/src/gateway.c failure() emissions for the |
85 | 85 | # Raft-side BUSY path that means "the in-flight write was not accepted; |
|
90 | 90 | # the matcher here keeps the upstream-coupling explicit so a future |
91 | 91 | # rewording (or addition of a new Raft-BUSY message) is one-line update |
92 | 92 | # rather than a hunt through the classifier. |
93 | | -_RAFT_BUSY_MESSAGE_FRAGMENTS: tuple[str, ...] = ("checkpoint in progress",) |
| 93 | +_RAFT_BUSY_MESSAGE_FRAGMENTS: Final[tuple[str, ...]] = ("checkpoint in progress",) |
94 | 94 |
|
95 | 95 |
|
96 | 96 | def _is_keyword_boundary(s: str, kw_len: int) -> bool: |
|
0 commit comments