fix: mypy errors from TTS language switching (#5) #8

Merged
troed merged 1 commit from devel into main 2026-08-26 18:25:05 +02:00
Owner

Fixes the mypy failures introduced in #5 that have been failing CI on every push since.

Root cause from actions/runs/3984 logs:

src/computer/LLM/utils.py:90: error: Incompatible types in assignment (expression has type "None", variable has type "LanguageDetector")  [assignment]
src/computer/LLM/base_openai_compatible_language_model.py:310: error: Argument 2 to "resolve_effective_language" has incompatible type "list[str] | None"; expected "Iterable[str]"  [arg-type]
src/computer/LLM/base_openai_compatible_language_model.py:310: error: Argument 3 to "resolve_effective_language" has incompatible type "str | None"; expected "str"  [arg-type]

Fixes:

  • utils.py: _lingua_detector is LanguageDetector in the success branch and None in the ImportError branch — added type: ignore[assignment] on both assignments (runtime guard is LINGUA_AVAILABLE).
  • base_openai_compatible_language_model.py: _chunk() checked getattr(self, "tts_*", None) for truthiness but then passed self.tts_supported_languages / self.tts_default_language (still Optional to mypy). Now captures to locals tts_supported / tts_default via getattr first, so the truthiness check narrows them.

Verified:

  • uv run mypy src/ → Success: no issues found in 101 source files
  • uv run ruff check src/ tests/ / ruff format --check src/ tests/ → clean
  • Targeted pytest (106 tests) → pass
Fixes the mypy failures introduced in #5 that have been failing CI on every push since. Root cause from `actions/runs/3984` logs: ``` src/computer/LLM/utils.py:90: error: Incompatible types in assignment (expression has type "None", variable has type "LanguageDetector") [assignment] src/computer/LLM/base_openai_compatible_language_model.py:310: error: Argument 2 to "resolve_effective_language" has incompatible type "list[str] | None"; expected "Iterable[str]" [arg-type] src/computer/LLM/base_openai_compatible_language_model.py:310: error: Argument 3 to "resolve_effective_language" has incompatible type "str | None"; expected "str" [arg-type] ``` Fixes: - `utils.py`: `_lingua_detector` is `LanguageDetector` in the success branch and `None` in the `ImportError` branch — added `type: ignore[assignment]` on both assignments (runtime guard is `LINGUA_AVAILABLE`). - `base_openai_compatible_language_model.py`: `_chunk()` checked `getattr(self, "tts_*", None)` for truthiness but then passed `self.tts_supported_languages` / `self.tts_default_language` (still `Optional` to mypy). Now captures to locals `tts_supported` / `tts_default` via `getattr` first, so the truthiness check narrows them. Verified: - `uv run mypy src/` → `Success: no issues found in 101 source files` - `uv run ruff check src/ tests/` / `ruff format --check src/ tests/` → clean - Targeted pytest (106 tests) → pass
Follow-up to the public-repo security audit: tracked files carried real internal network details (LAN IP, hostnames, username, home paths, SSH port). This removes them; real values stay in gitignored local files and the deploy environment, mirroring the policy already used in starfleet/roster.

Changes:
- `AGENTS.md`: added a **Public repo hygiene** section (no internal hostnames/IPs/usernames/home paths/credentials in tracked files; pre-push scan command). Sanitized the deploy/fj sections that documented the live server's address, user, repo path, and SSH commands.
- `deploy.sh`: `SERVER_HOST`, `SERVER_USER`, `SERVER_REPO_DIR` are now **required env vars** (were hardcoded LAN defaults); setup comments use placeholders.
- `client.sh.example` / `server.sh.example` / `mcp.json.example`: placeholder hosts (`<server-host>`, `<llm-host>`, `<home-assistant-host>`).
- `README.md` + `src/computer/client/__init__.py`: example IPs replaced with placeholders.

Deploy note: run deploys with `SERVER_HOST=... SERVER_USER=... SERVER_REPO_DIR=... ./deploy.sh` (export them in your shell or a gitignored env file).

Verification: `bash -n deploy.sh` OK; edited Python module compiles; hygiene scan (`git grep -nIEi ...`) clean over tracked tree.
Co-authored-by: Troed Sångberg <github@troed.se>
Reviewed-on: #4
docs: note wake word model training is complete
Some checks failed
CI / Sanity check (ubuntu-latest) (pull_request) Failing after 3m33s
8a67ed25fd
docs: add NemotronLabs VoiceChat-11B investigation
Some checks failed
CI / Sanity check (ubuntu-latest) (pull_request) Failing after 3m19s
d3b4b67576
docs: add roster server to mcp.json.example
Some checks failed
CI / Sanity check (ubuntu-latest) (pull_request) Failing after 3m37s
e452cd1986
fix: mypy errors from TTS language switching (#5)
Some checks failed
CI / Sanity check (ubuntu-latest) (pull_request) Has been cancelled
9d1701a0cb
utils: _lingua_detector assigned None in ImportError branch typed as
LanguageDetector — suppress with type: ignore[assignment] (runtime
guard is LINGUA_AVAILABLE).

base_openai: resolve_effective_language called with list[str]|None /
str|None because getattr guard wasn't narrowing self.tts_* attrs for
mypy — capture to locals tts_supported/tts_default first.
troed force-pushed devel from 9d1701a0cb
Some checks failed
CI / Sanity check (ubuntu-latest) (pull_request) Has been cancelled
to 7907581b4c
All checks were successful
CI / Sanity check (ubuntu-latest) (pull_request) Successful in 4m42s
2026-08-26 18:24:52 +02:00
Compare
troed merged commit b1866517d5 into main 2026-08-26 18:25:05 +02:00
troed deleted branch devel 2026-08-26 18:25:05 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starfleet/computer!8
No description provided.