Skip to content

Add mypy type checking and py.typed marker - #139

Merged
letmaik merged 7 commits into
mainfrom
copilot/add-mypy-test-and-marker-file
Jan 30, 2026
Merged

Add mypy type checking and py.typed marker#139
letmaik merged 7 commits into
mainfrom
copilot/add-mypy-test-and-marker-file

Conversation

Copilot AI commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Add mypy type checking and py.typed marker

Plan:

  • Add mypy to dev-requirements.txt
  • Create py.typed marker file in pyvirtualcam/ package directory
  • Update setup.py to include py.typed in package_data
  • Create test_mypy.py to run mypy on source and test folders
  • Fix type annotations in source code (no type: ignore comments)
  • Create mypy.ini configuration file
  • Test the mypy integration
  • Verify types are picked up by IDEs
  • Address all PR review feedback

Summary:

Successfully added mypy type checking to the project with:

  • Single test function that runs mypy with --install-types --non-interactive on both source and test folders
  • Test uses absolute paths based on __file__ to work from any directory
  • py.typed marker file properly configured in setup.py for IDE type discovery
  • Clean type annotations without using any # type: ignore comments
  • Minimal mypy.ini configuration with just python_version and necessary import ignores
  • Fully typed Camera.init with all fields annotated
  • Backend guaranteed to be non-None after initialization using local variable pattern

馃挰 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 30, 2026 00:58
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
Copilot AI requested a review from letmaik January 30, 2026 01:10
Comment thread test/test_mypy.py Outdated
Comment thread mypy.ini Outdated
Comment thread mypy.ini Outdated
Comment thread mypy.ini
Comment thread pyvirtualcam/camera.py Outdated
- 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>
Copilot AI requested a review from letmaik January 30, 2026 01:23
@letmaik
letmaik marked this pull request as ready for review January 30, 2026 01:24
Comment thread test/test_mypy.py Outdated
Comment thread test/test_mypy.py Outdated
- 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>
Copilot AI requested a review from letmaik January 30, 2026 09:04
@letmaik
letmaik merged commit 54f2881 into main Jan 30, 2026
100 checks passed
@letmaik
letmaik deleted the copilot/add-mypy-test-and-marker-file branch January 30, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants