Django stubs doesn`t support operations on JSON fields using F operator
What's wrong
Since the 9.5 version, Postgres supports '-' operator for JSON fields. It removes key: value from the object.
Here the example that works fine:
from django.db import models
from django.contrib.postgres.fields import JSONField
class A(models.Model):
some_data = JSONField()
A.objects.create(some_data={'key': 'value'})
query = A.objects.filter(id=1).update(
some_data=(F('some_data') - 'key'),
)
But mypy returns
file.py:1: note: In function "function_name":
file.py:1: error: Unsupported operand types for - ("F" and "str") [operator] some_data=(F('some_data') - 'key'),
Bug report
Django stubs doesn`t support operations on JSON fields using F operator
What's wrong
Since the 9.5 version, Postgres supports '-' operator for JSON fields. It removes key: value from the object. Here the example that works fine:
But mypy returns
How is that should be
Operator
F
should support-
operation withstr
System information
python
version: 3.7django
version: 2.2.24mypy
version: 0.790django-stubs
version: 1.7.0