--- a/eric6/Plugins/VcsPlugins/vcsGit/git.py Wed Apr 14 19:38:19 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/git.py Wed Apr 14 19:59:16 2021 +0200 @@ -10,6 +10,7 @@ import os import shutil import re +import contextlib from PyQt5.QtCore import QProcess, pyqtSignal, QFileInfo from PyQt5.QtWidgets import QApplication, QDialog, QInputDialog, QLineEdit @@ -1166,10 +1167,8 @@ entries.extend(Utilities.direntries(name, True, pat)) for entry in entries: - try: + with contextlib.suppress(OSError): os.remove(entry) - except OSError: - pass def vcsCommandLine(self, name): """ @@ -3572,10 +3571,7 @@ cfgFile = os.path.join(repodir, self.adminDir, "config") if not os.path.exists(cfgFile): # create an empty one - try: - with open(cfgFile, "w"): - pass - except OSError: + with contextlib.suppress(OSError), open(cfgFile, "w"): pass self.repoEditor = MiniEditor(cfgFile, "Properties") self.repoEditor.show() @@ -3594,14 +3590,10 @@ else: firstName, lastName, email = ( "Firstname", "Lastname", "email_address") - try: - with open(cfgFile, "w") as f: - f.write("[user]\n") - f.write(" name = {0} {1}\n".format(firstName, lastName)) - f.write(" email = {0}\n".format(email)) - except OSError: - # ignore these - pass + with contextlib.suppress(OSError), open(cfgFile, "w") as f: + f.write("[user]\n") + f.write(" name = {0} {1}\n".format(firstName, lastName)) + f.write(" email = {0}\n".format(email)) self.userEditor = MiniEditor(cfgFile, "Properties") self.userEditor.show()