Skip to content

Full type safety with Pyright enforcement #249

@nitrobass24

Description

@nitrobass24

Summary

Add static type checking enforcement to the Python codebase using Pyright in strict mode, with CI integration to prevent regressions.

Motivation

Type safety is a security measure. Unchecked types allow None to flow into sensitive functions (SSH command construction, os.path.join, shlex.quote), unvalidated external data to propagate through the system, and subtle bugs to hide at module boundaries.

RapidCopy enforces Mypy strict with 0 errors. We should match or exceed this with Pyright.

Current State

  • Angular: Already strong — strict: true in tsconfig, strict templates, only ~12 any usages at JSON parsing boundaries
  • Python: Type hints exist on many functions but no static checker is configured or enforced. Pyright already flags real issues: Optional values passed to os.path.join(), str | None to shlex.quote(), etc.

Implementation

Python (primary scope)

  1. Add pyrightconfig.json with strict mode
  2. Fix all violations — focus on security-critical paths first:
    • SSH command construction (remote_scanner.py, sshcp.py)
    • Path handling (os.path.join, file operations)
    • Config deserialization boundaries
    • Shell command building (lftp.py)
  3. Add Pyright check to CI as a required step
  4. Target: 0 errors enforced

Angular (secondary scope)

  • Replace ~12 any usages with typed interfaces for JSON parsing (e.g., RawModelFile interface for SSE event data)
  • Lower priority since strict mode is already enforced and blast radius of frontend type errors is smaller

Acceptance Criteria

  • pyrightconfig.json added with strict mode
  • 0 Pyright errors in Python codebase
  • CI step enforces Pyright (fails on any error)
  • Security-critical code paths fully typed (SSH, paths, shell commands, config)
  • Angular any usages replaced with typed interfaces

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonPull requests that update python coderefactorCode refactoring and cleanup

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions