From f0fc96fd0ef9aabbdd6473a82d489c6f03a77e25 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:21:24 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- markdown_it/__init__.py | 1 + markdown_it/cli/parse.py | 1 + markdown_it/common/entities.py | 1 + markdown_it/common/html_re.py | 3 +-- markdown_it/common/utils.py | 4 ++-- markdown_it/helpers/__init__.py | 4 ++-- markdown_it/helpers/parse_link_label.py | 1 + markdown_it/helpers/parse_link_title.py | 4 ++-- markdown_it/main.py | 15 +++++---------- markdown_it/parser_block.py | 1 + markdown_it/parser_core.py | 9 +++++---- markdown_it/parser_inline.py | 4 ++-- markdown_it/presets/commonmark.py | 1 + markdown_it/presets/default.py | 1 + markdown_it/presets/zero.py | 1 + markdown_it/renderer.py | 4 ++-- markdown_it/ruler.py | 1 + markdown_it/rules_block/code.py | 1 + markdown_it/rules_block/heading.py | 3 ++- markdown_it/rules_block/hr.py | 1 + markdown_it/rules_block/paragraph.py | 1 + markdown_it/rules_core/normalize.py | 3 ++- markdown_it/rules_core/replacements.py | 1 + markdown_it/rules_core/smartquotes.py | 4 ++-- markdown_it/rules_core/text_join.py | 1 + markdown_it/rules_inline/balance_pairs.py | 1 + markdown_it/rules_inline/escape.py | 1 + markdown_it/rules_inline/linkify.py | 1 + markdown_it/rules_inline/newline.py | 1 + markdown_it/tree.py | 7 +++---- scripts/build_fuzzers.py | 1 + scripts/profiler.py | 1 + tests/test_api/test_plugin_creation.py | 1 + tests/test_cmark_spec/test_spec.py | 1 + tests/test_fuzzer.py | 1 + 35 files changed, 53 insertions(+), 34 deletions(-) diff --git a/markdown_it/__init__.py b/markdown_it/__init__.py index 6606868a..399c6b70 100644 --- a/markdown_it/__init__.py +++ b/markdown_it/__init__.py @@ -1,4 +1,5 @@ """A Python port of Markdown-It""" + __all__ = ("MarkdownIt",) __version__ = "3.0.0" diff --git a/markdown_it/cli/parse.py b/markdown_it/cli/parse.py index bfd3449d..fe346b2f 100644 --- a/markdown_it/cli/parse.py +++ b/markdown_it/cli/parse.py @@ -4,6 +4,7 @@ Parse one or more markdown files, convert each to HTML, and print to stdout. """ + from __future__ import annotations import argparse diff --git a/markdown_it/common/entities.py b/markdown_it/common/entities.py index 6bb2d343..14d08ec9 100644 --- a/markdown_it/common/entities.py +++ b/markdown_it/common/entities.py @@ -1,4 +1,5 @@ """HTML5 entities map: { name -> characters }.""" + import html.entities entities = {name.rstrip(";"): chars for name, chars in html.entities.html5.items()} diff --git a/markdown_it/common/html_re.py b/markdown_it/common/html_re.py index f0c336d2..dae052e9 100644 --- a/markdown_it/common/html_re.py +++ b/markdown_it/common/html_re.py @@ -1,5 +1,4 @@ -"""Regexps to match html elements -""" +"""Regexps to match html elements""" import re diff --git a/markdown_it/common/utils.py b/markdown_it/common/utils.py index dbe082a1..0dafa2d6 100644 --- a/markdown_it/common/utils.py +++ b/markdown_it/common/utils.py @@ -1,5 +1,5 @@ -"""Utilities for parsing source text -""" +"""Utilities for parsing source text""" + from __future__ import annotations import re diff --git a/markdown_it/helpers/__init__.py b/markdown_it/helpers/__init__.py index 3dbbdd1d..bcf2dc21 100644 --- a/markdown_it/helpers/__init__.py +++ b/markdown_it/helpers/__init__.py @@ -1,5 +1,5 @@ -"""Functions for parsing Links -""" +"""Functions for parsing Links""" + __all__ = ("parseLinkLabel", "parseLinkDestination", "parseLinkTitle") from .parse_link_destination import parseLinkDestination from .parse_link_label import parseLinkLabel diff --git a/markdown_it/helpers/parse_link_label.py b/markdown_it/helpers/parse_link_label.py index 01c653c5..c80da5a7 100644 --- a/markdown_it/helpers/parse_link_label.py +++ b/markdown_it/helpers/parse_link_label.py @@ -5,6 +5,7 @@ returns the end of the label """ + from markdown_it.rules_inline import StateInline diff --git a/markdown_it/helpers/parse_link_title.py b/markdown_it/helpers/parse_link_title.py index 8f589336..fe23ea71 100644 --- a/markdown_it/helpers/parse_link_title.py +++ b/markdown_it/helpers/parse_link_title.py @@ -1,5 +1,5 @@ -"""Parse link title -""" +"""Parse link title""" + from ..common.utils import charCodeAt, unescapeAll diff --git a/markdown_it/main.py b/markdown_it/main.py index bb294a99..bf9fd18f 100644 --- a/markdown_it/main.py +++ b/markdown_it/main.py @@ -68,24 +68,19 @@ def __repr__(self) -> str: return f"{self.__class__.__module__}.{self.__class__.__name__}()" @overload - def __getitem__(self, name: Literal["inline"]) -> ParserInline: - ... + def __getitem__(self, name: Literal["inline"]) -> ParserInline: ... @overload - def __getitem__(self, name: Literal["block"]) -> ParserBlock: - ... + def __getitem__(self, name: Literal["block"]) -> ParserBlock: ... @overload - def __getitem__(self, name: Literal["core"]) -> ParserCore: - ... + def __getitem__(self, name: Literal["core"]) -> ParserCore: ... @overload - def __getitem__(self, name: Literal["renderer"]) -> RendererProtocol: - ... + def __getitem__(self, name: Literal["renderer"]) -> RendererProtocol: ... @overload - def __getitem__(self, name: str) -> Any: - ... + def __getitem__(self, name: str) -> Any: ... def __getitem__(self, name: str) -> Any: return { diff --git a/markdown_it/parser_block.py b/markdown_it/parser_block.py index 72360f9b..3c4d4019 100644 --- a/markdown_it/parser_block.py +++ b/markdown_it/parser_block.py @@ -1,4 +1,5 @@ """Block-level tokenizer.""" + from __future__ import annotations import logging diff --git a/markdown_it/parser_core.py b/markdown_it/parser_core.py index ca5ab256..77075098 100644 --- a/markdown_it/parser_core.py +++ b/markdown_it/parser_core.py @@ -1,9 +1,10 @@ """ - * class Core - * - * Top-level rules executor. Glues block/inline parsers and does intermediate - * transformations. +* class Core +* +* Top-level rules executor. Glues block/inline parsers and does intermediate +* transformations. """ + from __future__ import annotations from typing import Callable diff --git a/markdown_it/parser_inline.py b/markdown_it/parser_inline.py index 0026c383..8f3ac1e6 100644 --- a/markdown_it/parser_inline.py +++ b/markdown_it/parser_inline.py @@ -1,5 +1,5 @@ -"""Tokenizes paragraph content. -""" +"""Tokenizes paragraph content.""" + from __future__ import annotations from typing import TYPE_CHECKING, Callable diff --git a/markdown_it/presets/commonmark.py b/markdown_it/presets/commonmark.py index 3990d434..ed0de0fe 100644 --- a/markdown_it/presets/commonmark.py +++ b/markdown_it/presets/commonmark.py @@ -6,6 +6,7 @@ - block: table - inline: strikethrough """ + from ..utils import PresetType diff --git a/markdown_it/presets/default.py b/markdown_it/presets/default.py index c9ab902d..8aa858f7 100644 --- a/markdown_it/presets/default.py +++ b/markdown_it/presets/default.py @@ -1,4 +1,5 @@ """markdown-it default options.""" + from ..utils import PresetType diff --git a/markdown_it/presets/zero.py b/markdown_it/presets/zero.py index 2f69a58d..3f1fc18c 100644 --- a/markdown_it/presets/zero.py +++ b/markdown_it/presets/zero.py @@ -2,6 +2,7 @@ "Zero" preset, with nothing enabled. Useful for manual configuring of simple modes. For example, to parse bold/italic only. """ + from ..utils import PresetType diff --git a/markdown_it/renderer.py b/markdown_it/renderer.py index 5a774d06..6d60589a 100644 --- a/markdown_it/renderer.py +++ b/markdown_it/renderer.py @@ -5,6 +5,7 @@ class Renderer copy of rules. Those can be rewritten with ease. Also, you can add new rules if you create plugin and adds new token types. """ + from __future__ import annotations from collections.abc import Sequence @@ -21,8 +22,7 @@ class RendererProtocol(Protocol): def render( self, tokens: Sequence[Token], options: OptionsDict, env: EnvType - ) -> Any: - ... + ) -> Any: ... class RendererHTML(RendererProtocol): diff --git a/markdown_it/ruler.py b/markdown_it/ruler.py index bd8baba3..711edce7 100644 --- a/markdown_it/ruler.py +++ b/markdown_it/ruler.py @@ -15,6 +15,7 @@ class Ruler rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and [[MarkdownIt.use]]. """ + from __future__ import annotations from collections.abc import Iterable diff --git a/markdown_it/rules_block/code.py b/markdown_it/rules_block/code.py index 89db9cec..af8a41c8 100644 --- a/markdown_it/rules_block/code.py +++ b/markdown_it/rules_block/code.py @@ -1,4 +1,5 @@ """Code block (4 spaces padded).""" + import logging from .state_block import StateBlock diff --git a/markdown_it/rules_block/heading.py b/markdown_it/rules_block/heading.py index 850ffb50..afcf9ed4 100644 --- a/markdown_it/rules_block/heading.py +++ b/markdown_it/rules_block/heading.py @@ -1,4 +1,5 @@ -""" Atex heading (#, ##, ...) """ +"""Atex heading (#, ##, ...)""" + from __future__ import annotations import logging diff --git a/markdown_it/rules_block/hr.py b/markdown_it/rules_block/hr.py index 16df05f2..fca7d79d 100644 --- a/markdown_it/rules_block/hr.py +++ b/markdown_it/rules_block/hr.py @@ -2,6 +2,7 @@ At least 3 of these characters on a line * - _ """ + import logging from ..common.utils import isStrSpace diff --git a/markdown_it/rules_block/paragraph.py b/markdown_it/rules_block/paragraph.py index 5388a4b1..30ba8777 100644 --- a/markdown_it/rules_block/paragraph.py +++ b/markdown_it/rules_block/paragraph.py @@ -1,4 +1,5 @@ """Paragraph.""" + import logging from .state_block import StateBlock diff --git a/markdown_it/rules_core/normalize.py b/markdown_it/rules_core/normalize.py index c9f8d0d5..32439243 100644 --- a/markdown_it/rules_core/normalize.py +++ b/markdown_it/rules_core/normalize.py @@ -1,4 +1,5 @@ """Normalize input string.""" + import re from .state_core import StateCore @@ -13,6 +14,6 @@ def normalize(state: StateCore) -> None: string = NEWLINES_RE.sub("\n", state.src) # Replace NULL characters - string = NULL_RE.sub("\uFFFD", string) + string = NULL_RE.sub("\ufffd", string) state.src = string diff --git a/markdown_it/rules_core/replacements.py b/markdown_it/rules_core/replacements.py index 14912e17..bcc99800 100644 --- a/markdown_it/rules_core/replacements.py +++ b/markdown_it/rules_core/replacements.py @@ -13,6 +13,7 @@ * ``--`` → &ndash * ``---`` → &mdash """ + from __future__ import annotations import logging diff --git a/markdown_it/rules_core/smartquotes.py b/markdown_it/rules_core/smartquotes.py index c98fbd71..f9b8b457 100644 --- a/markdown_it/rules_core/smartquotes.py +++ b/markdown_it/rules_core/smartquotes.py @@ -1,5 +1,5 @@ -"""Convert straight quotation marks to typographic ones -""" +"""Convert straight quotation marks to typographic ones""" + from __future__ import annotations import re diff --git a/markdown_it/rules_core/text_join.py b/markdown_it/rules_core/text_join.py index d54ccbbc..5379f6d7 100644 --- a/markdown_it/rules_core/text_join.py +++ b/markdown_it/rules_core/text_join.py @@ -5,6 +5,7 @@ For example, `\\:)` shouldn't be replaced with an emoji. """ + from __future__ import annotations from ..token import Token diff --git a/markdown_it/rules_inline/balance_pairs.py b/markdown_it/rules_inline/balance_pairs.py index bbb2101c..9c63b27f 100644 --- a/markdown_it/rules_inline/balance_pairs.py +++ b/markdown_it/rules_inline/balance_pairs.py @@ -1,4 +1,5 @@ """Balance paired characters (*, _, etc) in inline tokens.""" + from __future__ import annotations from .state_inline import Delimiter, StateInline diff --git a/markdown_it/rules_inline/escape.py b/markdown_it/rules_inline/escape.py index 9f68b5df..0fca6c84 100644 --- a/markdown_it/rules_inline/escape.py +++ b/markdown_it/rules_inline/escape.py @@ -1,6 +1,7 @@ """ Process escaped chars and hardbreaks """ + from ..common.utils import isStrSpace from .state_inline import StateInline diff --git a/markdown_it/rules_inline/linkify.py b/markdown_it/rules_inline/linkify.py index 88224e78..3669396e 100644 --- a/markdown_it/rules_inline/linkify.py +++ b/markdown_it/rules_inline/linkify.py @@ -1,4 +1,5 @@ """Process links like https://example.org/""" + import re from .state_inline import StateInline diff --git a/markdown_it/rules_inline/newline.py b/markdown_it/rules_inline/newline.py index ca8f1db0..d05ee6da 100644 --- a/markdown_it/rules_inline/newline.py +++ b/markdown_it/rules_inline/newline.py @@ -1,4 +1,5 @@ """Proceess '\n'.""" + from ..common.utils import charStrAt, isStrSpace from .state_inline import StateInline diff --git a/markdown_it/tree.py b/markdown_it/tree.py index 6641e5a4..7e775204 100644 --- a/markdown_it/tree.py +++ b/markdown_it/tree.py @@ -2,6 +2,7 @@ This module is not part of upstream JavaScript markdown-it. """ + from __future__ import annotations from collections.abc import Generator, Sequence @@ -78,12 +79,10 @@ def __repr__(self) -> str: return f"{type(self).__name__}({self.type})" @overload - def __getitem__(self: _NodeType, item: int) -> _NodeType: - ... + def __getitem__(self: _NodeType, item: int) -> _NodeType: ... @overload - def __getitem__(self: _NodeType, item: slice) -> list[_NodeType]: - ... + def __getitem__(self: _NodeType, item: slice) -> list[_NodeType]: ... def __getitem__(self: _NodeType, item: int | slice) -> _NodeType | list[_NodeType]: return self.children[item] diff --git a/scripts/build_fuzzers.py b/scripts/build_fuzzers.py index 3dce8ddf..00cc1198 100644 --- a/scripts/build_fuzzers.py +++ b/scripts/build_fuzzers.py @@ -1,4 +1,5 @@ """Build fuzzers idempotently in a given folder.""" + import argparse from pathlib import Path import subprocess diff --git a/scripts/profiler.py b/scripts/profiler.py index a593baa1..bdee697c 100644 --- a/scripts/profiler.py +++ b/scripts/profiler.py @@ -4,6 +4,7 @@ - `tox -e profile` - `firefox .tox/prof/output.svg` """ + from pathlib import Path from markdown_it import MarkdownIt diff --git a/tests/test_api/test_plugin_creation.py b/tests/test_api/test_plugin_creation.py index d5bda748..d555be18 100644 --- a/tests/test_api/test_plugin_creation.py +++ b/tests/test_api/test_plugin_creation.py @@ -1,6 +1,7 @@ """Test basic plugin creation functionality: that they can be added and are called correctly """ + from markdown_it import MarkdownIt diff --git a/tests/test_cmark_spec/test_spec.py b/tests/test_cmark_spec/test_spec.py index 88d9fca7..e5199477 100644 --- a/tests/test_cmark_spec/test_spec.py +++ b/tests/test_cmark_spec/test_spec.py @@ -1,6 +1,7 @@ """In this module tests are run against the full test set, provided by https://github.com/commonmark/CommonMark.git. """ + import json from pathlib import Path diff --git a/tests/test_fuzzer.py b/tests/test_fuzzer.py index f3666cc5..7286f8ea 100644 --- a/tests/test_fuzzer.py +++ b/tests/test_fuzzer.py @@ -5,6 +5,7 @@ In the future, perhaps atheris could be directly used here, but it was not directly apparent how to integrate it into pytest. """ + import pytest from markdown_it import MarkdownIt