Skip to content

Conversation

@ashwinb
Copy link
Contributor

@ashwinb ashwinb commented Oct 28, 2025

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).

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 28, 2025
@ashwinb ashwinb changed the title chore: add type_checking dependency group for complete mypy coverage chore/fix(mypy): add type stubs and fix typing issues Oct 28, 2025
@ashwinb ashwinb changed the title chore/fix(mypy): add type stubs and fix typing issues fix(mypy): add type stubs and fix typing issues Oct 28, 2025
Copy link
Collaborator

@leseb leseb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the ignore, we should just leave an explanation either in code or in commit message, thanks!

@ashwinb ashwinb force-pushed the phase-2g-add-type-checking-deps branch from e7179e8 to 021e669 Compare October 28, 2025 16:40
@ashwinb ashwinb force-pushed the phase-2f-fix-openai-boto3-types branch 3 times, most recently from 675b005 to 99380de Compare October 28, 2025 17:48
Base automatically changed from phase-2f-fix-openai-boto3-types to main October 28, 2025 17:54
ashwinb and others added 6 commits October 28, 2025 10:55
Create a new type_checking dependency group that includes:
- All type stubs (moved from dev group for better organization)
- Optional runtime dependencies needed for complete mypy coverage
  (streamlit, anthropic, databricks-sdk, fairscale, torchtune, etc.)

This reduces mypy errors from 73 to 59 by providing proper type information
for all optional features. The dev group is now cleaner with only actual
development tools.

To run mypy with full type coverage:
  uv run --group dev --group type_checking mypy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add lm-format-enforcer to type_checking dependencies and update the
pre-commit mypy hook to use local repo with uv run --group dev --group
type_checking for better integration with dependency groups.

This reduces mypy errors from 73 to 58 (one additional error fixed).
… files

This commit achieves zero mypy errors across all 430 source files by addressing type issues in post-training providers, model implementations, and testing infrastructure.

Key changes:
- Created HFAutoModel Protocol for HuggingFace models to provide type safety without requiring complete type stubs
- Added module overrides in pyproject.toml for libraries lacking type stubs (torchtune, fairscale, torchvision, datasets, etc.)
- Fixed type issues in databricks provider and api_recorder

Using centralized mypy.overrides instead of scattered inline suppressions provides cleaner code organization.
@ashwinb ashwinb force-pushed the phase-2g-add-type-checking-deps branch from 021e669 to d112e63 Compare October 28, 2025 17:55
@ashwinb ashwinb merged commit 94b0592 into main Oct 28, 2025
68 checks passed
@ashwinb ashwinb deleted the phase-2g-add-type-checking-deps branch October 28, 2025 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants