Skip to content

[chore]: cleanup! achieve full mypy type coverage / fix linting (finally)#161

Open
archae0pteryx wants to merge 29 commits intomainfrom
fix/full-type-coverage
Open

[chore]: cleanup! achieve full mypy type coverage / fix linting (finally)#161
archae0pteryx wants to merge 29 commits intomainfrom
fix/full-type-coverage

Conversation

@archae0pteryx
Copy link
Contributor

@archae0pteryx archae0pteryx commented Jan 28, 2026

Summary

  • Achieve 100% mypy type coverage (0 errors) across 68 source files
  • Remove || true error suppression from typecheck task
  • Enable ruff linting for full codebase
  • Add TODO.md to track technical debt

Changes

Type System Improvements

  • Configure mypy to use uv run for access to installed package types
  • Add generic TypeVar to run_coro_thread_save for proper return type inference
  • Fix implicit optional parameters (PEP 484 compliance)
  • Add explicit type annotations to list variables and class attributes
  • Convert WorkerClientSession to Protocol for interface typing
  • Fix Pydantic discriminated union inheritance pattern

Code Quality

  • Remove ~50 obsolete type: ignore comments
  • Fix unreachable code in jobs.py, worker_jobs.py, visualize.py
  • Fix callback types to use Coroutine for async callbacks
  • Change return types from _RequestContextManager to ClientResponse

Configuration

  • Enable ruff linting for full codebase (removed exclude = ["*"])
  • Add mypy ignore rules only for packages without stubs (matplotlib, pyarrow, etc.)
  • Configure pyright with global suppressions for Pydantic discriminated union pattern

Documentation

  • Add TODO.md documenting technical debt (Pydantic anti-pattern for future refactoring)

Test plan

  • task typecheck passes with 0 errors
  • task test - 112 tests passing
  • task lint:all passes
  • uvx pyright - 0 errors

- Use uv run mypy instead of uvx to access installed packages
- Add ignore_missing_imports for packages without stubs (matplotlib, pyarrow, etc.)
- Add pandas-stubs to dev dependencies
- Add endpoint type annotation for DataEndpoint
- Remove obsolete type: ignore comments
- Fix ground_truth parameter type to match DataEndpoint signature
- Add endpoint type annotation for WorkerEndpoint
- Fix return types on async methods (WorkerJob, not WorkerJob | SyncWorkerJob)
Remove Literal from BaseComponent.type to allow subclass narrowing
- Allow None for prediction parameter
- Add type annotation for label variable
- Inline Polygon patches to avoid type conflicts with Rectangle
- Fix unreachable code in jobs.py, worker_jobs.py, data_jobs.py
- Fix callback types to use Coroutine for async callbacks
- Fix variable reassignment type conflicts in data_top_k.py
- Add null checks and type annotations in endpoint.py
- Change return types from _RequestContextManager to ClientResponse
- Convert WorkerClientSession to Protocol for interface typing
- Add null checks and type annotations in worker_endpoint.py
- Fix return types to ClientResponse
- Fix var-annotated errors in predictions.py and annotations.py
- Fix return types in data_endpoint.py (ClientResponse, StreamReader)
- Fix callback types to use Coroutine for async callbacks
- Add type annotations in request_tracer.py, periodic.py, metrics.py
- Fix session return type in syncify.py
- Fix Asset.annotations to handle None return from annotations parser
- Remove duplicate JobState enum in metrics.py
Type coverage is now complete with 0 mypy errors
Remove exclude=["*"] to lint all Python files
@archae0pteryx archae0pteryx changed the title feat: achieve full mypy type coverage [chore]: cleanup! achieve full mypy type coverage / fix linting (finally) Jan 28, 2026
- Remove unused `Enum` import from metrics.py
- Remove unused `SyncWorkerJob` import from worker_endpoint.py
- Rename `job` to `_job` in metrics.py loop (B007)
- Rename unused variable source_model_uuid to _source_model_uuid (F841)
- Sort imports in data_endpoint.py (I001)
- Add D105 to ruff.toml ignore list (missing magic method docstrings)
- Remove unused imports from endpoint.py (CallableABC, _RequestContextManager)
- Sort imports in endpoint.py
- Fix list type annotations in assets.py using cast() for [None] * len() pattern
- Add null check for client_session.close() in endpoint.py
- Use lambdas instead of methods for open_stream in worker_jobs.py
- Disable reportIncompatibleVariableOverride in pyrightconfig.json for Pydantic discriminated union pattern
- Fix typo: sinc → since in assets.py comments
- Remove duplicate pyright config from pyproject.toml (already in pyrightconfig.json)
- Remove inline pyright ignore comments (covered by global config)
- Remove commented-out exclude line from ruff.toml
Document Pydantic discriminated union inheritance anti-pattern for future refactoring
CI uses basedpyright which reads config from pyproject.toml.
Remove separate pyrightconfig.json to have single source of truth.
@archae0pteryx archae0pteryx force-pushed the fix/full-type-coverage branch from 31fc0db to 1ab7ae7 Compare January 28, 2026 22:17
- Remove `type` field from BaseComponent to avoid inheritance type conflict
- Each subclass now defines its own `type: Literal[...]` field independently
- Remove unnecessary pyright suppressions (no longer needed)
- Move pyright config to pyproject.toml for CI compatibility
- Delete TODO.md since the issue is properly fixed
Only trigger checks workflow on:
- Pushes directly to main branch
- Pull requests targeting main branch

This prevents duplicate runs when pushing to a PR branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant