I get a warning from pycharm when I have a model class with a json field and I try to access that json field, eg (pseudocode I can't easily test for repro, unfortunately, but it demonstrates what I'm pretty sure is a repro case of the problem from our private code):
from django.contrib.postgres.fields import JSONField
class ProbablyIrrelevantSuperclass(models.Model):
# misc probably-irrelevant stuff
class Meta:
abstract = True
class SomeTableWithJson(ProbablyIrrelevantSuperclass):
# ... lots of misc fields that probably don't matter ...
some_json_value = JSONField(default=dict, blank=True, null=True)
def some_func(self):
# warning on next line: Unresolved attribute reference 'get' for class 'JSONField'
return some_json_value.get("some_key")
How is that should be
JSONField should act as a union between JSONField and either the type of the default, or the possible types of a json value, depending on which the authors of django-stubs feel is appropriate.
System information
OS: Mac OS 10.14.6
python version: 3.7.4
django version: Django==2.2.3
mypy version: mypy==0.740
django-stubs version: django-stubs==1.2.0
PyCharm version: Pycharm Professional 2019.2.2
mypy.ini (I don't think this is used by pycharm, and we don't get any warnings from mypy, but I figured I'd share it anyway):
Bug report
What's wrong
I get a warning from pycharm when I have a model class with a json field and I try to access that json field, eg (pseudocode I can't easily test for repro, unfortunately, but it demonstrates what I'm pretty sure is a repro case of the problem from our private code):
How is that should be
JSONField should act as a union between JSONField and either the type of the default, or the possible types of a json value, depending on which the authors of django-stubs feel is appropriate.
System information
Mac OS 10.14.6
python
version:3.7.4
django
version:Django==2.2.3
mypy
version:mypy==0.740
django-stubs
version:django-stubs==1.2.0
mypy.ini
(I don't think this is used by pycharm, and we don't get any warnings from mypy, but I figured I'd share it anyway):[mypy.plugins.django-stubs] django_settings_module = app.settings.local
[mypy~.migrations.]
ignore_errors = True```