Skip to content

Commit

Permalink
refactor: BlockProcessor already receives strings, use them as such
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Jan 1, 2021
1 parent c8584f3 commit bcf7da9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/mkdocstrings/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""
import re
from collections import ChainMap
from typing import Any, Mapping, Tuple
from typing import Any, Mapping, MutableSequence, Tuple
from xml.etree.ElementTree import XML, Element, ParseError # noqa: S405 (we choose to trust the XML input)

import yaml
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(self, parser: BlockParser, md: Markdown, config: dict, handlers: Ha
self._handlers = handlers
self._updated_env = False

def test(self, parent: Element, block: Element) -> bool:
def test(self, parent: Element, block: str) -> bool:
"""
Match our autodoc instructions.
Expand All @@ -123,9 +123,9 @@ def test(self, parent: Element, block: Element) -> bool:
Returns:
Whether this block should be processed or not.
"""
return bool(self.regex.search(str(block)))
return bool(self.regex.search(block))

def run(self, parent: Element, blocks: Element) -> None:
def run(self, parent: Element, blocks: MutableSequence[str]) -> None:
"""
Run code on the matched blocks.
Expand All @@ -137,7 +137,7 @@ def run(self, parent: Element, blocks: Element) -> None:
blocks: The rest of the blocks to be processed.
"""
block = blocks.pop(0)
match = self.regex.search(str(block))
match = self.regex.search(block)

if match:
if match.start() > 0:
Expand All @@ -151,7 +151,7 @@ def run(self, parent: Element, blocks: Element) -> None:
identifier = match["name"]
heading_level = match["heading"].count("#")
log.debug(f"Matched '::: {identifier}'")
xml_element = self.process_block(identifier, str(block), heading_level)
xml_element = self.process_block(identifier, block, heading_level)
parent.append(xml_element)

if the_rest:
Expand Down

0 comments on commit bcf7da9

Please sign in to comment.