src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFunctionVisitor.py

branch
eric7
changeset 10119
64147a7e6393
parent 10058
5d965939ab85
child 10169
0f70a4ef4592
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFunctionVisitor.py	Thu Jul 20 10:36:23 2023 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFunctionVisitor.py	Thu Jul 20 11:00:30 2023 +0200
@@ -12,14 +12,11 @@
 #####################################################################################
 
 import ast
-import sys
 
 from .AnnotationsEnums import AnnotationType, ClassDecoratorType, FunctionType
 
 # The order of AST_ARG_TYPES must match Python's grammar
-AST_ARG_TYPES = ("args", "vararg", "kwonlyargs", "kwarg")
-if sys.version_info >= (3, 8, 0):
-    AST_ARG_TYPES = ("posonlyargs",) + AST_ARG_TYPES
+AST_ARG_TYPES = ("posonlyargs", "args", "vararg", "kwonlyargs", "kwarg")
 
 
 class Argument:
@@ -374,27 +371,7 @@
         if node.lineno == node.body[0].lineno:
             return Function._singleLineColonSeeker(node, lines[node.lineno - 1])
 
-        # With Python < 3.8, the function node includes the docstring and the
-        # body does not, so we have to rewind through any docstrings, if
-        # present, before looking for the def colon. We should end up with
-        # lines[defEndLineno - 1] having the colon.
-        defEndLineno = node.body[0].lineno
-        if sys.version_info < (3, 8, 0):
-            # If the docstring is on one line then no rewinding is necessary.
-            nTripleQuotes = lines[defEndLineno - 1].count('"""')
-            if nTripleQuotes == 1:
-                # Docstring closure, rewind until the opening is found and take
-                # the line prior.
-                while True:
-                    defEndLineno -= 1
-                    if '"""' in lines[defEndLineno - 1]:
-                        # Docstring has closed
-                        break
-
-        # Once we've gotten here, we've found the line where the docstring
-        # begins, so we have to step up one more line to get to the close of
-        # the def.
-        defEndLineno -= 1
+        defEndLineno = node.body[0].lineno - 1
 
         # Use str.rfind() to account for annotations on the same line,
         # definition closure should be the last : on the line

eric ide

mercurial