Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
py-ver-major: [3]
py-ver-minor: [9, 10, 11, 12, 13, 14]
py-ver-minor: [10, 11, 12, 13, 14]
fail-fast: false

env:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Style guide:
- Python 3.9+ compatible code
- Python 3.10+ compatible code
- PEP-484 type hints
- Prefer new style format strings https://pyformat.info/
- Use ``make format`` to format your code
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bandit:
bandit --recursive --exclude schema_salad/tests/ schema_salad

pyupgrade: $(filter-out schema_salad/metaschema.py,$(PYSOURCES))
pyupgrade --exit-zero-even-if-changed --py39-plus $^
pyupgrade --exit-zero-even-if-changed --py310-plus $^
auto-walrus $^

release-test: FORCE
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ generation, and transformation to RDF_. Salad provides a bridge
between document and record oriented data modeling and the Semantic
Web.

The Schema Salad library is Python 3.9+ only.
The Schema Salad library is Python 3.10+ only.

Installation
------------
Expand Down
17 changes: 8 additions & 9 deletions mypy-stubs/mistune/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Dict, Iterable, List, Optional, Union

from typing_extensions import Literal
from collections.abc import Iterable
from typing import Any, Literal, TypeAlias

from .block_parser import BlockParser as BlockParser
from .core import BaseRenderer as BaseRenderer
Expand Down Expand Up @@ -32,20 +31,20 @@ __all__ = [
"markdown",
]

RendererRef = Union[Literal["html", "ast"], BaseRenderer]
RendererRef: TypeAlias = Literal["html", "ast"] | BaseRenderer

def create_markdown(
escape: bool = True,
hard_wrap: bool = False,
renderer: Optional[RendererRef] = "html",
plugins: Optional[Iterable[PluginRef]] = None,
renderer: RendererRef | None = "html",
plugins: Iterable[PluginRef] | None = None,
) -> Markdown: ...

html: Markdown

def markdown(
text: str,
escape: bool = True,
renderer: Optional[RendererRef] = "html",
plugins: Optional[Iterable[Any]] = None,
) -> Union[str, List[Dict[str, Any]]]: ...
renderer: RendererRef | None = "html",
plugins: Iterable[Any] | None = None,
) -> str | list[dict[str, Any]]: ...
30 changes: 15 additions & 15 deletions mypy-stubs/mistune/block_parser.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import ClassVar, Dict, Iterable, List, Match, Optional, Pattern, Tuple
from collections.abc import Iterable
from re import Match, Pattern
from typing import ClassVar

from .core import BlockState as BlockState
from .core import Parser as Parser
Expand All @@ -22,29 +24,27 @@ class BlockParser(Parser[BlockState]):
BLANK_LINE: Pattern[str]
RAW_HTML: str
BLOCK_HTML: str
SPECIFICATION: ClassVar[Dict[str, str]]
SPECIFICATION: ClassVar[dict[str, str]]
DEFAULT_RULES: ClassVar[Iterable[str]]
block_quote_rules: List[str]
list_rules: List[str]
block_quote_rules: list[str]
list_rules: list[str]
max_nested_level: int
def __init__(
self,
block_quote_rules: Optional[List[str]] = None,
list_rules: Optional[List[str]] = None,
block_quote_rules: list[str] | None = None,
list_rules: list[str] | None = None,
max_nested_level: int = 6,
) -> None: ...
def parse_blank_line(self, m: Match[str], state: BlockState) -> int: ...
def parse_thematic_break(self, m: Match[str], state: BlockState) -> int: ...
def parse_indent_code(self, m: Match[str], state: BlockState) -> int: ...
def parse_fenced_code(self, m: Match[str], state: BlockState) -> Optional[int]: ...
def parse_fenced_code(self, m: Match[str], state: BlockState) -> int | None: ...
def parse_atx_heading(self, m: Match[str], state: BlockState) -> int: ...
def parse_setex_heading(self, m: Match[str], state: BlockState) -> Optional[int]: ...
def parse_ref_link(self, m: Match[str], state: BlockState) -> Optional[int]: ...
def extract_block_quote(
self, m: Match[str], state: BlockState
) -> Tuple[str, Optional[int]]: ...
def parse_setex_heading(self, m: Match[str], state: BlockState) -> int | None: ...
def parse_ref_link(self, m: Match[str], state: BlockState) -> int | None: ...
def extract_block_quote(self, m: Match[str], state: BlockState) -> tuple[str, int | None]: ...
def parse_block_quote(self, m: Match[str], state: BlockState) -> int: ...
def parse_list(self, m: Match[str], state: BlockState) -> int: ...
def parse_block_html(self, m: Match[str], state: BlockState) -> Optional[int]: ...
def parse_raw_html(self, m: Match[str], state: BlockState) -> Optional[int]: ...
def parse(self, state: BlockState, rules: Optional[List[str]] = None) -> None: ...
def parse_block_html(self, m: Match[str], state: BlockState) -> int | None: ...
def parse_raw_html(self, m: Match[str], state: BlockState) -> int | None: ...
def parse(self, state: BlockState, rules: list[str] | None = None) -> None: ...
62 changes: 24 additions & 38 deletions mypy-stubs/mistune/core.pyi
Original file line number Diff line number Diff line change
@@ -1,85 +1,71 @@
import re
from collections.abc import Generator as Generator
from typing import (
Any,
Callable,
ClassVar,
Dict,
Generic,
Iterable,
List,
Match,
MutableMapping,
Optional,
Pattern,
Type,
TypeVar,
Union,
)
from collections.abc import Callable, Iterable, MutableMapping
from re import Match, Pattern
from typing import Any, ClassVar, Generic, TypeVar

