mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 20:54:29 +08:00
add support for models defined in the same module be specified as name of class in related fields
This commit is contained in:
@@ -274,4 +274,14 @@ Book2(publisher_id=1)
|
||||
Book2(publisher_id='hello') # E: Incompatible type for "publisher_id" of "Book2" (got "str", expected "Union[int, Combinable, Literal[''], None]")
|
||||
Book2.objects.create(publisher_id=1)
|
||||
Book2.objects.create(publisher_id='hello') # E: Incompatible type for "publisher_id" of "Book2" (got "str", expected "Union[int, Combinable, Literal['']]")
|
||||
[out]
|
||||
[out]
|
||||
|
||||
[CASE if_model_is_defined_as_name_of_the_class_look_for_it_in_the_same_file]
|
||||
from django.db import models
|
||||
|
||||
class Book(models.Model):
|
||||
publisher = models.ForeignKey(to='Publisher', on_delete=models.CASCADE)
|
||||
class Publisher(models.Model):
|
||||
pass
|
||||
reveal_type(Book().publisher) # E: Revealed type is 'main.Publisher*'
|
||||
[out]
|
||||
|
||||
Reference in New Issue
Block a user