-
Notifications
You must be signed in to change notification settings - Fork 39
feat(mypy): enable comprehensive strict type checking across codebase #885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(mypy): enable comprehensive strict type checking across codebase #885
Conversation
Removes sdist.py and settings.py from mypy exclude list as these files no longer exist in the codebase. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Extends mypy configuration to include tests and e2e directories in mypy_path and updates hatch mypy environment to check all three directories for comprehensive type checking coverage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Enables check_untyped_defs to check function bodies even without type annotations. Added exclusions for problematic e2e directories (build directories and pyo3_test with missing imports). All existing code passes this check without requiring fixes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Enables disallow_incomplete_defs to require complete type annotations on function signatures. Fixed all issues in source code including: - Added missing return type annotations - Added missing parameter type annotations - Fixed incompatible type issues in packagesettings.py - Corrected return type for _add_node in dependency_graph.py Source code now passes strict incomplete definition checking. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Enables disallow_untyped_defs to require type annotations on all function definitions. Fixed all issues in source code including: - Added missing return type annotations (-> None for void functions) - Added missing parameter type annotations - Fixed BaseException vs Exception type for _format_exception - Updated pydantic field validator with proper typing Source code now passes strict untyped definition checking. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add explicit type annotations to resolve 'returning Any' warnings: - finders.py: Add explicit pathlib.Path annotations for variables - wheels.py: Add explicit pathlib.Path annotation for new_wheel_file - bootstrapper.py: Add explicit pathlib.Path annotation for sdist_filename - bootstrapper.py: Add return type annotation for _create_unpack_dir 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Remove sources.py and commands/build.py from mypy exclude list. Fix all type annotation issues in previously excluded files: sources.py: - Add null check for download URL - Fix return types for _download_source_check and nested functions - Fix function parameter and return type annotations - Handle Version|None sorting in patch map iteration - Convert Path arguments to str for external commands - Add explicit type annotations to resolve Any returns commands/build.py: - Add type annotations for dict_factory and _create_table functions - Add proper typing for **kwargs parameters All source files now pass strict mypy type checking. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
… parameter
The serialize() method should default to a frozenset as it was before.
- Change exclude parameter type to set[str] | frozenset[str]
- Default to frozenset({'name', 'has_config'})
- Convert frozenset to set when calling model_dump() to satisfy Pydantic's IncEx type
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Remove the instructions to the agent to use type annotations. We can rely on the linter to catch issues.
- Add scripts/pre-commit hook that runs lint:check and mypy:check - Add scripts/setup-pre-commit-hook.sh for easy installation - Update CONTRIBUTING.md with setup and usage instructions - Ensures all commits pass quality checks before being created Co-Authored-By: Claude <[email protected]>
30780e9 to
012052c
Compare
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ All pre-commit checks passed!" No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick, we should add a new line at the end of file. Without it it messes up some editors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will come back and add a separate linter to enforce that in another PR.
| echo "before every commit to ensure code quality." | ||
| echo "" | ||
| echo "To bypass the hook for a specific commit (not recommended):" | ||
| echo " git commit --no-verify -m \"message\"" No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick, we should add a new line at the end of file.
|
Overall, this is awesome. |
Summary
This PR enables comprehensive strict mypy type checking across the entire fromager codebase through an incremental approach. Each strict checking option was enabled in separate commits with corresponding fixes.
Changes Made
tests/ande2e/directories to mypy checkingcheck_untyped_defs = truedisallow_incomplete_defs = truedisallow_untyped_defs = truewarn_return_any = truesources.pyandcommands/build.pynow pass strict checkingTesting
All mypy checks now pass with zero errors:
Success: no issues found in 54 source files🤖 Generated with Claude Code