mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-01-26 04:46:47 +08:00
Disable monkeypatches, add dependencies via new hook (#60)
* code cleanups, disable monkeypatches, move to add_additional_deps * disable incremental mode for tests * add pip-wheel-metadata * move some code from get_base_hook to get_attribute_hook to reduce dependencies * simplify values/values_list tests and code * disable cache for some tests failing with incremental mode * enable incremental mode for tests typechecking * pin mypy version * fix tests * lint * fix internal crashes
This commit is contained in:
@@ -33,7 +33,7 @@ class User(models.Model):
|
||||
text = models.TextField()
|
||||
|
||||
user = User()
|
||||
reveal_type(user.id) # E: Revealed type is 'builtins.int*'
|
||||
reveal_type(user.id) # E: Revealed type is 'builtins.int'
|
||||
reveal_type(user.small_int) # E: Revealed type is 'builtins.int*'
|
||||
reveal_type(user.name) # E: Revealed type is 'builtins.str*'
|
||||
reveal_type(user.slug) # E: Revealed type is 'builtins.str*'
|
||||
@@ -51,7 +51,7 @@ class Booking(models.Model):
|
||||
some_decimal = models.DecimalField(max_digits=10, decimal_places=5)
|
||||
|
||||
booking = Booking()
|
||||
reveal_type(booking.id) # E: Revealed type is 'builtins.int*'
|
||||
reveal_type(booking.id) # E: Revealed type is 'builtins.int'
|
||||
reveal_type(booking.time_range) # E: Revealed type is 'Any'
|
||||
reveal_type(booking.some_decimal) # E: Revealed type is 'decimal.Decimal*'
|
||||
[/CASE]
|
||||
@@ -72,7 +72,10 @@ class User(models.Model):
|
||||
my_pk = models.IntegerField(primary_key=True)
|
||||
|
||||
reveal_type(User().my_pk) # E: Revealed type is 'builtins.int*'
|
||||
reveal_type(User().id) # E: Revealed type is 'Any'
|
||||
reveal_type(User().id)
|
||||
[out]
|
||||
main:7: error: Revealed type is 'Any'
|
||||
main:7: error: Default primary key 'id' is not defined
|
||||
[/CASE]
|
||||
|
||||
[CASE test_meta_nested_class_allows_subclassing_in_multiple_inheritance]
|
||||
@@ -100,6 +103,16 @@ class User(Abstract):
|
||||
id = models.AutoField(primary_key=True)
|
||||
[/CASE]
|
||||
|
||||
[CASE test_primary_key_on_optional_queryset_method]
|
||||
from django.db import models
|
||||
class User(models.Model):
|
||||
pass
|
||||
reveal_type(User.objects.first().id)
|
||||
[out]
|
||||
main:4: error: Revealed type is 'Any'
|
||||
main:4: error: Item "None" of "Optional[User]" has no attribute "id"
|
||||
[/CASE]
|
||||
|
||||
[CASE standard_it_from_parent_model_could_be_overridden_with_non_integer_field_in_child_model]
|
||||
from django.db import models
|
||||
import uuid
|
||||
@@ -107,7 +120,7 @@ class ParentModel(models.Model):
|
||||
pass
|
||||
class MyModel(ParentModel):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
reveal_type(MyModel().id) # E: Revealed type is 'uuid.UUID*'
|
||||
reveal_type(MyModel().id) # E: Revealed type is 'uuid.UUID'
|
||||
[/CASE]
|
||||
|
||||
[CASE blank_and_null_char_field_allows_none]
|
||||
|
||||
Reference in New Issue
Block a user