from typing_extensions import Self

class BlockState:
src: str
tokens: List[Dict[str, Any]]
tokens: list[dict[str, Any]]
cursor: int
cursor_max: int
list_tight: bool
parent: Any
env: MutableMapping[str, Any]
def __init__(self, parent: Optional[Any] = None) -> None: ...
def __init__(self, parent: Any | None = None) -> None: ...
def child_state(self, src: str) -> BlockState: ...
def process(self, src: str) -> None: ...
def find_line_end(self) -> int: ...
def get_text(self, end_pos: int) -> str: ...
def last_token(self) -> Any: ...
def prepend_token(self, token: Dict[str, Any]) -> None: ...
def append_token(self, token: Dict[str, Any]) -> None: ...
def prepend_token(self, token: dict[str, Any]) -> None: ...
def append_token(self, token: dict[str, Any]) -> None: ...
def add_paragraph(self, text: str) -> None: ...
def append_paragraph(self) -> Optional[int]: ...
def append_paragraph(self) -> int | None: ...
def depth(self) -> int: ...

class InlineState:
env: MutableMapping[str, Any]
src: str
tokens: List[Dict[str, Any]]
tokens: list[dict[str, Any]]
in_image: bool
in_link: bool
in_emphasis: bool
in_strong: bool
def __init__(self, env: MutableMapping[str, Any]) -> None: ...
def prepend_token(self, token: Dict[str, Any]) -> None: ...
def append_token(self, token: Dict[str, Any]) -> None: ...
def prepend_token(self, token: dict[str, Any]) -> None: ...
def append_token(self, token: dict[str, Any]) -> None: ...
def copy(self) -> InlineState: ...

ST = TypeVar("ST", InlineState, BlockState)

class Parser(Generic[ST]):
sc_flag: re._FlagsType
state_cls: Type[ST]
SPECIFICATION: ClassVar[Dict[str, str]]
state_cls: type[ST]
SPECIFICATION: ClassVar[dict[str, str]]
DEFAULT_RULES: ClassVar[Iterable[str]]
specification: Dict[str, str]
specification: dict[str, str]
rules: Iterable[str]
def __init__(self) -> None: ...
def compile_sc(self, rules: Optional[List[str]] = None) -> Pattern[str]: ...
def compile_sc(self, rules: list[str] | None = None) -> Pattern[str]: ...
def register(
self,
name: str,
pattern: Union[str, None],
func: Callable[[Self, Match[str], ST], Optional[int]],
before: Optional[str] = None,
pattern: str | None,
func: Callable[[Self, Match[str], ST], int | None],
before: str | None = None,
) -> None: ...
def register_rule(self, name: str, pattern: str, func: Any) -> None: ...
@staticmethod
def insert_rule(rules: List[str], name: str, before: Optional[str] = None) -> None: ...
def parse_method(self, m: Match[str], state: ST) -> Optional[int]: ...
def insert_rule(rules: list[str], name: str, before: str | None = None) -> None: ...
def parse_method(self, m: Match[str], state: ST) -> int | None: ...

