Clean up LSP diagnostics across backend and frontend #7

Merged
Pakobbix merged 1 commits from cleanup/lint-modernization into main 2026-09-08 21:58:42 +00:00
Collaborator

Lint/type-cleanup pass: 103 LSP diagnostics (89 backend + 14 frontend) → 0 errors/warnings. Behavior-preserving except three intentional fixes.

Backend

  • hal/: conditional pynvml imports → established pynvml: Any = _pynvml_import pattern (fixes ~50 "possibly unbound" errors); typed result dicts; query_interface() guards; explicit uuid/pci-bus parsing; Optional[T] → T | None
  • cli.py: curve_state unbound + snap_path None fixed; unchecked int()/open()/makedirs() wrapped with clean CLI errors; logger for silent except-pass; raise ... from exc
  • daemon.py: 0o666 → _SOCKET_MODE constant (intentional for /run sockets) + nosemgrep
  • server.py: nosemgrep for 3.7-compat false positive (requires ≥3.12); swallowed exception logged
  • profiles/: file ops + int(k) key parsing wrapped; imports sorted; typing modernized

Frontend

  • .js extensions on all relative imports (TS-ESM standard; Vite resolves .js → .ts)
  • React.FormEvent (deprecated) → React.SubmitEvent; catch (e: any) → unknown + narrowing
  • React-hooks: ref writes moved to effects; viewport reset → render-phase state adjustment; selectPoint(index, multi) split into selectPoint/togglePoint; non-null assertion removed
  • Static inline styles → Tailwind; non-standard scrollIntoView container option removed

Intentional behavior changes

  1. nvcurve setup no longer restores the newest (possibly stale) snapshot when baseline save fails — reports the failure instead
  2. pci_bus_id now always int | None (string bus values parsed as hex)
  3. Invalid profile point keys no longer raise in apply_profile/apply_with_retry — reported/skipped

Verified: tsc --noEmit (full) · vite build (2338 modules) · Python imports · LSP scan: 0 errors/warnings

Note: no test suite; selection refactor traced old-vs-new (equivalent) — manual pass of Shift/Ctrl+click, box-select, flatten-to-anchor recommended.

Lint/type-cleanup pass: 103 LSP diagnostics (89 backend + 14 frontend) → 0 errors/warnings. Behavior-preserving except three intentional fixes. **Backend** - hal/: conditional pynvml imports → established `pynvml: Any = _pynvml_import` pattern (fixes ~50 "possibly unbound" errors); typed result dicts; query_interface() guards; explicit uuid/pci-bus parsing; `Optional[T]` → `T | None` - cli.py: curve_state unbound + snap_path None fixed; unchecked int()/open()/makedirs() wrapped with clean CLI errors; logger for silent except-pass; `raise ... from exc` - daemon.py: 0o666 → _SOCKET_MODE constant (intentional for /run sockets) + nosemgrep - server.py: nosemgrep for 3.7-compat false positive (requires ≥3.12); swallowed exception logged - profiles/: file ops + int(k) key parsing wrapped; imports sorted; typing modernized **Frontend** - .js extensions on all relative imports (TS-ESM standard; Vite resolves .js → .ts) - React.FormEvent (deprecated) → React.SubmitEvent; catch (e: any) → unknown + narrowing - React-hooks: ref writes moved to effects; viewport reset → render-phase state adjustment; selectPoint(index, multi) split into selectPoint/togglePoint; non-null assertion removed - Static inline styles → Tailwind; non-standard scrollIntoView container option removed **Intentional behavior changes** 1. `nvcurve setup` no longer restores the newest (possibly stale) snapshot when baseline save fails — reports the failure instead 2. pci_bus_id now always int | None (string bus values parsed as hex) 3. Invalid profile point keys no longer raise in apply_profile/apply_with_retry — reported/skipped **Verified:** tsc --noEmit (full) · vite build (2338 modules) · Python imports · LSP scan: 0 errors/warnings Note: no test suite; selection refactor traced old-vs-new (equivalent) — manual pass of Shift/Ctrl+click, box-select, flatten-to-anchor recommended.
ARIA added 1 commit 2026-09-08 21:57:45 +00:00
Backend (nvcurve/):
- hal/fans.py, hal/limits.py, hal/gpu.py: replace conditional pynvml
  imports with the established 'pynvml: Any = _pynvml_import' pattern
  (fixes ~50 'possibly unbound' errors); type the result dicts; guard
  query_interface() results; explicit uuid/pci-bus parsing (int, hex
  convention documented); modernize Optional[T] -> T | None
- cli.py: fix 'curve_state' possibly-unbound and snap_path None handling
  in cmd_setup; wrap unchecked int()/open()/makedirs() calls in
  try/except with clean CLI errors; add module logger for silent
  except-pass blocks; raise ... from exc; fix unused loop vars and
  set-comprehension
- hal/snapshot.py: filepath: str | None; wrap all file ops; sorted
  imports; remove unused CT_POINTS import
- daemon.py: extract 0o666 to _SOCKET_MODE constant (intentional for
  /run sockets) with nosemgrep
- server.py: nosemgrep for Python 3.7-compat false positive (project
  requires >= 3.12); log previously-swallowed exception
- profiles/native.py, profiles/apply.py: wrap file ops and int(k)
  profile-key parsing; sorted imports; modernize typing

Frontend (frontend/src):
- Add .js extensions to all relative imports (standard TS-ESM; Vite
  resolves .js -> .ts)
- React.FormEvent (deprecated in React 19 types) -> React.SubmitEvent
- catch (e: any) -> catch (e: unknown) + instanceof Error narrowing
- React-hooks: move ref writes from render into effects; convert
  viewport reset to render-phase state adjustment; split
  selectPoint(index, multi) into selectPoint + togglePoint (no flag
  argument); remove non-null assertion
- Static inline styles -> Tailwind classes (dynamic positioning/cursor
  styles kept)
- Remove non-standard 'container' option from scrollIntoView (browsers
  ignore unknown options) which had orphaned a @ts-expect-error
- Object.fromEntries for Map -> Record conversion

Tooling:
- .gitignore: ignore .codegraph/ local tool data

Verified: tsc --noEmit, vite production build, python imports, and
full LSP scan (0 errors/warnings in both projects).
Collaborator

✅ No issues found — changes look consistent with the stated intent. Ready to be merged.

✅ No issues found — changes look consistent with the stated intent. Ready to be merged.
Pakobbix merged commit 34a9bc6d6e into main 2026-09-08 21:58:42 +00:00
Pakobbix deleted branch cleanup/lint-modernization 2026-09-08 21:58:43 +00:00
Sign in to join this conversation.