311 ( |
312 ( |
312 self.__checkEricNoBlankBeforeAndAfterClassOrFunction, |
313 self.__checkEricNoBlankBeforeAndAfterClassOrFunction, |
313 ("D244", "D245"), |
314 ("D244", "D245"), |
314 ), |
315 ), |
315 (self.__checkEricException, ("D250", "D251", "D252", "D253")), |
316 (self.__checkEricException, ("D250", "D251", "D252", "D253")), |
316 (self.__checkEricDocumentationSequence, ("D270",)), |
317 (self.__checkEricDocumentationSequence, ("D270", "D271")), |
317 (self.__checkEricDocumentationDeprecatedTags, ("D271",)), |
318 (self.__checkEricDocumentationDeprecatedTags, ("D272",)), |
318 ], |
319 ], |
319 "docstring": [ |
320 "docstring": [ |
320 (self.__checkTripleDoubleQuotes, ("D111",)), |
321 (self.__checkTripleDoubleQuotes, ("D111",)), |
321 (self.__checkBackslashes, ("D112",)), |
322 (self.__checkBackslashes, ("D112",)), |
322 (self.__checkIndent, ("D122",)), |
323 (self.__checkIndent, ("D122",)), |
1624 """ |
1625 """ |
1625 if docstringContext is None: |
1626 if docstringContext is None: |
1626 return |
1627 return |
1627 |
1628 |
1628 docTokens = [] |
1629 docTokens = [] |
1629 for lineno, line in enumerate(docstringContext.source()): |
1630 lines = docstringContext.source() |
|
1631 for lineno, line in enumerate(lines): |
1630 strippedLine = line.lstrip() |
1632 strippedLine = line.lstrip() |
1631 if strippedLine.startswith("@"): |
1633 if strippedLine.startswith("@"): |
1632 docTokens.append((strippedLine.split(None, 1)[0], lineno)) |
1634 docToken = strippedLine.split(None, 1)[0] |
1633 |
1635 docTokens.append((docToken, lineno)) |
|
1636 |
|
1637 # check, that a type tag is not preceeced by an empty line |
|
1638 if ( |
|
1639 docToken in ("@tyoe", "@rtype", "@ytype") |
|
1640 and lineno > 0 |
|
1641 and lines[lineno - 1].strip() == "" |
|
1642 ): |
|
1643 self.__error( |
|
1644 docstringContext.start() + lineno, 0, "D271", docToken |
|
1645 ) |
|
1646 |
|
1647 # check the correct sequence of @param/@return/@yield and their accompanying |
|
1648 # type tag |
1634 for index in range(len(docTokens)): |
1649 for index in range(len(docTokens)): |
1635 docToken, lineno = docTokens[index] |
1650 docToken, lineno = docTokens[index] |
1636 try: |
1651 try: |
1637 docToken2, _ = docTokens[index + 1] |
1652 docToken2, _ = docTokens[index + 1] |
1638 except IndexError: |
1653 except IndexError: |
1682 tag = strippedLine.split(None, 1)[0] |
1697 tag = strippedLine.split(None, 1)[0] |
1683 with contextlib.suppress(KeyError): |
1698 with contextlib.suppress(KeyError): |
1684 self.__error( |
1699 self.__error( |
1685 docstringContext.start() + lineno, |
1700 docstringContext.start() + lineno, |
1686 0, |
1701 0, |
1687 "D271", |
1702 "D272", |
1688 tag, |
1703 tag, |
1689 deprecationsList[tag], |
1704 deprecationsList[tag], |
1690 ) |
1705 ) |