constants.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  2. # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
  3. import operator
  4. import re
  5. import sys
  6. from os.path import abspath, dirname
  7. from pathlib import Path
  8. SYS_VERS_STR = (
  9. "%d%d%d" % sys.version_info[:3] # pylint: disable=consider-using-f-string
  10. )
  11. TITLE_UNDERLINES = ["", "=", "-", "."]
  12. PREFIX = abspath(dirname(__file__))
  13. UPDATE_OPTION = "--update-functional-output"
  14. UPDATE_FILE = Path("pylint-functional-test-update")
  15. # Common sub-expressions.
  16. _MESSAGE = {"msg": r"[a-z][a-z\-]+"}
  17. # Matches a #,
  18. # - followed by a comparison operator and a Python version (optional),
  19. # - followed by a line number with a +/- (optional),
  20. # - followed by a list of bracketed message symbols.
  21. # Used to extract expected messages from testdata files.
  22. _EXPECTED_RE = re.compile(
  23. r"\s*#\s*(?:(?P<line>[+-]?[0-9]+):)?" # pylint: disable=consider-using-f-string
  24. r"(?:(?P<op>[><=]+) *(?P<version>[0-9.]+):)?"
  25. r"\s*\[(?P<msgs>%(msg)s(?:,\s*%(msg)s)*)]" % _MESSAGE
  26. )
  27. _OPERATORS = {">": operator.gt, "<": operator.lt, ">=": operator.ge, "<=": operator.le}