Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgre and GIS model fields do not support the db_comment argument. #2053

Closed
JaeHyuckSa opened this issue Apr 12, 2024 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@JaeHyuckSa
Copy link
Contributor

Bug report

Mypy error occurs when using db_comment argumment of model fields in postgre and gis.

What's wrong

from django.contrib.gis.db.models import PointField
from django.contrib.postgres.fields import ArrayField
from django.db import models


class Place(models.Model):
    point = PointField(db_comment="Position coordinates")
    visible_phone_number = ArrayField(
        models.CharField(max_length=16), 
        db_comment="Exposed phone numbers to show customers", 
        size=2
    )

You can check the error with the terminal below.

models.py:23: error: Unexpected keyword argument "db_comment" for "ArrayField"  [call-arg]
/Users/sajh/.pyenv/versions/3.11.5/envs/mung/lib/python3.11/site-packages/django-stubs/contrib/postgres/fields/array.pyi:26: note: "ArrayField" defined here

/models.py:27: error: Unexpected keyword argument "db_comment" for "PointField"  [call-arg]
/Users/sajh/.pyenv/versions/3.11.5/envs/mung/lib/python3.11/site-packages/django-stubs/contrib/gis/db/models/fields.pyi:81: note: "PointField" defined here

How is that should be

#1492 The contributor to the issue seems to have forgotten to process the postgres and gis fields while adding the value of the db_comment argument. In order to solve the error, add db_comment argument to GeometryField and BaseSpatialField, which are higher classes in ArrayField and PointField.

System information

  • OS:
  • python version: 3.11.5
  • django version: 4.2.11
  • mypy version: 1.9.0
  • django-stubs version: 4.2.7
  • django-stubs-ext version: 4.2.7
@JaeHyuckSa JaeHyuckSa added the bug Something isn't working label Apr 12, 2024
@JaeHyuckSa JaeHyuckSa changed the title Postgre and GIS model fields do not support the db_comment argument. Postgre and GIS model fields do not support the db_comment argument. Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant