From cd8d9fb95ecb65d29e1d9c43e564bd9c89a05eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Tue, 1 Dec 2020 08:43:12 +0100 Subject: [PATCH] Fix ResourceWarning: unclosed file in setup.py Also prevent potential identical warning in `plat_other.py`. --- send2trash/plat_other.py | 5 ++--- setup.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/send2trash/plat_other.py b/send2trash/plat_other.py index dd45606..f5dcadd 100644 --- a/send2trash/plat_other.py +++ b/send2trash/plat_other.py @@ -112,9 +112,8 @@ def trash_move(src, dst, topdir=None): check_create(infopath) os.rename(src, op.join(filespath, destname)) - f = open(op.join(infopath, destname + INFO_SUFFIX), "w") - f.write(info_for(src, topdir)) - f.close() + with open(op.join(infopath, destname + INFO_SUFFIX), "w") as f: + f.write(info_for(src, topdir)) def find_mount_point(path): diff --git a/setup.py b/setup.py index 60a07a1..3ac4580 100644 --- a/setup.py +++ b/setup.py @@ -17,9 +17,8 @@ CLASSIFIERS = [ "Topic :: Desktop Environment :: File Managers", ] -LONG_DESCRIPTION = ( - open("README.rst", "rt").read() + "\n\n" + open("CHANGES.rst", "rt").read() -) +with open("README.rst", "rt") as f1, open("CHANGES.rst", "rt") as f2: + LONG_DESCRIPTION = f1.read() + "\n\n" + f2.read() setup( name="Send2Trash",