Skip to content

Commit ca63e9f

Browse files
authored
Merge pull request #3772 from Viicos/patch-1
Make return type of `from_model` parameterized with respect to `model`
2 parents a331d3e + b6af2b2 commit ca63e9f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • hypothesis-python/src/hypothesis/extra/django

hypothesis-python/src/hypothesis/extra/django/_impl.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import sys
1212
import unittest
1313
from functools import partial
14-
from typing import TYPE_CHECKING, Optional, Type, Union
14+
from typing import TYPE_CHECKING, Optional, Type, TypeVar, Union
1515

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

33+
ModelT = TypeVar("ModelT", bound=dm.Model)
34+
3335

3436
class HypothesisTestCase:
3537
def setup_example(self):
@@ -64,8 +66,8 @@ class StaticLiveServerTestCase(HypothesisTestCase, dst.StaticLiveServerTestCase)
6466

6567
@defines_strategy()
6668
def from_model(
67-
model: Type[dm.Model], /, **field_strategies: Union[st.SearchStrategy, EllipsisType]
68-
) -> st.SearchStrategy:
69+
model: Type[ModelT], /, **field_strategies: Union[st.SearchStrategy, EllipsisType]
70+
) -> st.SearchStrategy[ModelT]:
6971
"""Return a strategy for examples of ``model``.
7072
7173
.. warning::

0 commit comments

Comments
 (0)