[diffoscope] 07/07: Prefer kwargs[x] = kwargs.pop(x, 'default') idiom over ``if`` statements.

Chris Lamb chris at chris-lamb.co.uk
Mon Aug 15 21:55:54 CEST 2016


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit b63b857582963bf17f45068d554385cb97cb4287
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Aug 15 20:54:59 2016 +0100

    Prefer kwargs[x] = kwargs.pop(x, 'default') idiom over ``if`` statements.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/__init__.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/diffoscope/__init__.py b/diffoscope/__init__.py
index e5c80c6..c6ab2bc 100644
--- a/diffoscope/__init__.py
+++ b/diffoscope/__init__.py
@@ -91,16 +91,14 @@ temp_dirs = []
 
 
 def get_named_temporary_file(*args, **kwargs):
-    if 'suffix' not in kwargs:
-        kwargs['suffix'] = '_diffoscope'
+    kwargs['suffix'] = kwargs.pop('suffix', '_diffoscope')
     f = tempfile.NamedTemporaryFile(*args, **kwargs)
     temp_files.append(f.name)
     return f
 
 
 def get_temporary_directory(*args, **kwargs):
-    if 'suffix' not in kwargs:
-        kwargs['suffix'] = '_diffoscope'
+    kwargs['suffix'] = kwargs.pop('suffix', '_diffoscope')
     d = tempfile.TemporaryDirectory(*args, **kwargs)
     temp_dirs.append(d)
     return d

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list