fix: make type annotations runtime-safe for bear-type compatibility#4973
Draft
mayankansys wants to merge 18 commits intomainfrom
Draft
fix: make type annotations runtime-safe for bear-type compatibility#4973mayankansys wants to merge 18 commits intomainfrom
mayankansys wants to merge 18 commits intomainfrom
Conversation
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.
Context
Several function signatures across the codebase annotated parameters as
(Type = None)without includingNonein the type union. Static type-checkers like mypy accept this pattern silently, but runtime type-checkers such as beartype reject it — becauseNoneis not a valid instance ofTypeat evaluation time.Change Summary
Annotations for all parameters defaulting to
Nonewere corrected to explicitly includeNonein their type(Type | None = None). The code generation template was updated to emit the corrected form. Deprecation decorators were hardened to preserve original function signatures through wrapper layers. Regression tests were added to guard against future regressions.Impact
Runtime type-checking libraries can now be activated on the project without annotation-related failures. Introspection-based tooling (IDEs, documentation generators) will see accurate function signatures for decorated functions. Future code generation runs will automatically produce correct annotations.