mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-02-28 12:32:21 +08:00
Model.__init__ supporting same typing as assigment (#835)
* `Model.__init__` supporting same typing as assigment * Update mypy_django_plugin/django/context.py
This commit is contained in:
19
tests/typecheck/contrib/postgres/test_fields.yml
Normal file
19
tests/typecheck/contrib/postgres/test_fields.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
- case: union_combinable_reduced_to_non_union
|
||||
main: |
|
||||
from typing import List
|
||||
from myapp.models import MyModel
|
||||
array_val: List[int] = [1]
|
||||
MyModel(array=array_val) # E: Incompatible type for "array" of "MyModel" (got "List[int]", expected "Union[Sequence[str], Combinable]")
|
||||
non_init = MyModel()
|
||||
non_init.array = array_val # E: Incompatible types in assignment (expression has type "List[int]", variable has type "Union[Sequence[str], Combinable]")
|
||||
installed_apps:
|
||||
- myapp
|
||||
files:
|
||||
- path: myapp/__init__.py
|
||||
- path: myapp/models.py
|
||||
content: |
|
||||
from django.db import models
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
|
||||
class MyModel(models.Model):
|
||||
array = ArrayField(base_field=models.TextField())
|
||||
Reference in New Issue
Block a user