From 801d7a01999a2fd2216536655671ce69be8ae0bc Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Tue, 17 Nov 2026 22:20:19 +0100 Subject: [PATCH] Clear red pre-commit and stale pins check_patch_targets reads PEP 562 _LAZY_ATTRS tables when a module cannot import under the hook python. Bumps gatelock 0.15.0, rtdb-relay 0.2.0 (Python side unchanged), gradle 9.9.1. Co-Authored-By: Claude Opus 5.5 --- .pre-commit-config.yaml | 4 ++-- .../gradle/wrapper/gradle-wrapper.properties | 2 +- diet_guard/_kuchnia_autolog.py | 7 ++++++- docs/DOCS-claude-relay.md | 2 +- pyproject.toml | 4 ++-- requirements.txt | 4 ++-- scripts/check_patch_targets.py | 17 +++++++++++++++++ 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 976e5a4..f1858d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -111,11 +111,11 @@ repos: # direct URLs for one distribution, so any pin that drifts from # the manifest becomes an unresolvable hook environment rather # than merely an old one. - - gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.14.0#subdirectory=gatelock + - gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.15.0#subdirectory=gatelock - crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync - freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays - sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays - - rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.1.1#subdirectory=rtdb_relay + - rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.2.0#subdirectory=rtdb_relay - claude-agent-sdk==0.2.183 - httpx==0.28.1 - mcp>=2,<3 diff --git a/app/android/gradle/wrapper/gradle-wrapper.properties b/app/android/gradle/wrapper/gradle-wrapper.properties index 46b4692..1e395d3 100644 --- a/app/android/gradle/wrapper/gradle-wrapper.properties +++ b/app/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.1-all.zip diff --git a/diet_guard/_kuchnia_autolog.py b/diet_guard/_kuchnia_autolog.py index 7b3b587..37237e3 100644 --- a/diet_guard/_kuchnia_autolog.py +++ b/diet_guard/_kuchnia_autolog.py @@ -52,9 +52,14 @@ _logger = logging.getLogger(__name__) FETCH_TIMEOUT_S = 5.0 +#: Names served lazily by ``__getattr__`` (read statically by +#: scripts/check_patch_targets.py when the catering client cannot import). +_LAZY_ATTRS = ("refresh_delivery",) + + def __getattr__(name: str) -> object: """Resolve the deferred catering import on first attribute access.""" - if name != "refresh_delivery": + if name not in _LAZY_ATTRS: msg = f"module {__name__!r} has no attribute {name!r}" raise AttributeError(msg) return import_module("diet_guard._kuchnia_import").refresh_delivery diff --git a/docs/DOCS-claude-relay.md b/docs/DOCS-claude-relay.md index 62ac6aa..54f7eaa 100644 --- a/docs/DOCS-claude-relay.md +++ b/docs/DOCS-claude-relay.md @@ -3,7 +3,7 @@ The phone sends a food description and/or a photo. A worker on the PC runs Claude on kuhy's Max subscription, **logs the meal at once (no review)** and answers the phone. Transport is Firebase RTDB through the shared -`rtdb_relay` package (`kuhyx/utils`, tag `rtdb-relay-v0.1.1`), the same wire +`rtdb_relay` package (`kuhyx/utils`, tag `rtdb-relay-v0.2.0`), the same wire format as the tutor app. No VPN, no open port, only kuhy's Google account. This file is the contract both halves build against. The fixture diff --git a/pyproject.toml b/pyproject.toml index 1711cc9..5c5b7ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ version = "1.0.0" description = "Tkinter/systemd log-to-unlock meal gate with calorie/macro budget tracking" requires-python = ">=3.14" dependencies = [ - "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.14.0#subdirectory=gatelock", + "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.15.0#subdirectory=gatelock", "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync", "freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays", "holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds", @@ -13,7 +13,7 @@ dependencies = [ "defusedxml==0.7.1", "httpx==0.28.1", "requests==2.34.2", - "rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.1.1#subdirectory=rtdb_relay", + "rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.2.0#subdirectory=rtdb_relay", ] # Optional extras. The `mcp` group is ONLY needed by the MCP server diff --git a/requirements.txt b/requirements.txt index 263b9a2..120af9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ coverage==7.17.3 crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync defusedxml==0.7.1 freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays -gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.14.0#subdirectory=gatelock +gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.15.0#subdirectory=gatelock holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds httpx==0.28.1 hypothesis==6.170.15 @@ -23,6 +23,6 @@ pytest-sugar==1.1.1 pytest-xdist==3.8.0 pytest-xvfb==3.1.1 requests==2.34.2 -rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.1.1#subdirectory=rtdb_relay +rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.2.0#subdirectory=rtdb_relay ruff==0.17.5 sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays diff --git a/scripts/check_patch_targets.py b/scripts/check_patch_targets.py index 124311f..8349ee7 100755 --- a/scripts/check_patch_targets.py +++ b/scripts/check_patch_targets.py @@ -65,6 +65,21 @@ def _third_party_missing(exc: ImportError) -> bool: return isinstance(exc, ModuleNotFoundError) and not missing.startswith(PACKAGE) +def _lazy_names(value: ast.expr | None) -> list[str]: + """The names a PEP 562 ``_LAZY_ATTRS`` table (dict keys or a tuple) serves.""" + if isinstance(value, ast.Dict): + items: list[ast.expr | None] = list(value.keys) + elif isinstance(value, (ast.Tuple, ast.List, ast.Set)): + items = list(value.elts) + else: + return [] + return [ + i.value + for i in items + if isinstance(i, ast.Constant) and isinstance(i.value, str) + ] + + def defined_statically(parts: list[str], split: int) -> bool: """Whether ``parts[split]`` is a top-level name of module ``parts[:split]``. @@ -81,6 +96,8 @@ def defined_statically(parts: list[str], split: int) -> bool: elif isinstance(node, (ast.Assign, ast.AnnAssign)): targets = node.targets if isinstance(node, ast.Assign) else [node.target] names = [t.id for t in targets if isinstance(t, ast.Name)] + if "_LAZY_ATTRS" in names: + names += _lazy_names(node.value) elif isinstance(node, (ast.Import, ast.ImportFrom)): names = [(a.asname or a.name).split(".")[0] for a in node.names] else: