feat: add comprehensive type checking with mypy strict mode and pyright#20
Merged
feat: add comprehensive type checking with mypy strict mode and pyright#20
Conversation
- Upgrade mypy to strict mode with additional error codes (ignore-without-code, redundant-cast, truthy-bool, truthy-iterable, unused-awaitable) - Add pyright as a second type checker for comprehensive coverage - Configure pyright in strict mode with practical exceptions for third-party libraries lacking full stubs - Update CI to run both type checkers in parallel via matrix strategy - Fix CompletedProcess generic type parameter in cli.py - Add type: ignore comments for untyped posthog methods in telemetry.py - Update AGENTS.md documentation with new type checking setup The dual type checker approach catches different categories of issues: - mypy: The standard Python type checker, excellent for protocol validation - pyright: Microsoft's type checker, catches additional edge cases Both run in strict mode to enforce rigorous typing standards. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mldangelo
added a commit
that referenced
this pull request
Feb 24, 2026
…ht (#20) - Upgrade mypy to strict mode with additional error codes (ignore-without-code, redundant-cast, truthy-bool, truthy-iterable, unused-awaitable) - Add pyright as a second type checker for comprehensive coverage - Configure pyright in strict mode with practical exceptions for third-party libraries lacking full stubs - Update CI to run both type checkers in parallel via matrix strategy - Fix CompletedProcess generic type parameter in cli.py - Add type: ignore comments for untyped posthog methods in telemetry.py - Update AGENTS.md documentation with new type checking setup The dual type checker approach catches different categories of issues: - mypy: The standard Python type checker, excellent for protocol validation - pyright: Microsoft's type checker, catches additional edge cases Both run in strict mode to enforce rigorous typing standards. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the type checking infrastructure by:
ignore-without-code,redundant-cast,truthy-bool,truthy-iterable,unused-awaitable)Why Two Type Checkers?
mypy and pyright catch different categories of issues:
Running both provides defense-in-depth: errors caught by one may be missed by the other.
Configuration Details
mypy (strict mode + extras):
--strictenabledposthog.*module to ignore missing importspyright (strict mode with practical exceptions):
typeCheckingMode = "strict"type: ignorecommentsChanges
pyproject.toml: Enhanced mypy config, added pyright config and dependency.github/workflows/test.yml: Matrix strategy for parallel type checker executionsrc/promptfoo/cli.py: FixedCompletedProcessgeneric type parametersrc/promptfoo/telemetry.py: Addedtype: ignorefor untyped posthog methodsAGENTS.md: Updated documentation with new type checking setupuv.lock: Added pyright dependencyTest plan
uv run mypy src/promptfoo/anduv run pyright src/promptfoo/pass locally🤖 Generated with Claude Code