From b86a5f959cb2dfdbe44163f81640b1af4a5452b5 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Fri, 8 Dec 2023 15:32:56 +0200 Subject: [PATCH] Simplify CodeBlockPreprocessor definition --- rest_framework-stubs/compat.pyi | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rest_framework-stubs/compat.pyi b/rest_framework-stubs/compat.pyi index 883110ae3..bd12eafde 100644 --- a/rest_framework-stubs/compat.pyi +++ b/rest_framework-stubs/compat.pyi @@ -31,17 +31,11 @@ try: import pygments except ImportError: pygments: TypeAlias = None # type: ignore[no-redef] -try: - import markdown - def apply_markdown(text: str) -> str: ... - -except ImportError: - apply_markdown: TypeAlias = None # type: ignore[no-redef] - markdown: TypeAlias = None # type: ignore[no-redef] try: - import pygments + import markdown from markdown.preprocessors import Preprocessor + def apply_markdown(text: str) -> str: ... class CodeBlockPreprocessor(Preprocessor): pattern: Any @@ -49,7 +43,8 @@ try: def run(self, lines: list[str]) -> list[str]: ... except ImportError: - pass + apply_markdown: TypeAlias = None # type: ignore[no-redef] + markdown: TypeAlias = None # type: ignore[no-redef] def pygments_css(style: Any) -> str | None: ... def pygments_highlight(text: str, lang: str, style: Any) -> Any: ...