Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31771 closed Cleanup/optimization (wontfix)

Add warning if model field has trailing comma.

Reported by: Jonas Haag Owned by: nobody
Component: Core (System checks) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If someone types (note the trailing comma):

class MyModel(models.Model):
  trailing_comma = models.IntegerField(),

Django silently ignored the field, possibly leaving you wondering for a very long time what's going on.

I suggest to add a warning to the models checker framework.

If accepted, I'm willing to come up with an initial patch.

Change History (4)

comment:1 by Mariusz Felisiak, 4 years ago

Component: Database layer (models, ORM)Core (System checks)
Resolution: wontfix
Status: newclosed
Summary: Add warning if model field has trailing commaAdd warning if model field has trailing comma.
UI/UX: unset

Thanks for this ticket, however we cannot add a system check for tuples defined on models. It's a supported use case.

comment:2 by Jonas Haag, 4 years ago

What do you mean by “supported use case”? Obviously defining tuples on model classes generally should not raise a warning, but how about the specific case of tuple of size 1 containing a model field instance?

comment:4 by Mariusz Felisiak, 4 years ago

It is too specific, we cannot add separate system checks for each kind of typos.

Note: See TracTickets for help on using tickets.
Back to Top