Skip to content

Commit

Permalink
Merge 38b2dc9 into 9890b13
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Avanov committed Jul 1, 2018
2 parents 9890b13 + 38b2dc9 commit 9eb3b6b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -53,7 +53,7 @@
# The short X.Y version.
version = '0.5'
# The full version, including alpha/beta/rc tags.
release = '0.5.0'
release = '0.5.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -23,7 +23,7 @@
# ----------------------------

setup(name='typeit',
version='0.5.0',
version='0.5.1',
description='Type it!',
long_description=README,
classifiers=[
Expand Down
4 changes: 3 additions & 1 deletion tests/test_parser.py
Expand Up @@ -26,11 +26,13 @@ def test_type_with_sequence():
class X(NamedTuple):
x: int
y: Sequence[Any]
z: Sequence[str]

MkX = p.type_constructor(X)

x: X = MkX({'x': 1, 'y': []})
x: X = MkX({'x': 1, 'y': [], 'z': ['Hello']})
assert x.y == []
assert x.z[0] == 'Hello'


def test_type_with_empty_enum_variant():
Expand Down
6 changes: 5 additions & 1 deletion typeit/parser.py
Expand Up @@ -5,6 +5,7 @@
Dict, NamedTuple, Callable,
Sequence, get_type_hints
)
import collections

import inflection
import colander as col
Expand Down Expand Up @@ -221,7 +222,10 @@ def _maybe_node_for_list(typ) -> Optional[col.SequenceSchema]:
# typ is List[T] where T is either unknown Any or a concrete type
if typ in (List[Any], Sequence[Any]):
return col.SequenceSchema(col.SchemaNode(col.Str(allow_empty=True)))
elif insp.get_origin(typ) in (List, Sequence, list):
elif insp.get_origin(typ) in (List,
Sequence,
collections.abc.Sequence,
list):
inner = insp.get_args(typ)[0]
return col.SequenceSchema(decide_node_type(inner))
return None
Expand Down

0 comments on commit 9eb3b6b

Please sign in to comment.