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

Markdown: add fake base class to Pattern to fix overrides #10970

Closed
wants to merge 3 commits into from
Closed
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 stubs/Markdown/markdown/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _ReadableStream(Protocol):

class Markdown:
preprocessors: Registry[preprocessors.Preprocessor]
inlinePatterns: Registry[inlinepatterns.Pattern]
inlinePatterns: Registry[inlinepatterns.InlineProcessor | inlinepatterns.Pattern]
treeprocessors: Registry[treeprocessors.Treeprocessor]
postprocessors: Registry[postprocessors.Postprocessor]
parser: blockparser.BlockParser
Expand Down
2 changes: 1 addition & 1 deletion stubs/Markdown/markdown/extensions/smarty.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ class SmartyExtension(Extension):
def educateEllipses(self, md: Markdown) -> None: ...
def educateAngledQuotes(self, md: Markdown) -> None: ...
def educateQuotes(self, md: Markdown) -> None: ...
inlinePatterns: util.Registry[inlinepatterns.Pattern]
inlinePatterns: util.Registry[inlinepatterns.InlineProcessor | inlinepatterns.Pattern]

def makeExtension(**kwargs) -> SmartyExtension: ...
12 changes: 7 additions & 5 deletions stubs/Markdown/markdown/inlinepatterns.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from xml.etree.ElementTree import Element
from markdown import util
from markdown.core import Markdown

def build_inlinepatterns(md: Markdown, **kwargs) -> util.Registry[Pattern]: ...
def build_inlinepatterns(md: Markdown, **kwargs) -> util.Registry[InlineProcessor | Pattern]: ...

NOIMG: str
BACKTICK_RE: str
Expand Down Expand Up @@ -39,21 +39,23 @@ class EmStrongItem(NamedTuple):
builder: str
tags: str

class Pattern:
class _BasePattern:
ANCESTOR_EXCLUDES: ClassVar[Collection[str]]
pattern: str
compiled_re: re.Pattern[str]
md: Markdown
def __init__(self, pattern: str, md: Markdown | None = None) -> None: ...
def getCompiledRegExp(self) -> re.Pattern[str]: ...
def handleMatch(self, m: re.Match[str]) -> str | Element | None: ...
def type(self) -> str: ...
def unescape(self, text: str) -> str: ...

class InlineProcessor(Pattern):
class Pattern(_BasePattern):
def handleMatch(self, m: re.Match[str]) -> str | Element | None: ...

class InlineProcessor(_BasePattern):
safe_mode: bool
def __init__(self, pattern: str, md: Markdown | None = None) -> None: ...
def handleMatch(self, m: re.Match[str], data: str) -> tuple[Element | str | None, int | None, int | None]: ... # type: ignore[override]
def handleMatch(self, m: re.Match[str], data: str) -> tuple[Element | str | None, int | None, int | None]: ...

class SimpleTextPattern(Pattern): ...
class SimpleTextInlineProcessor(InlineProcessor): ...
Expand Down
Loading