Add mypy type checking and py.typed marker - #139
Merged
Conversation
Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
- Use TYPE_CHECKING to avoid importing native modules during type checking - Fix __exit__ to return None instead of bool - Initialize _last_frame_t as 0.0 instead of None - Add assertions for Optional[Backend] to ensure it's not None - Fix pytest.mark.skipif conditions with bool() - Unify capture_rgb signatures across platforms - Add type annotations to test files - Create mypy.ini with proper configuration - Update test_mypy.py to use --install-types flag Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
- Remove duplicate signal import and unused overload import - Initialize _last_frame_t to time.perf_counter() instead of 0.0 for correctness - Initialize _extra_time_per_frame as 0.0 explicitly Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add test for running mypy on source and test folders
Add mypy type checking and py.typed marker
Jan 30, 2026
letmaik
requested changes
Jan 30, 2026
- Combine test_mypy_source and test_mypy_tests into single test_mypy function - Remove unnecessary mypy config options and rely on defaults - Remove native module ignores (not needed with TYPE_CHECKING guards) - Add type annotations to all Camera.__init__ fields - Use local variable pattern to ensure _backend is never None after init - Use _closed flag instead of setting _backend to None in close() - Remove assertions that checked for None backend - Exclude test/win-dshow-capture from mypy checking - Add return type annotation to get_pybind_include.__str__ Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
letmaik
approved these changes
Jan 30, 2026
letmaik
marked this pull request as ready for review
January 30, 2026 01:24
letmaik
reviewed
Jan 30, 2026
letmaik
reviewed
Jan 30, 2026
- Calculate repo root from test file location using Path(__file__) - Run mypy with cwd set to repo root to find mypy.ini config - This ensures the test works correctly regardless of current working directory Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
8 tasks
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.
Add mypy type checking and py.typed marker
Plan:
Summary:
Successfully added mypy type checking to the project with:
--install-types --non-interactiveon both source and test folders__file__to work from any directory# type: ignorecomments馃挰 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.