fix tests

This commit is contained in:
Maxim Kurnikov
2019-02-12 17:09:28 +03:00
parent 16a983152a
commit cf7c263fb5
3 changed files with 11 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ class User(models.Model):
age = models.IntegerField()
User.objects.create(name='Max', age=10)
User.objects.create(name=1010) # E: Incompatible type for "name" of "User" (got "int", expected "Union[str, Combinable]")
User.objects.create(age='hello') # E: Incompatible type for "age" of "User" (got "str", expected "Union[int, Combinable, Literal['']]")
[out]
[CASE model_recognises_parent_attributes]

View File

@@ -14,9 +14,9 @@ from django.db import models
class MyUser(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
user = MyUser(name=1, age=12)
user = MyUser(name='hello', age='world')
[out]
main:6: error: Incompatible type for "name" of "MyUser" (got "int", expected "Union[str, Combinable]")
main:6: error: Incompatible type for "age" of "MyUser" (got "str", expected "Union[int, Combinable, Literal['']]")
[CASE arguments_to_init_combined_from_base_classes]
from django.db import models
@@ -62,8 +62,8 @@ user3= MyUser2(pk=1)
from django.db import models
class MyUser1(models.Model):
mypk = models.CharField(primary_key=True)
user = MyUser1(pk=1) # E: Incompatible type for "pk" of "MyUser1" (got "int", expected "Union[str, Combinable]")
mypk = models.IntegerField(primary_key=True)
user = MyUser1(pk='hello') # E: Incompatible type for "pk" of "MyUser1" (got "str", expected "Union[int, Combinable, Literal['']]")
[out]
[CASE can_set_foreign_key_by_its_primary_key]
@@ -72,13 +72,13 @@ from django.db import models
class Publisher(models.Model):
pass
class PublisherWithCharPK(models.Model):
id = models.CharField(max_length=100, primary_key=True)
id = models.IntegerField(primary_key=True)
class Book(models.Model):
publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)
publisher_with_char_pk = models.ForeignKey(PublisherWithCharPK, on_delete=models.CASCADE)
Book(publisher_id=1, publisher_with_char_pk_id='hello')
Book(publisher_id=1, publisher_with_char_pk_id=1) # E: Incompatible type for "publisher_with_char_pk_id" of "Book" (got "int", expected "Union[str, Combinable]")
Book(publisher_id=1, publisher_with_char_pk_id=1)
Book(publisher_id=1, publisher_with_char_pk_id='hello') # E: Incompatible type for "publisher_with_char_pk_id" of "Book" (got "str", expected "Union[int, Combinable, Literal['']]")
[out]
[CASE setting_value_to_an_array_of_ints]
@@ -112,9 +112,9 @@ class MyModel(models.Model):
MyModel(1)
class MyModel2(models.Model):
name = models.CharField(max_length=100)
MyModel2(1, 'Maxim')
MyModel2(1, 12) # E: Incompatible type for "name" of "MyModel2" (got "int", expected "Union[str, Combinable]")
name = models.IntegerField()
MyModel2(1, 12)
MyModel2(1, 'Maxim') # E: Incompatible type for "name" of "MyModel2" (got "str", expected "Union[int, Combinable, Literal['']]")
[out]
[CASE arguments_passed_as_dictionary_unpacking_are_not_supported]