From e2f6abe5796645dde8490f2a8b602a8e4a9681ed Mon Sep 17 00:00:00 2001 From: proxy <51172302+3n-k1@users.noreply.github.com> Date: Wed, 28 Oct 2020 03:28:04 -0400 Subject: [PATCH] add additional failing test for ModelAdmin generic (#505) this will ensure that the generic constraint holds --- test-data/typecheck/contrib/admin/test_options.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test-data/typecheck/contrib/admin/test_options.yml b/test-data/typecheck/contrib/admin/test_options.yml index dee3d5e..aa205cd 100644 --- a/test-data/typecheck/contrib/admin/test_options.yml +++ b/test-data/typecheck/contrib/admin/test_options.yml @@ -136,3 +136,13 @@ class A(admin.ModelAdmin): actions = [an_action] # E: List item 0 has incompatible type "Callable[[None], None]"; expected "Union[Callable[[ModelAdmin[Any], HttpRequest, QuerySet[Any]], None], str]" +- case: errors_for_invalid_model_admin_generic + main: | + from django.contrib.admin import ModelAdmin + from django.db.models import Model + + class TestModel(Model): + pass + + class A(ModelAdmin[TestModel]): + model = int # E: Incompatible types in assignment (expression has type "Type[int]", base class "ModelAdmin" defined the type as "Type[TestModel]")