From 683341db4396d92e4578d348b7fcce3312df505d Mon Sep 17 00:00:00 2001
From: Daniel Hahler <github@thequod.de>
Date: Sat, 3 Mar 2018 19:35:09 +0100
Subject: [PATCH] Condensed some widgets code.

---
 django/contrib/admin/widgets.py |  5 +----
 django/forms/widgets.py         | 11 +++--------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index 91795d4ce4b..ab57f53433f 100644
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -389,10 +389,7 @@ class AutocompleteMixin:
         self.admin_site = admin_site
         self.db = using
         self.choices = choices
-        if attrs is not None:
-            self.attrs = attrs.copy()
-        else:
-            self.attrs = {}
+        self.attrs = {} if attrs is None else attrs.copy()
 
     def get_url(self):
         model = self.rel.model
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index f3a6b38f46c..50e41b59ec9 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -161,10 +161,8 @@ def media_property(cls):
                     for medium in extend:
                         m = m + base[medium]
                 return m + Media(definition)
-            else:
-                return Media(definition)
-        else:
-            return base
+            return Media(definition)
+        return base
     return property(_media)
 
 
@@ -188,10 +186,7 @@ class Widget(metaclass=MediaDefiningClass):
     supports_microseconds = True
 
     def __init__(self, attrs=None):
-        if attrs is not None:
-            self.attrs = attrs.copy()
-        else:
-            self.attrs = {}
+        self.attrs = {} if attrs is None else attrs.copy()
 
     def __deepcopy__(self, memo):
         obj = copy.copy(self)