Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 22, 2024
1 parent f6acb93 commit 32b0edb
Show file tree
Hide file tree
Showing 35 changed files with 53 additions and 34 deletions.
1 change: 1 addition & 0 deletions markdown_it/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A Python port of Markdown-It"""

__all__ = ("MarkdownIt",)
__version__ = "3.0.0"

Expand Down
1 change: 1 addition & 0 deletions markdown_it/cli/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Parse one or more markdown files, convert each to HTML, and print to stdout.
"""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions markdown_it/common/entities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""HTML5 entities map: { name -> characters }."""

import html.entities

entities = {name.rstrip(";"): chars for name, chars in html.entities.html5.items()}
3 changes: 1 addition & 2 deletions markdown_it/common/html_re.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Regexps to match html elements
"""
"""Regexps to match html elements"""

import re

Expand Down
4 changes: 2 additions & 2 deletions markdown_it/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Utilities for parsing source text
"""
"""Utilities for parsing source text"""

from __future__ import annotations

import re
Expand Down
4 changes: 2 additions & 2 deletions markdown_it/helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions markdown_it/helpers/parse_link_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
returns the end of the label
"""

from markdown_it.rules_inline import StateInline


Expand Down
4 changes: 2 additions & 2 deletions markdown_it/helpers/parse_link_title.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Parse link title
"""
"""Parse link title"""

from ..common.utils import charCodeAt, unescapeAll


Expand Down
15 changes: 5 additions & 10 deletions markdown_it/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions markdown_it/parser_block.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Block-level tokenizer."""

from __future__ import annotations

import logging
Expand Down
9 changes: 5 additions & 4 deletions markdown_it/parser_core.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions markdown_it/parser_inline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tokenizes paragraph content.
"""
"""Tokenizes paragraph content."""

from __future__ import annotations

from typing import TYPE_CHECKING, Callable
Expand Down
1 change: 1 addition & 0 deletions markdown_it/presets/commonmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- block: table
- inline: strikethrough
"""

from ..utils import PresetType


Expand Down
1 change: 1 addition & 0 deletions markdown_it/presets/default.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""markdown-it default options."""

from ..utils import PresetType


Expand Down
1 change: 1 addition & 0 deletions markdown_it/presets/zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions markdown_it/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,8 +22,7 @@ class RendererProtocol(Protocol):

def render(
self, tokens: Sequence[Token], options: OptionsDict, env: EnvType
) -> Any:
...
) -> Any: ...


class RendererHTML(RendererProtocol):
Expand Down
1 change: 1 addition & 0 deletions markdown_it/ruler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_block/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Code block (4 spaces padded)."""

import logging

from .state_block import StateBlock
Expand Down
3 changes: 2 additions & 1 deletion markdown_it/rules_block/heading.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Atex heading (#, ##, ...) """
"""Atex heading (#, ##, ...)"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_block/hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
At least 3 of these characters on a line * - _
"""

import logging

from ..common.utils import isStrSpace
Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_block/paragraph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Paragraph."""

import logging

from .state_block import StateBlock
Expand Down
3 changes: 2 additions & 1 deletion markdown_it/rules_core/normalize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Normalize input string."""

import re

from .state_core import StateCore
Expand All @@ -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
1 change: 1 addition & 0 deletions markdown_it/rules_core/replacements.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* ``--`` → &ndash
* ``---`` → &mdash
"""

from __future__ import annotations

import logging
Expand Down
4 changes: 2 additions & 2 deletions markdown_it/rules_core/smartquotes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Convert straight quotation marks to typographic ones
"""
"""Convert straight quotation marks to typographic ones"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_core/text_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
For example, `\\:)` shouldn't be replaced with an emoji.
"""

from __future__ import annotations

from ..token import Token
Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_inline/balance_pairs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Balance paired characters (*, _, etc) in inline tokens."""

from __future__ import annotations

from .state_inline import Delimiter, StateInline
Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_inline/escape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Process escaped chars and hardbreaks
"""

from ..common.utils import isStrSpace
from .state_inline import StateInline

Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_inline/linkify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Process links like https://example.org/"""

import re

from .state_inline import StateInline
Expand Down
1 change: 1 addition & 0 deletions markdown_it/rules_inline/newline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Proceess '\n'."""

from ..common.utils import charStrAt, isStrSpace
from .state_inline import StateInline

Expand Down
7 changes: 3 additions & 4 deletions markdown_it/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module is not part of upstream JavaScript markdown-it.
"""

from __future__ import annotations

from collections.abc import Generator, Sequence
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions scripts/build_fuzzers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Build fuzzers idempotently in a given folder."""

import argparse
from pathlib import Path
import subprocess
Expand Down
1 change: 1 addition & 0 deletions scripts/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- `tox -e profile`
- `firefox .tox/prof/output.svg`
"""

from pathlib import Path

from markdown_it import MarkdownIt
Expand Down
1 change: 1 addition & 0 deletions tests/test_api/test_plugin_creation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test basic plugin creation functionality:
that they can be added and are called correctly
"""

from markdown_it import MarkdownIt


Expand Down
1 change: 1 addition & 0 deletions tests/test_cmark_spec/test_spec.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/test_fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 32b0edb

Please sign in to comment.