#28858: Remove 'else' after 'return' or 'raise'
-------------------------------------+-------------------------------------
     Reporter:  Дилян Палаузов       |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Core (Other)         |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tomer Chachamu):

 I think you answered your own question there - it is used when it impacts
 readability (as judged by the original authors, who may not always agree
 with each other).

 An `if..elif..else..` block clearly lists mutually exclusive branches
 taken, and can be seen by looking at a single indentation level.
 `if..return; if.. return;..` requires checking two indentation levels to
 ensure there's a `return/raise` ending every `if`.

 For example, in the first hunk of the patch, the code is:

 {{{
 if bla:
    some code
 if bla2:
    raise
 elif bla3:
    raise
 return val
 }}}

 After the change, it is:

 {{{
 if bla:
    some code
 if bla2:
    raise
 if bla3:
    raise
 return val
 }}}

 A newline before `if bla2` would improve readability, however the `elif`
 is already helping to show there is some similarity between `if bla2` and
 `if bla3`, and that `if bla` has a different purpose.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28858#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.4a3e69c069c6393cf76a3564c2b2cdbd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to