Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#34446 closed Bug (fixed)

Coding style docs should contain incorrect example for Model style.

Reported by: JiriKr Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Joseph V Zammit, Paolo Melchiorre Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style

In dev documentation version there is no difference between Do this: and Don’t do this: in Meta section.

class Person(models.Model):
    first_name = models.CharField(max_length=20)
    last_name = models.CharField(max_length=40)

    class Meta:
        verbose_name_plural = "people"

In 4.1 version it is correct. Related to https://code.djangoproject.com/ticket/34140 .

Change History (8)

comment:1 by Mariusz Felisiak, 20 months ago

Cc: Joseph V Zammit Paolo Melchiorre added
Easy pickings: set
Summary: Code style - incorrect Model StyleCoding style docs should contain incorrect example for Model style.
Triage Stage: UnreviewedAccepted

Great catch! We should remove this blank line:

  • docs/internals/contributing/writing-code/coding-style.txt

    diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt
    index 5b64e94b24..9b44be87b1 100644
    a b Model style  
    282282      class Person(models.Model):
    283283          first_name = models.CharField(max_length=20)
    284284          last_name = models.CharField(max_length=40)
    285 
    286285          class Meta:
    287286              verbose_name_plural = "people"
    288287

I hope there is a way to skip blacken-docs on this example.

JiriKr, Would you like to prepare a patch?

comment:2 by Mariusz Felisiak, 20 months ago

TBH, I think this example is no longer needed as we have black CI builds. I'd remove it:

  • docs/internals/contributing/writing-code/coding-style.txt

    diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt
    index 5b64e94b24..812be79c91 100644
    a b Model style  
    279279
    280280  Don't do this::
    281281
    282       class Person(models.Model):
    283           first_name = models.CharField(max_length=20)
    284           last_name = models.CharField(max_length=40)
    285 
    286           class Meta:
    287               verbose_name_plural = "people"
    288 
    289   Don't do this, either::
    290 
    291282      class Person(models.Model):
    292283          class Meta:
    293284              verbose_name_plural = "people"

comment:3 by Paolo Melchiorre, 20 months ago

I agree with Mariusz

in reply to:  1 comment:4 by JiriKr, 20 months ago

Has patch: set
Triage Stage: AcceptedReady for checkin

Replying to Mariusz Felisiak:

JiriKr, Would you like to prepare a patch?

Yes, I would like to. It's my first contribution to Django (hope it will be correct).

Thank you for guidance, I prepared PR

comment:5 by JiriKr, 20 months ago

Triage Stage: Ready for checkinAccepted

Sorry, not sure if I can change Triage Stage.

comment:6 by Mariusz Felisiak, 20 months ago

Triage Stage: AcceptedReady for checkin

Sorry, not sure if I can change Triage Stage.

You shouldn't change stage for your own tickets/PRs ;), but I can. Thanks!

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

Resolution: fixed
Status: newclosed

In cfe563ff:

Fixed #34446 -- Removed unneeded and incorrect example in coding style docs.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

In 634acb5:

[4.2.x] Fixed #34446 -- Removed unneeded and incorrect example in coding style docs.

Backport of cfe563ffaf01d22343717176d96bfca0d05f60fb from main

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