class BaseRenderer:
NAME: ClassVar[str]
def __init__(self) -> None: ...
def register(self, name: str, method: Callable[..., str]) -> None: ...
def render_token(self, token: Dict[str, Any], state: BlockState) -> str: ...
def iter_tokens(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> Iterable[str]: ...
def render_tokens(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> str: ...
def __call__(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> str: ...
def render_token(self, token: dict[str, Any], state: BlockState) -> str: ...
def iter_tokens(self, tokens: Iterable[dict[str, Any]], state: BlockState) -> Iterable[str]: ...
def render_tokens(self, tokens: Iterable[dict[str, Any]], state: BlockState) -> str: ...
def __call__(self, tokens: Iterable[dict[str, Any]], state: BlockState) -> str: ...
4 changes: 1 addition & 3 deletions mypy-stubs/mistune/directives/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

from ._base import BaseDirective as BaseDirective
from ._base import DirectiveParser as DirectiveParser
from ._base import DirectivePlugin as DirectivePlugin
Expand All @@ -25,4 +23,4 @@ __all__ = [
]

class RstDirective(RSTDirective):
def __init__(self, plugins: List[DirectivePlugin]) -> None: ...
def __init__(self, plugins: list[DirectivePlugin]) -> None: ...
43 changes: 16 additions & 27 deletions mypy-stubs/mistune/directives/_base.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import abc
from abc import ABCMeta, abstractmethod
from typing import (
Any,
Callable,
Dict,
Iterable,
List,
Match,
Optional,
Tuple,
Type,
Union,
)
from collections.abc import Callable, Iterable
from re import Match
from typing import Any

from ..block_parser import BlockParser as BlockParser
from ..core import BlockState as BlockState
Expand All @@ -31,42 +22,40 @@ class DirectiveParser(ABCMeta, metaclass=abc.ABCMeta):
@classmethod
def parse_tokens(
cls, block: BlockParser, text: str, state: BlockState
) -> Iterable[Dict[str, Any]]: ...
) -> Iterable[dict[str, Any]]: ...
@staticmethod
def parse_options(m: Match[str]) -> List[Tuple[str, str]]: ...
def parse_options(m: Match[str]) -> list[tuple[str, str]]: ...

class BaseDirective(metaclass=ABCMeta):
parser: Type[DirectiveParser]
directive_pattern: Optional[str]
def __init__(self, plugins: List["DirectivePlugin"]) -> None: ...
parser: type[DirectiveParser]
directive_pattern: str | None
def __init__(self, plugins: list["DirectivePlugin"]) -> None: ...
def register(
self,
name: str,
fn: Callable[
[BlockParser, Match[str], BlockState], Union[Dict[str, Any], List[Dict[str, Any]]]
],
fn: Callable[[BlockParser, Match[str], BlockState], dict[str, Any] | list[dict[str, Any]]],
) -> None: ...
def parse_method(
self, block: BlockParser, m: Match[str], state: BlockState
) -> Union[Dict[str, Any], List[Dict[str, Any]]]: ...
) -> dict[str, Any] | list[dict[str, Any]]: ...
@abstractmethod
def parse_directive(
self, block: BlockParser, m: Match[str], state: BlockState
) -> Optional[int]: ...
def register_block_parser(self, md: Markdown, before: Optional[str] = None) -> None: ...
) -> int | None: ...
def register_block_parser(self, md: Markdown, before: str | None = None) -> None: ...
def __call__(self, markdown: Markdown) -> None: ...

