new experimental optype.test module#544
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new experimental optype.test module that provides type-check only utilities for testing static types. The module is stub-only (.pyi file) and is not available at runtime, following the intended design for type-checking utilities. The module currently contains a single utility, assert_subtype, which provides a flexible alternative to typing.assert_type for writing type-tests compatible with multiple type checkers.
Changes:
- Added new experimental
optype.testmodule withassert_subtypeutility for type-checking - Updated documentation and configuration to include the new experimental module
- Added comprehensive tests in stub format to verify the type-checking behavior
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
optype/test.pyi |
New stub-only module implementing assert_subtype as a generic class with @type_check_only decorator |
optype/__init__.pyi |
Added test module to imports and __all__ list for type-checking support |
tests/test_test.pyi |
Added type-checking tests covering valid subtypes and invalid cases with proper type-ignore annotations |
docs/reference/experimental/test.md |
Added comprehensive documentation explaining the experimental nature, usage, and examples |
zensical.toml |
Added experimental test module to documentation navigation structure |
.github/labeler.yml |
Added labeler configuration for optype.test module (but with incorrect file extension) |
Comments suppressed due to low confidence (2)
.github/labeler.yml:88
- The labeler configuration references
optype/test.py, but the module is implemented asoptype/test.pyi(a stub-only file). This configuration won't match changes to the actual file. The path should be changed tooptype/test.pyito correctly trigger the label when this file is modified.
optype.test:
- changed-files:
- any-glob-to-any-file:
- optype/test.py
docs/reference/experimental/test.md:38
- Inconsistent spacing before inline comments. Line 36 has a space before the comment
# (1)!, but lines 37-38 lack this space (#(2)!and#(3)!). For consistency, all three lines should have the same spacing convention - either all with a space or all without.
assert_subtype[int](True) # (1)!
assert_subtype[int](1) #(2)!
assert_subtype[int](1.0) #(3)!
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.
It's type-check only, experimental, and only contains
assert_subtypefor now.