refactor: rename get_origin_or_inner_type to unwrap_and_get_origin#4618
Open
Br1an67 wants to merge 6 commits intolitestar-org:mainfrom
Open
refactor: rename get_origin_or_inner_type to unwrap_and_get_origin#4618Br1an67 wants to merge 6 commits intolitestar-org:mainfrom
Br1an67 wants to merge 6 commits intolitestar-org:mainfrom
Conversation
Open
4 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4618 +/- ##
==========================================
+ Coverage 97.88% 97.89% +0.01%
==========================================
Files 298 298
Lines 15375 15379 +4
Branches 1730 1730
==========================================
+ Hits 15050 15056 +6
Misses 184 184
+ Partials 141 139 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4618 |
provinzkraut
reviewed
Mar 1, 2026
Rename the confusingly named get_origin_or_inner_type function to unwrap_and_get_origin, which better describes its behavior of unwrapping wrapper types (Annotated, Required, etc.) and returning the instantiable origin type. The old name is kept as a deprecated alias that emits a deprecation warning when called. This change was discussed in litestar-org#2463 review comments.
- Fix alphabetical ordering of imports in pydantic/utils.py, utils/__init__.py, and test_typing.py - Collapse multi-line expression in predicates.py to satisfy formatter - Add test for deprecated get_origin_or_inner_type alias to improve coverage
These two branches had partial coverage before the rename — Python flattens nested Literals so the True branch in _iter_flat_literal_args is unreachable, and the else branch in _deserializer's TypeError handler is a rare edge case. Adding pragma: no branch to satisfy codecov patch coverage requirements.
Move the lazy import of warn_deprecation in get_origin_or_inner_type to the top-level imports to avoid unnecessary performance penalty on each call. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
29905ac to
8bb6d9e
Compare
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.
Description
Rename the confusingly named
get_origin_or_inner_typefunction tounwrap_and_get_origin, which better describes its behavior of unwrapping wrapper types (Annotated,Required,NotRequired,ReadOnly) and returning the instantiable origin type.The old name is preserved as a deprecated alias that emits a
DeprecationWarningwhen called, pointing users to the new name.Changes:
get_origin_or_inner_type→unwrap_and_get_originacross 9 fileswarn_deprecation("3.0", ...)__all__for backward compatibilityCloses
Closes #2467
📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4618