eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py

changeset 8243
cc717c2ae956
parent 8234
fcb6b4b96274
child 8273
698ae46f40a4
--- a/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Thu Apr 15 16:52:05 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Thu Apr 15 18:11:24 2021 +0200
@@ -12,13 +12,11 @@
 import re
 import traceback
 import multiprocessing
-
+import contextlib
 
-try:
+with contextlib.suppress(ImportError):
     from pyflakes.checker import Checker
     from pyflakes.messages import ImportStarUsed, ImportStarUsage
-except ImportError:
-    pass
 
 VcsConflictMarkerRegExpList = (
     re.compile(
@@ -283,13 +281,11 @@
             error = str(detail)
         return [{'error': (fn, line, 0, "", error)}]
     except Exception as detail:
-        try:
+        with contextlib.suppress(Exception):
             fn = detail.filename
             line = detail.lineno
             error = detail.msg
             return [{'error': (fn, line, 0, "", error)}]
-        except Exception:           # secok
-            pass
     
     # pyflakes
     if not checkFlakes:
@@ -309,11 +305,9 @@
             
             _fn, lineno, col, message, msg_args = warning.getMessageData()
             lineFlags = extractLineFlags(lines[lineno - 1].strip())
-            try:
+            with contextlib.suppress(IndexError):
                 lineFlags += extractLineFlags(lines[lineno].strip(),
                                               flagsLine=True)
-            except IndexError:
-                pass
             if (
                 "__IGNORE_WARNING__" not in lineFlags and
                 "noqa" not in lineFlags

eric ide

mercurial