Skip to content

Commit b0de008

Browse files
committed
Fix issues due to variable override checking changes
Bisected to python/mypy#18847 Some of these look valid, others might be due to bugs, e.g. duplicate note output that might need to be fixed in mypy?
1 parent 2b77f23 commit b0de008

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

tests/typecheck/contrib/admin/test_options.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
class TestModel(models.Model):
1919
pass
2020
21+
class TestModelForm(ModelForm[TestModel]):
22+
pass
23+
2124
class A(admin.ModelAdmin[TestModel]):
2225
# BaseModelAdmin
2326
autocomplete_fields = ("strs",)
@@ -32,7 +35,7 @@
3235
("group", {"fields": ("c",), "classes": ("a",), "description": "foo"}),
3336
(_("lazy"), {"fields": ["bar"]})
3437
]
35-
form = ModelForm
38+
form = TestModelForm
3639
filter_vertical = ("fields",)
3740
filter_horizontal = ("plenty", "of", "fields")
3841
radio_fields = {

tests/typecheck/db/models/test_fields_choices.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
main:4: note: def __iter__(self) -> Iterator[Union[Tuple[Any, Any], Tuple[str, Iterable[Tuple[Any, Any]]]]]
1212
main:4: note: Got:
1313
main:4: note: def __iter__(self) -> Iterator[str]
14+
main:4: note: Expected:
15+
main:4: note: def __iter__(self) -> Iterator[Union[Tuple[Any, Any], Tuple[str, Iterable[Tuple[Any, Any]]]]]
16+
main:4: note: Got:
17+
main:4: note: def __iter__(self) -> Iterator[str]
1418
1519
- case: db_models_integerfield_invalid_choices
1620
main: |
@@ -25,6 +29,10 @@
2529
main:4: note: def __iter__(self) -> Iterator[Union[Tuple[Any, Any], Tuple[str, Iterable[Tuple[Any, Any]]]]]
2630
main:4: note: Got:
2731
main:4: note: def __iter__(self) -> Iterator[str]
32+
main:4: note: Expected:
33+
main:4: note: def __iter__(self) -> Iterator[Union[Tuple[Any, Any], Tuple[str, Iterable[Tuple[Any, Any]]]]]
34+
main:4: note: Got:
35+
main:4: note: def __iter__(self) -> Iterator[str]
2836
2937
- case: db_models_valid_choices
3038
main: |

tests/typecheck/fields/test_related.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,10 @@
779779
- case: resolve_primary_keys_for_foreign_keys_with_abstract_self_model
780780
main: |
781781
from myapp.models import User
782-
reveal_type(User().parent) # N: Revealed type is "myapp.models.User"
782+
reveal_type(User().parent) # N: Revealed type is "myapp.models.AbstractUser"
783783
reveal_type(User().parent_id) # N: Revealed type is "builtins.int"
784784
785-
reveal_type(User().parent2) # N: Revealed type is "Union[myapp.models.User, None]"
785+
reveal_type(User().parent2) # N: Revealed type is "Union[myapp.models.AbstractUser, None]"
786786
reveal_type(User().parent2_id) # N: Revealed type is "Union[builtins.int, None]"
787787
installed_apps:
788788
- myapp

tests/typecheck/models/test_meta_options.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
class Meta(TypedModelMeta):
6767
abstract = 7 # E: Incompatible types in assignment (expression has type "int", base class "TypedModelMeta" defined the type as "bool") [assignment]
6868
verbose_name = ['test'] # E: Incompatible types in assignment (expression has type "List[str]", base class "TypedModelMeta" defined the type as "Union[str, _StrPromise]") [assignment]
69-
unique_together = {1: 2} # E: Incompatible types in assignment (expression has type "Dict[int, int]", base class "TypedModelMeta" defined the type as "Union[Sequence[Sequence[str]], Sequence[str]]") [assignment]
69+
unique_together = {1: 2} # E: Incompatible types in assignment (expression has type "Dict[int, int]", base class "TypedModelMeta" defined the type as "Sequence[Sequence[str]]") [assignment]
7070
unknown_attr = True # can't check this
7171
7272

0 commit comments

Comments
 (0)