constants.py 1.1 KB

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