fix(api-v3): clear the six lint errors this rebase introduced

All six were introduced by rebasing this branch onto the merged blueprint
split, not by the split itself. Confirmed by diffing pyflakes output against
main with line numbers normalised -- everything else it reports is present on
main too and is the package's deliberate re-export pattern.

starlark.py used _STARLARK_APPS_DIR three times without importing it (F821).
The rebase resolved an import-list conflict as a union of both sides, and that
symbol was on neither side of the conflict hunk, so it was silently lost. It is
defined in __init__.py and is now imported like its neighbours. This was the
only one of the six that would fail at runtime rather than merely lint.

__init__.py imported contextlib twice (F811): the cherry-pick added one next to
the existing import. Removed the duplicate; the original at line 19 is used.

__init__.py imported signal purely to re-export it to starlark.py, so pyflakes
saw it as unused (F401). signal is stdlib and does not need routing through the
blueprint package, so starlark.py imports it directly and __init__.py no longer
does. contextlib stays re-exported because this module genuinely uses it.

_read_mqtt_bridge_config()'s local `config` shadowed the `config` submodule
this module imports at the bottom for its route side effects (F811). Renamed to
`settings`, with a comment saying why, since the name is otherwise the obvious
one to reach for.

Verified: pyflakes now reports nothing on this branch that main does not, the
package imports, all nine route modules load, and 117 routes register, matching
the pinned URL-map snapshot.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-09-11 10:40:13 -04:00
co-authored by Claude Opus 5
parent db60115bc2
commit eb942275c1
2 changed files with 16 additions and 10 deletions
+10 -7
View File
@@ -18,8 +18,6 @@ everything they need has to exist first.
from flask import Blueprint, request, jsonify, Response
import contextlib
import json
import signal
import contextlib
import os
import re
import stat
@@ -1971,18 +1969,23 @@ def _mqtt_bridge_service_state() -> Dict[str, Any]:
return state
def _read_mqtt_bridge_config() -> Dict[str, Any]:
"""Stored config overlaid on the defaults. Missing file is not an error."""
config = dict(_MQTT_BRIDGE_DEFAULTS)
config['mqtt_password'] = None
"""Stored config overlaid on the defaults. Missing file is not an error.
Named `settings`, not `config`: this module imports a submodule called
`config` at the bottom for its route side effects, and a local of the same
name shadows it.
"""
settings = dict(_MQTT_BRIDGE_DEFAULTS)
settings['mqtt_password'] = None
try:
if _MQTT_BRIDGE_CONFIG.is_file():
with open(_MQTT_BRIDGE_CONFIG, encoding='utf-8') as handle:
stored = json.load(handle)
if isinstance(stored, dict):
config.update(stored)
settings.update(stored)
except (OSError, json.JSONDecodeError) as err:
logger.warning('Could not read %s: %s', _MQTT_BRIDGE_CONFIG, err)
return config
return settings
def _coerce_mqtt_bridge_value(key: str, raw: Any) -> Tuple[Any, Optional[str]]:
"""Validate one submitted field. Returns (value, error)."""
+6 -3
View File
@@ -3,16 +3,19 @@
Routes decorate the shared `api_v3` Blueprint from ._common, so their
endpoint names are unchanged by living here.
"""
import signal
from web_interface.blueprints.api_v3 import (
PROJECT_ROOT, Path, _PIXLET_EDITOR_DEFAULT_PORT,
_PIXLET_EDITOR_DEFAULT_TIMEOUT, _PIXLET_EDITOR_MAX_TIMEOUT,
_PIXLET_EDITOR_SCRIPT, _PIXLET_EDITOR_STATE, _clear_pixlet_editor_state,
_find_pixlet_binary, _install_star_file, _pixlet_editor_alive,
_pixlet_editor_status, _read_pixlet_editor_state,
_standalone_render_starlark_app, _starlark_github_token,
_starlark_manifest_lock, _validate_and_sanitize_app_id,
_STARLARK_APPS_DIR, _standalone_render_starlark_app,
_starlark_github_token, _starlark_manifest_lock,
_validate_and_sanitize_app_id,
_validate_starlark_app_path, _validate_timing_value, api_v3, contextlib,
describe_exception, json, jsonify, logger, os, request, shutil, signal,
describe_exception, json, jsonify, logger, os, request, shutil,
subprocess, tempfile,
)
import web_interface.blueprints.api_v3 as _pkg