summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wikimini/__init__.py6
-rw-r--r--wikimini/templates/__init__.py8
2 files changed, 9 insertions, 5 deletions
diff --git a/wikimini/__init__.py b/wikimini/__init__.py
index 00179cc..3e344fd 100644
--- a/wikimini/__init__.py
+++ b/wikimini/__init__.py
@@ -5,7 +5,7 @@ import requests
from tabulate import tabulate
-from typing import List, Union, Tuple
+from typing import List, Union, Tuple, Sequence
from .document import (
Plain, BlockLink, InlineLink, Verbatim, Document, Node, Block, ItemList,
@@ -98,7 +98,7 @@ class Wikimini:
def convert(
self,
obj: Union[mwp.wikicode.Wikicode, mwp.nodes.Node],
- ) -> Union[Document, List[Node], List[Block]]:
+ ) -> Union[Document, Sequence[Node], Sequence[Block]]:
"""Function that converts and renders a node.
This function is exposed for template implementors, for normal usage,
@@ -127,7 +127,7 @@ class Wikimini:
[Plain(mwp.wikicode.Wikicode([obj]).strip_code(collapse=False))]
if isinstance(obj, mwp.wikicode.Wikicode):
- document = []
+ document: List[Block] = []
for node in obj.nodes:
current = self.convert(node)
diff --git a/wikimini/templates/__init__.py b/wikimini/templates/__init__.py
index ebe3bbc..533ba5e 100644
--- a/wikimini/templates/__init__.py
+++ b/wikimini/templates/__init__.py
@@ -7,15 +7,19 @@ and the :class:`~mwparserfromhell.nodes.template.Template` node to convert, and
returns a string with the template output (see :const:`Template`).
"""
import copy
-from typing import Callable, Optional
+from typing import Callable, Optional, Union, Sequence
import mwparserfromhell as mwp
from .. import Wikimini
+from ..document import Block, Node
#: The type of a template render function.
-Template = Callable[[Wikimini, mwp.nodes.template.Template], str]
+Template = Callable[
+ [Wikimini, mwp.nodes.template.Template],
+ Union[Sequence[Block], Sequence[Node]]
+]
class Registry: