From 9d13593ff5857539b2d24c1b6fd715ca296ca44f Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Sun, 21 May 2023 00:39:09 +0300 Subject: [PATCH] Fix tests: revert (test_fieldset_workaround_regression) & update error message --- django-stubs/contrib/admin/options.pyi | 11 +++++++++-- tests/typecheck/db/migrations/test_operations.yml | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index be50a736b..ace77d7d5 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -1,5 +1,12 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence -from typing import Any, Generic, Literal, TypeVar, Union # noqa: Y037 # https://github.com/python/mypy/issues/12211 +from typing import ( # noqa: Y037 # https://github.com/python/mypy/issues/12211 + Any, + Generic, + Literal, + Optional, + TypeVar, + Union, +) from django import forms from django.contrib.admin.filters import FieldListFilter, ListFilter @@ -81,7 +88,7 @@ class BaseModelAdmin(Generic[_ModelT]): raw_id_fields: Sequence[str] fields: _FieldGroups | None exclude: Sequence[str] | None - fieldsets: _FieldsetSpec | None + fieldsets: Optional[_FieldsetSpec] # noqa: UP007 form: type[forms.ModelForm[_ModelT]] filter_vertical: Sequence[str] filter_horizontal: Sequence[str] diff --git a/tests/typecheck/db/migrations/test_operations.yml b/tests/typecheck/db/migrations/test_operations.yml index 7c830fb5c..825d584c4 100644 --- a/tests/typecheck/db/migrations/test_operations.yml +++ b/tests/typecheck/db/migrations/test_operations.yml @@ -16,5 +16,5 @@ RunSQL(sql=["SOME SQLS", ("SOME SQLS %s, %s", ["PARAM", "ANOTHER PARAM"])], reverse_sql=["SOME SQLS", ("SOME SQLS %s, %s", ["PARAM", "ANOTHER PARAM"])]) - RunSQL(sql=("SOME SQL", {})) # E: Argument "sql" to "RunSQL" has incompatible type "Tuple[str, Dict[, ]]"; expected "Union[str, Union[List[Union[str, Tuple[str, Union[Dict[str, Any], List[str], Tuple[str, ...], Tuple[], None]]]], Tuple[Union[str, Tuple[str, Union[Dict[str, Any], List[str], Tuple[str, ...], Tuple[], None]]], ...], Tuple[]]]" + RunSQL(sql=("SOME SQL", {})) # E: Argument "sql" to "RunSQL" has incompatible type "Tuple[str, Dict[, ]]"; expected "Union[str, Union[List[Union[str, Tuple[str, Union[Dict[str, Any], Union[List[str], Tuple[str, ...], Tuple[]], None]]]], Tuple[Union[str, Tuple[str, Union[Dict[str, Any], Union[List[str], Tuple[str, ...], Tuple[]], None]]], ...], Tuple[]]]" RunSQL(sql=["SOME SQLS", ("SOME SQLS %s, %s", [object(), "ANOTHER PARAM"])]) # E: List item 0 has incompatible type "object"; expected "str"