fix(mypy): add type stubs and fix typing issues (#3938)

Adds type stubs and fixes mypy errors for better type coverage.

Changes:
- Added type_checking dependency group with type stubs (torchtune, trl,
etc.)
- Added lm-format-enforcer to pre-commit hook
- Created HFAutoModel Protocol for type-safe HuggingFace model handling
- Added mypy.overrides for untyped libraries (torchtune, fairscale,
etc.)
- Fixed type issues in post-training providers, databricks, and
api_recorder

Note: ~1,200 errors remain in excluded files (see pyproject.toml exclude
list).

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Ashwin Bharambe 2025-10-28 11:00:09 -07:00 committed by GitHub
parent 1d385b5b75
commit 94b0592240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 487 additions and 68 deletions

View file

@ -57,18 +57,17 @@ repos:
hooks:
- id: uv-lock
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.1
- repo: local
hooks:
- id: mypy
name: mypy
additional_dependencies:
- uv==0.6.2
- mypy
- pytest
- rich
- types-requests
- pydantic
- uv==0.7.8
entry: uv run --group dev --group type_checking mypy
language: python
types: [python]
pass_filenames: false
require_serial: true
# - repo: https://github.com/tcort/markdown-link-check
# rev: v3.11.2