feat: Add type hints to public API - #136
Merged
Merged
Conversation
- Replace unittest2 (Python 2 backport) with pytest - Replace coverage with pytest-cov - Remove mock dependency (built into Python 3.3+) - Add pytest configuration to pyproject.toml - Update CI workflow to use pytest - Update CONTRIBUTING.MD with pytest commands - Mark functional tests to skip when RAYGUN_API_KEY not set - Refactor global variable tests to use direct injection instead of relying on module globals (fixes pytest compatibility)
The standalone mock package was removed as a dependency since it's built into Python 3.3+. Updated remaining test files that were still using the external import.
Add comprehensive type annotations to the core public API: - raygunprovider.py: RaygunSender, RaygunHandler with full type hints - raygunmsgs.py: RaygunMessage, RaygunMessageBuilder, RaygunErrorMessage - utilities.py: All utility functions typed - http_utilities.py: HTTP request handling typed Also includes: - py.typed marker for PEP 561 compliance - mypy configuration in pyproject.toml - mypy and types-requests added to dev dependencies Type checking is currently enabled for the core modules only. Middleware and CLI are excluded pending future work.
TheRealAgentK
requested review from
ProRedCat,
Copilot,
miquelbeltran and
sumitramanga
January 18, 2026 04:54
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive type hints to the core public API of the raygun4py library, improving IDE support, static analysis capabilities, and overall developer experience.
Changes:
- Added type annotations to core modules (
raygunprovider.py,raygunmsgs.py,utilities.py,http_utilities.py) - Configured mypy for static type checking with strict settings
- Migrated test infrastructure from unittest to pytest with coverage support
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python3/tests/test_raygunmsgs.py | Refactored tests to directly inject global variables instead of using actual globals, improving test isolation |
| python3/tests/test_functional.py | Replaced unittest-based skip logic with pytest decorator |
| python3/tests/middleware/test_wsgi.py | Updated mock import to use standard library's unittest.mock |
| python3/tests/middleware/test_django.py | Updated mock import to use standard library's unittest.mock |
| python3/raygun4py/utilities.py | Added comprehensive type hints with forward references |
| python3/raygun4py/raygunprovider.py | Added type hints to all methods and introduced type aliases for clarity |
| python3/raygun4py/raygunmsgs.py | Added type hints to message classes and builder pattern |
| python3/raygun4py/http_utilities.py | Added type hints to HTTP utility functions |
| pyproject.toml | Added mypy configuration and migrated from unittest2 to pytest |
| CONTRIBUTING.MD | Updated testing instructions to use pytest |
| .github/workflows/python-checks.yml | Updated CI to use pytest instead of unittest |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jan 18, 2026
ProRedCat
approved these changes
Jan 19, 2026
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
Add comprehensive type annotations to the core public API for improved AI/IDE support, static analysis, and developer experience.
NOTE: This PR is based on the changes in PR #125 (because I anticipated that there would be changes to tests required).
Changes
Type-annotated modules:
raygunprovider.py-RaygunSender,RaygunHandlerwith full type hintsraygunmsgs.py-RaygunMessage,RaygunMessageBuilder,RaygunErrorMessageutilities.py- All utility functions typedhttp_utilities.py- HTTP request handling typedInfrastructure:
py.typedmarker for PEP 561 compliancepyproject.tomlmypyandtypes-requeststo dev dependenciesTesting
Future work
Type hints for middleware (Flask, Django, WSGI) and CLI are planned for a follow-up PR.
Closes #135