Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #323

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ exclude: >
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.4.3
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.10.0
hooks:
- id: mypy
additional_dependencies: [mdurl]
Expand Down
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
4 changes: 1 addition & 3 deletions markdown_it/rules_inline/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ def link(state: StateInline, silent: bool) -> bool:

label = normalizeReference(label)

ref = (
state.env["references"][label] if label in state.env["references"] else None
)
ref = state.env["references"].get(label, None)
if not ref:
state.pos = oldPos
return False
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ exclude = [
"benchmarking/"
]

[tool.ruff]
[tool.ruff.lint]
extend-select = ["B0", "C4", "I", "ICN", "ISC", "N", "RUF", "SIM", "UP"]
extend-ignore = ["ISC001", "ISC003", "N802", "N803", "N806", "N816", "RUF003"]

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
Loading