#23919: Cleanups for when we drop Python 2 compatibility
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Core (Other)          |                  Version:
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Nick Pope):

 Given that Django 2.0 is targeting Python 3.5+, are there other things
 that could be cleaned up that were added to support <3.5 or could be used
 now that 3.5 is the minimum version?

 For example, there are many places with the following pattern:

 {{{#!python
 try:
     ...
 except ...:
     pass
 }}}

 These could be replaced with
 
[[https://docs.python.org/3/library/contextlib.html#contextlib.suppress|contextlib.suppress()]]
 which is available since 3.4.

 Other potentially interesting things are:

 - Use of [[https://docs.python.org/3.5/whatsnew/3.5.html#whatsnew-
 pep-448|unpacking generalisations]]
 - Use of [[https://docs.python.org/3.5/whatsnew/3.5.html#whatsnew-
 pep-484|type hints]] and a type checker when building.
 - Use of [[https://docs.python.org/3.5/whatsnew/3.5.html#whatsnew-
 pep-471|os.scandir()]] instead of os.listdir().
 - Use of the [[https://docs.python.org/3.5/library/enum.html#module-
 enum|enum]] and [[https://docs.python.org/3.5/library/pathlib.html#module-
 pathlib|pathlib]] modules where appropriate.
 -
 
[[https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout|contextlib.redirect_stdout()]]
 and
 
[[https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stderr|contextlib.redirect_stderr()]]

 There may be more - this was just a quick look at the What's New pages for
 3.4 and 3.5.

--
Ticket URL: <https://code.djangoproject.com/ticket/23919#comment:103>
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/067.1ff866e725a808c2d58efcb017072637%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to