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

Make return type of from_model parameterized with respect to model #3772

Merged
merged 1 commit into from Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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