class DirectivePlugin:
parser: Type[DirectiveParser]
parser: type[DirectiveParser]
def __init__(self) -> None: ...
def parse_options(self, m: Match[str]) -> List[Tuple[str, str]]: ...
def parse_options(self, m: Match[str]) -> list[tuple[str, str]]: ...
def parse_type(self, m: Match[str]) -> str: ...
def parse_title(self, m: Match[str]) -> str: ...
def parse_content(self, m: Match[str]) -> str: ...
def parse_tokens(
self, block: BlockParser, text: str, state: BlockState
) -> Iterable[Dict[str, Any]]: ...
) -> Iterable[dict[str, Any]]: ...
def parse(
self, block: BlockParser, m: Match[str], state: BlockState
) -> Union[Dict[str, Any], List[Dict[str, Any]]]: ...
) -> dict[str, Any] | list[dict[str, Any]]: ...
def __call__(self, directive: BaseDirective, md: Markdown) -> None: ...
8 changes: 4 additions & 4 deletions mypy-stubs/mistune/directives/_fenced.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Match, Optional
from re import Match

from _typeshed import Incomplete

Expand All @@ -22,11 +22,11 @@ class FencedDirective(BaseDirective):
parser = FencedParser
markers: Incomplete
directive_pattern: Incomplete
def __init__(self, plugins: List[DirectivePlugin], markers: str = "`~") -> None: ...
def __init__(self, plugins: list[DirectivePlugin], markers: str = "`~") -> None: ...
def parse_directive(
self, block: BlockParser, m: Match[str], state: BlockState
) -> Optional[int]: ...
) -> int | None: ...
def parse_fenced_code(
self, block: BlockParser, m: Match[str], state: BlockState
) -> Optional[int]: ...
) -> int | None: ...
def __call__(self, md: Markdown) -> None: ...
4 changes: 2 additions & 2 deletions mypy-stubs/mistune/directives/_rst.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Match, Optional
from re import Match

from ..block_parser import BlockParser
from ..core import BlockState
Expand All @@ -21,5 +21,5 @@ class RSTDirective(BaseDirective):
directive_pattern: str
def parse_directive(
self, block: BlockParser, m: Match[str], state: BlockState
) -> Optional[int]: ...
) -> int | None: ...
def __call__(self, markdown: Markdown) -> None: ...
5 changes: 3 additions & 2 deletions mypy-stubs/mistune/directives/admonition.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Dict, Match
from re import Match
from typing import Any

from _typeshed import Incomplete

Expand All @@ -10,7 +11,7 @@ from ._base import DirectivePlugin as DirectivePlugin

class Admonition(DirectivePlugin):
SUPPORTED_NAMES: Incomplete
def parse(self, block: BlockParser, m: Match[str], state: BlockState) -> Dict[str, Any]: ...
def parse(self, block: BlockParser, m: Match[str], state: BlockState) -> dict[str, Any]: ...
def __call__(self, directive: BaseDirective, md: Markdown) -> None: ...

def render_admonition(self, text: str, name: str, **attrs: Any) -> str: ...
Expand Down
9 changes: 5 additions & 4 deletions mypy-stubs/mistune/directives/image.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Dict, List, Match, Optional
from re import Match
from typing import Any

from ..block_parser import BlockParser
from ..core import BlockState
Expand All @@ -9,13 +10,13 @@ __all__ = ["Image", "Figure"]

class Image(DirectivePlugin):
NAME: str
def parse(self, block: BlockParser, m: Match[str], state: BlockState) -> Dict[str, Any]: ...
def parse(self, block: BlockParser, m: Match[str], state: BlockState) -> dict[str, Any]: ...
def __call__(self, directive: BaseDirective, md: Markdown) -> None: ...

class Figure(DirectivePlugin):
NAME: str
def parse_directive_content(
self, block: BlockParser, m: Match[str], state: BlockState
) -> Optional[List[Dict[str, Any]]]: ...
def parse(self, block: BlockParser, m: Match[str], state: BlockState) -> Dict[str, Any]: ...
) -> list[dict[str, Any]] | None: ...
def parse(self, block: BlockParser, m: Match[str], state: BlockState) -> dict[str, Any]: ...
def __call__(self, directive: BaseDirective, md: Markdown) -> None: ...
Loading
Loading