2021-09-15 18:42:22 +00:00
|
|
|
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
|
|
|
|
|
|
|
|
"""A collection of typing utilities."""
|
2021-09-16 14:58:37 +00:00
|
|
|
import sys
|
2021-10-17 08:37:02 +00:00
|
|
|
from typing import NamedTuple, Optional, Union
|
2021-09-15 18:42:22 +00:00
|
|
|
|
2021-09-16 14:58:37 +00:00
|
|
|
if sys.version_info >= (3, 8):
|
|
|
|
from typing import Literal, TypedDict
|
|
|
|
else:
|
|
|
|
from typing_extensions import Literal, TypedDict
|
|
|
|
|
|
|
|
|
|
|
|
class FileItem(NamedTuple):
|
|
|
|
"""Represents data about a file handled by pylint
|
|
|
|
|
|
|
|
Each file item has:
|
|
|
|
- name: full name of the module
|
|
|
|
- filepath: path of the file
|
|
|
|
- modname: module name
|
|
|
|
"""
|
|
|
|
|
|
|
|
name: str
|
|
|
|
filepath: str
|
|
|
|
modpath: str
|
|
|
|
|
|
|
|
|
|
|
|
class ModuleDescriptionDict(TypedDict):
|
|
|
|
"""Represents data about a checked module"""
|
|
|
|
|
|
|
|
path: str
|
|
|
|
name: str
|
|
|
|
isarg: bool
|
|
|
|
basepath: str
|
|
|
|
basename: str
|
|
|
|
|
|
|
|
|
|
|
|
class ErrorDescriptionDict(TypedDict):
|
|
|
|
"""Represents data about errors collected during checking of a module"""
|
|
|
|
|
|
|
|
key: Literal["fatal"]
|
|
|
|
mod: str
|
|
|
|
ex: Union[ImportError, SyntaxError]
|
|
|
|
|
2021-09-15 18:42:22 +00:00
|
|
|
|
2021-09-21 11:56:58 +00:00
|
|
|
class MessageLocationTuple(NamedTuple):
|
|
|
|
"""Tuple with information about the location of a to-be-displayed message"""
|
|
|
|
|
|
|
|
abspath: str
|
|
|
|
path: str
|
|
|
|
module: str
|
|
|
|
obj: str
|
|
|
|
line: int
|
|
|
|
column: int
|
2021-11-22 21:40:26 +00:00
|
|
|
end_line: Optional[int] = None
|
|
|
|
end_column: Optional[int] = None
|
2021-10-17 08:37:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ManagedMessage(NamedTuple):
|
2021-12-22 17:26:44 +00:00
|
|
|
"""Tuple with information about a managed message of the linter"""
|
2021-10-17 08:37:02 +00:00
|
|
|
|
|
|
|
name: Optional[str]
|
|
|
|
msgid: str
|
|
|
|
symbol: str
|
|
|
|
line: Optional[int]
|
|
|
|
is_disabled: bool
|