Skip to content

Commit

Permalink
Merge pull request #3772 from Viicos/patch-1
Browse files Browse the repository at this point in the history
Make return type of `from_model` parameterized with respect to `model`
  • Loading branch information
Zac-HD committed Oct 16, 2023
2 parents a331d3e + b6af2b2 commit ca63e9f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/extra/django/_impl.py
Expand Up @@ -11,7 +11,7 @@
import sys
import unittest
from functools import partial
from typing import TYPE_CHECKING, Optional, Type, Union
from typing import TYPE_CHECKING, Optional, Type, TypeVar, Union

from django import forms as df, test as dt
from django.contrib.staticfiles import testing as dst
Expand All @@ -30,6 +30,8 @@
else:
EllipsisType = type(Ellipsis)

ModelT = TypeVar("ModelT", bound=dm.Model)


class HypothesisTestCase:
def setup_example(self):
Expand Down Expand Up @@ -64,8 +66,8 @@ class StaticLiveServerTestCase(HypothesisTestCase, dst.StaticLiveServerTestCase)

@defines_strategy()
def from_model(
model: Type[dm.Model], /, **field_strategies: Union[st.SearchStrategy, EllipsisType]
) -> st.SearchStrategy:
model: Type[ModelT], /, **field_strategies: Union[st.SearchStrategy, EllipsisType]
) -> st.SearchStrategy[ModelT]:
"""Return a strategy for examples of ``model``.
.. warning::
Expand Down

0 comments on commit ca63e9f

Please sign in to comment.