summaryrefslogtreecommitdiff
path: root/doc/exts
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-09-09 09:52:43 +0200
committerGitHub <noreply@github.com>2022-09-09 09:52:43 +0200
commitf29bdd4e04c8c144b378220434646b37a8e7d9a0 (patch)
tree23231076dbd0beb358de9ea5d4325a27f8af40f1 /doc/exts
parentef7a9108e1bc5d1052d41bf7eda0311610c39d73 (diff)
downloadpylint-git-f29bdd4e04c8c144b378220434646b37a8e7d9a0.tar.gz
Turn on ``check-untyped-defs`` in ``mypy`` (#7407)
Diffstat (limited to 'doc/exts')
-rwxr-xr-xdoc/exts/pylint_extensions.py58
1 files changed, 43 insertions, 15 deletions
diff --git a/doc/exts/pylint_extensions.py b/doc/exts/pylint_extensions.py
index a973e1b13..e5949b1ed 100755
--- a/doc/exts/pylint_extensions.py
+++ b/doc/exts/pylint_extensions.py
@@ -6,22 +6,42 @@
"""Script used to generate the extensions file before building the actual documentation."""
+from __future__ import annotations
+
import os
import re
import sys
import warnings
-from typing import Optional
+from typing import Any
import sphinx
from sphinx.application import Sphinx
+from pylint.checkers import BaseChecker
from pylint.constants import MAIN_CHECKER_NAME
from pylint.lint import PyLinter
+from pylint.typing import MessageDefinitionTuple, OptionDict, ReportsCallable
from pylint.utils import get_rst_title
+if sys.version_info >= (3, 8):
+ from typing import TypedDict
+else:
+ from typing_extensions import TypedDict
+
+
+class _CheckerInfo(TypedDict):
+ """Represents data about a checker."""
+
+ checker: BaseChecker
+ options: list[tuple[str, OptionDict, Any]]
+ msgs: dict[str, MessageDefinitionTuple]
+ reports: list[tuple[str, str, ReportsCallable]]
+ doc: str
+ module: str
+
# pylint: disable-next=unused-argument
-def builder_inited(app: Optional[Sphinx]) -> None:
+def builder_inited(app: Sphinx | None) -> None:
"""Output full documentation in ReST format for all extension modules."""
# PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
base_path = os.path.dirname(
@@ -30,7 +50,7 @@ def builder_inited(app: Optional[Sphinx]) -> None:
# PACKAGE/ --> PACKAGE/pylint/extensions
ext_path = os.path.join(base_path, "pylint", "extensions")
modules = []
- doc_files = {}
+ doc_files: dict[str, str] = {}
for filename in os.listdir(ext_path):
name, ext = os.path.splitext(filename)
if name[0] == "_":
@@ -79,18 +99,26 @@ def builder_inited(app: Optional[Sphinx]) -> None:
checker, information = checker_information
j = -1
checker = information["checker"]
- del information["checker"]
if i == max_len - 1:
# Remove the \n\n at the end of the file
j = -3
print(
- checker.get_full_documentation(**information, show_options=False)[:j],
+ checker.get_full_documentation(
+ msgs=information["msgs"],
+ options=information["options"],
+ reports=information["reports"],
+ doc=information["doc"],
+ module=information["module"],
+ show_options=False,
+ )[:j],
file=stream,
)
-def get_plugins_info(linter, doc_files):
- by_checker = {}
+def get_plugins_info(
+ linter: PyLinter, doc_files: dict[str, str]
+) -> dict[BaseChecker, _CheckerInfo]:
+ by_checker: dict[BaseChecker, _CheckerInfo] = {}
for checker in linter.get_checkers():
if checker.name == MAIN_CHECKER_NAME:
continue
@@ -116,14 +144,14 @@ def get_plugins_info(linter, doc_files):
except KeyError:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
- by_checker[checker] = {
- "checker": checker,
- "options": list(checker.options_and_values()),
- "msgs": dict(checker.msgs),
- "reports": list(checker.reports),
- "doc": doc,
- "module": module,
- }
+ by_checker[checker] = _CheckerInfo(
+ checker=checker,
+ options=list(checker.options_and_values()),
+ msgs=dict(checker.msgs),
+ reports=list(checker.reports),
+ doc=doc,
+ module=module,
+ )
return by_checker