From 49cf1d360f670d6cfe5175f8ba9cecc18f2f3645 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Thu, 9 Jul 2020 17:14:47 +0100 Subject: [PATCH] Use subprocess.DEVNULL for output redirection --- xfel_calibrate/calibrate.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py index 917575076..99daadfd8 100755 --- a/xfel_calibrate/calibrate.py +++ b/xfel_calibrate/calibrate.py @@ -11,7 +11,7 @@ from nbparameterise import ( import os import pprint import re -from subprocess import check_output +from subprocess import check_output, DEVNULL import sys import warnings from .settings import * @@ -163,11 +163,9 @@ def extract_title_author_version(nb): # in the _version.py file try: git_dir = os.path.join(PKG_DIR, '..', '.git') - FNULL = open(os.devnull, 'w') - version = check_output(['git', - '--git-dir={}'.format(git_dir), - 'describe', '--tag'], - stderr=FNULL).decode('utf8') + version = check_output([ + 'git', f'--git-dir={git_dir}', 'describe', '--tag', + ], stderr=DEVNULL).decode('utf8') version = version.replace("\n", "") except: from .VERSION import __version__ -- GitLab