replace except: pass with suppress() context manager
This commit is contained in:
parent
23694b207b
commit
341c2f98e5
5 changed files with 12 additions and 22 deletions
|
@ -3,6 +3,7 @@ import configparser
|
|||
import os
|
||||
import string
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
|
||||
from django.contrib.messages import constants as messages
|
||||
from django.utils.crypto import get_random_string
|
||||
|
@ -155,19 +156,13 @@ MIDDLEWARE = [
|
|||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
try:
|
||||
with suppress(ImportError):
|
||||
import debug_toolbar # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
INSTALLED_APPS.append('debug_toolbar')
|
||||
MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')
|
||||
|
||||
try:
|
||||
with suppress(ImportError):
|
||||
import htmlmin # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
MIDDLEWARE += [
|
||||
'htmlmin.middleware.HtmlMinifyMiddleware',
|
||||
'htmlmin.middleware.MarkRequestMiddleware',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue