eric6/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py

changeset 8243
cc717c2ae956
parent 8222
5994b80b8760
child 8259
2bbec88047dd
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py	Thu Apr 15 16:52:05 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py	Thu Apr 15 18:11:24 2021 +0200
@@ -15,6 +15,7 @@
 import tokenize
 import ast
 from io import StringIO
+import contextlib
 
 try:
     ast.AsyncFunctionDef    # __IGNORE_EXCEPTION__
@@ -464,7 +465,7 @@
         
         tokenGenerator = tokenize.generate_tokens(
             StringIO(context.ssource()).readline)
-        try:
+        with contextlib.suppress(StopIteration):
             kind = None
             while kind != tokenize.INDENT:
                 kind, _, _, _, _ = next(tokenGenerator)
@@ -472,8 +473,6 @@
             if kind == tokenize.STRING:  # STRING after INDENT is a docstring
                 return DocStyleContext(
                     value, context.start() + line - 1, "docstring")
-        except StopIteration:
-            pass
         
         return None
     
@@ -559,7 +558,7 @@
                 tokenGenerator = tokenize.generate_tokens(
                     StringIO(classContext.ssource()).readline)
                 kind, value, char = None, None, None
-                try:
+                with contextlib.suppress(StopIteration):
                     while True:
                         start, end = None, None
                         while not (kind == tokenize.NAME and value == 'def'):
@@ -588,8 +587,6 @@
                             ):
                                 context.setSpecial("classmethod")
                         contexts.append(context)
-                except StopIteration:
-                    pass
             self.__methodsCache = contexts
         
         return self.__methodsCache

eric ide

mercurial