diff --git a/petl/util/materialise.py b/petl/util/materialise.py index 0728d77c..eb38f655 100644 --- a/petl/util/materialise.py +++ b/petl/util/materialise.py @@ -4,13 +4,15 @@ import operator from collections import OrderedDict from itertools import islice +from typing import Dict, Tuple, List, Any + from petl.compat import izip_longest, text_type, next from petl.util.base import asindices, Table -def listoflists(tbl): +def listoflists(tbl) -> List[list]: return [list(row) for row in tbl] @@ -18,7 +20,7 @@ def listoflists(tbl): Table.lol = listoflists -def tupleoftuples(tbl): +def tupleoftuples(tbl) -> Tuple[tuple, ...]: return tuple(tuple(row) for row in tbl) @@ -26,7 +28,7 @@ def tupleoftuples(tbl): Table.tot = tupleoftuples -def listoftuples(tbl): +def listoftuples(tbl) -> List[tuple]: return [tuple(row) for row in tbl] @@ -34,7 +36,7 @@ def listoftuples(tbl): Table.lot = listoftuples -def tupleoflists(tbl): +def tupleoflists(tbl) -> Tuple[list, ...]: return tuple(list(row) for row in tbl) @@ -42,7 +44,7 @@ def tupleoflists(tbl): Table.tol = tupleoflists -def columns(table, missing=None): +def columns(table, missing=None) -> OrderedDict: """ Construct a :class:`dict` mapping field names to lists of values. E.g.:: @@ -74,7 +76,7 @@ def columns(table, missing=None): Table.columns = columns -def facetcolumns(table, key, missing=None): +def facetcolumns(table, key, missing=None) -> Dict[Any, Dict[str, Any]]: """ Like :func:`petl.util.materialise.columns` but stratified by values of the given key field. E.g.:: @@ -119,7 +121,7 @@ def facetcolumns(table, key, missing=None): Table.facetcolumns = facetcolumns -def cache(table, n=None): +def cache(table, n=None) -> 'CacheView': """ Wrap the table with a cache that caches up to `n` rows as they are initially requested via iteration (cache all rows be default).