src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py

branch
eric7
changeset 10440
2c1289d82881
parent 10439
21c28b0f9e41
child 10455
bed8a0c90d11
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py	Sat Dec 23 15:48:12 2023 +0100
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py	Sun Dec 24 19:46:25 2023 +0100
@@ -186,6 +186,7 @@
         "D263",
         "D270",
         "D271",
+        "D272",
     ]
 
     def __init__(
@@ -313,8 +314,8 @@
                         ("D244", "D245"),
                     ),
                     (self.__checkEricException, ("D250", "D251", "D252", "D253")),
-                    (self.__checkEricDocumentationSequence, ("D270",)),
-                    (self.__checkEricDocumentationDeprecatedTags, ("D271",)),
+                    (self.__checkEricDocumentationSequence, ("D270", "D271")),
+                    (self.__checkEricDocumentationDeprecatedTags, ("D272",)),
                 ],
                 "docstring": [
                     (self.__checkTripleDoubleQuotes, ("D111",)),
@@ -1626,11 +1627,25 @@
             return
 
         docTokens = []
-        for lineno, line in enumerate(docstringContext.source()):
+        lines = docstringContext.source()
+        for lineno, line in enumerate(lines):
             strippedLine = line.lstrip()
             if strippedLine.startswith("@"):
-                docTokens.append((strippedLine.split(None, 1)[0], lineno))
+                docToken = strippedLine.split(None, 1)[0]
+                docTokens.append((docToken, lineno))
+                
+                # check, that a type tag is not preceeced by an empty line
+                if (
+                    docToken in ("@tyoe", "@rtype", "@ytype")
+                    and lineno > 0
+                    and lines[lineno - 1].strip() == ""
+                ):
+                    self.__error(
+                        docstringContext.start() + lineno, 0, "D271", docToken
+                    )
 
+        # check the correct sequence of @param/@return/@yield and their accompanying
+        # type tag
         for index in range(len(docTokens)):
             docToken, lineno = docTokens[index]
             try:
@@ -1684,7 +1699,7 @@
                     self.__error(
                         docstringContext.start() + lineno,
                         0,
-                        "D271",
+                        "D272",
                         tag,
                         deprecationsList[tag],
                     )

eric ide

mercurial