typing.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. """A collection of typing utilities."""
  4. import sys
  5. from typing import NamedTuple, Optional, Union
  6. if sys.version_info >= (3, 8):
  7. from typing import Literal, TypedDict
  8. else:
  9. from typing_extensions import Literal, TypedDict
  10. class FileItem(NamedTuple):
  11. """Represents data about a file handled by pylint
  12. Each file item has:
  13. - name: full name of the module
  14. - filepath: path of the file
  15. - modname: module name
  16. """
  17. name: str
  18. filepath: str
  19. modpath: str
  20. class ModuleDescriptionDict(TypedDict):
  21. """Represents data about a checked module"""
  22. path: str
  23. name: str
  24. isarg: bool
  25. basepath: str
  26. basename: str
  27. class ErrorDescriptionDict(TypedDict):
  28. """Represents data about errors collected during checking of a module"""
  29. key: Literal["fatal"]
  30. mod: str
  31. ex: Union[ImportError, SyntaxError]
  32. class MessageLocationTuple(NamedTuple):
  33. """Tuple with information about the location of a to-be-displayed message"""
  34. abspath: str
  35. path: str
  36. module: str
  37. obj: str
  38. line: int
  39. column: int
  40. end_line: Optional[int] = None
  41. end_column: Optional[int] = None
  42. class ManagedMessage(NamedTuple):
  43. """Tuple with information ahout a managed message of the linter"""
  44. name: Optional[str]
  45. msgid: str
  46. symbol: str
  47. line: Optional[int]
  48. is_disabled: bool