Skip to content

Commit 4fcff94

Browse files
committed
[Markdown] Add toc.unique's counters parameter and DelimiterProcessor.rule_of_3
Markdown 3.11.3 gave `unique()` an optional `counters` cache and `DelimiterProcessor` a static `rule_of_3()`; neither is in the stubs, so today's daily stubtest run reported both. Verified against the installed package: `inspect.signature(toc.unique)` is `(id: str, ids: MutableSet[str], counters: dict[str, int] | None = None) -> str`, and `rule_of_3` is a `staticmethod` with `(opener: int, closer: int) -> bool`. stubtest reproduces the two errors from the issue without this change and is clean with it; `tests/mypy_test.py stubs/Markdown` passes on 3.10-3.13. Closes #16709
1 parent 64c9da7 commit 4fcff94

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎stubs/Markdown/markdown/extensions/toc.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class _TocToken(_FlatTocToken):
2222

2323
def slugify(value: str, separator: str, unicode: bool = False) -> str: ...
2424
def slugify_unicode(value: str, separator: str) -> str: ...
25-
def unique(id: str, ids: MutableSet[str]) -> str: ...
25+
def unique(id: str, ids: MutableSet[str], counters: dict[str, int] | None = None) -> str: ...
2626
@deprecated("Use `render_inner_html` and `striptags` instead.")
2727
def get_name(el: Element) -> str: ...
2828
@deprecated("Use `run_postprocessors`, `render_inner_html` and/or `striptags` instead.")

‎stubs/Markdown/markdown/inlinepatterns.pyi‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class DelimiterProcessor(InlineProcessor):
111111
def reset(self) -> None: ...
112112
def increment_next_position(self, start: int, count: int) -> None: ...
113113
def get_cached_result(self, pos: int, data: str) -> tuple[Element, int, int]: ...
114+
@staticmethod
115+
def rule_of_3(opener: int, closer: int) -> bool: ...
114116
def get_match(self, data: str, start: int) -> re.Match[str] | None: ...
115117
def search(self, data: str, start: int) -> re.Match[str] | None: ...
116118
def add_region(self, delim: Delimiter, a: int, b: int, c: int, d: int, size: int) -> None: ...

0 commit comments

Comments
 (0)