Skip to content

refactor: rename get_origin_or_inner_type to unwrap_and_get_origin#4618

Open
Br1an67 wants to merge 6 commits intolitestar-org:mainfrom
Br1an67:refactor/rename-get-origin-or-inner-type
Open

refactor: rename get_origin_or_inner_type to unwrap_and_get_origin#4618
Br1an67 wants to merge 6 commits intolitestar-org:mainfrom
Br1an67:refactor/rename-get-origin-or-inner-type

Conversation

@Br1an67
Copy link
Copy Markdown
Contributor

@Br1an67 Br1an67 commented Mar 1, 2026

Description

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, NotRequired, ReadOnly) and returning the instantiable origin type.

The old name is preserved as a deprecated alias that emits a DeprecationWarning when called, pointing users to the new name.

Changes:

  • Renamed get_origin_or_inner_typeunwrap_and_get_origin across 9 files
  • Updated all internal imports and usages
  • Added deprecated alias with warn_deprecation("3.0", ...)
  • Both names exported in __all__ for backward compatibility

Closes

Closes #2467


📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4618

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.89%. Comparing base (2613a77) to head (8bb6d9e).
⚠️ Report is 24 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 1, 2026

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4618

Copy link
Copy Markdown
Member

@provinzkraut provinzkraut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Br1an67 and others added 6 commits March 3, 2026 22:24
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>
@Br1an67 Br1an67 force-pushed the refactor/rename-get-origin-or-inner-type branch from 29905ac to 8bb6d9e Compare March 3, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: rename get_origin_or_inner_type in litestar.utils.typing to a less confusing name

2 participants