Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validation): fix handling validation of subscribed generics #3519

Merged
merged 1 commit into from
May 24, 2024

Conversation

provinzkraut
Copy link
Member

@provinzkraut provinzkraut commented May 24, 2024

Fix a bug that would lead to a TypeError when subscribed generics were used in a route handler signature and subject to validation.

from typing import Generic, TypeVar
from litestar import get
from litestar.testing import create_test_client

T = TypeVar("T")

class Foo(Generic[T]):
    pass

async def provide_foo() -> Foo[str]:
    return Foo()

@get("/", dependencies={"foo": provide_foo})
async def something(foo: Foo[str]) -> None:
    return None

with create_test_client([something]) as client:
    client.get("/")

Copy link
Member

@cofin cofin left a comment

Choose a reason for hiding this comment

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

LGTM

@provinzkraut provinzkraut enabled auto-merge (squash) May 24, 2024 19:30
@provinzkraut provinzkraut disabled auto-merge May 24, 2024 19:31
@provinzkraut provinzkraut enabled auto-merge (squash) May 24, 2024 19:32
Copy link

Copy link

codecov bot commented May 24, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 98.28%. Comparing base (b6a640a) to head (e062ad6).

Files Patch % Lines
litestar/_signature/model.py 66.66% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3519      +/-   ##
==========================================
- Coverage   98.30%   98.28%   -0.02%     
==========================================
  Files         328      328              
  Lines       14876    14883       +7     
  Branches     2365     2367       +2     
==========================================
+ Hits        14624    14628       +4     
- Misses        115      116       +1     
- Partials      137      139       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

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

@provinzkraut provinzkraut disabled auto-merge May 24, 2024 19:36
@provinzkraut provinzkraut merged commit 9a3bd38 into main May 24, 2024
28 of 29 checks passed
@provinzkraut provinzkraut deleted the fix-decode-subscribed-generics branch May 24, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants