diff options
Diffstat (limited to 'logilab')
-rw-r--r-- | logilab/common/ureports/__init__.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/logilab/common/ureports/__init__.py b/logilab/common/ureports/__init__.py index cf6e098..bb95223 100644 --- a/logilab/common/ureports/__init__.py +++ b/logilab/common/ureports/__init__.py @@ -24,13 +24,15 @@ __docformat__ = "restructuredtext en" import sys -from typing import Any, Optional, Union, List, Generator, Tuple, Callable, TextIO +from typing import Any, Optional, Union, List as ListType, Generator, Tuple, Callable, TextIO from logilab.common.compat import StringIO from logilab.common.textutils import linesep from logilab.common.tree import VNode from logilab.common.ureports.nodes import Table, Section, Link, Paragraph, Title, Text +from logilab.common.ureports.nodes import VerbatimText, Image, Span, List # noqa + def get_nodes(node, klass): """return an iterator on all children node of the given klass""" @@ -54,7 +56,7 @@ def build_summary(layout, level=1): """make a summary for the report, including X level""" assert level > 0 level -= 1 - summary = List(klass="summary") + summary = ListType(klass="summary") for child in layout.children: if not isinstance(child, Section): continue @@ -97,7 +99,7 @@ class BaseWriter(object): if not encoding: encoding = getattr(stream, "encoding", "UTF-8") self.encoding = encoding or "UTF-8" - self.__compute_funcs: List[Tuple[Callable[[str], Any], Callable[[str], Any]]] = [] + self.__compute_funcs: ListType[Tuple[Callable[[str], Any], Callable[[str], Any]]] = [] self.out = stream self.begin_format(layout) layout.accept(self) @@ -130,12 +132,12 @@ class BaseWriter(object): def end_format(self, layout: Any) -> None: """finished to format a layout""" - def get_table_content(self, table: Table) -> List[List[str]]: + def get_table_content(self, table: Table) -> ListType[ListType[str]]: """trick to get table content without actually writing it return an aligned list of lists containing table cells values as string """ - result: List[List[str]] = [[]] + result: ListType[ListType[str]] = [[]] # mypy: "Table" has no attribute "cols" # dynamic attribute cols = table.cols # type: ignore @@ -189,7 +191,7 @@ class BaseWriter(object): self.__compute_funcs.append((write, writeln)) - # mypy: Item "Table" of "Union[List[Any], Table, Title]" has no attribute "children" + # mypy: Item "Table" of "Union[ListType[Any], Table, Title]" has no attribute "children" # dynamic attribute? for child in layout.children: # type: ignore stream = StringIO() |