Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reorganize typeit.schema * Add support for pyrsistent PVector and PMap * Add support for Literals #21 * Release 0.12.0
- Loading branch information
Maxim Avanov
committed
Apr 24, 2019
1 parent
30ff97f
commit 0000747
Showing
23 changed files
with
639 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
PROJECT=typeit | ||
|
||
test: | ||
pytest -s tests/ | ||
|
||
typecheck: | ||
mypy --config-file setup.cfg --package $(PROJECT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import NamedTuple, Any, Optional | ||
|
||
import pytest | ||
|
||
import typeit as ty | ||
import pyrsistent as ps | ||
|
||
|
||
def test_pyrsistent_types(): | ||
class X(NamedTuple): | ||
a: ps.typing.PMap[str, Any] | ||
b: ps.typing.PVector[ps.typing.PMap] | ||
c: Optional[ps.typing.PMap] | ||
|
||
mk_x, dict_x = ty.type_constructor ^ X | ||
|
||
data = { | ||
'a': {'x': 'x', 'y': 'y'}, | ||
'b': [{'x': 'x', 'y': 'y'}], | ||
'c': None | ||
} | ||
x = mk_x(data) | ||
assert isinstance(x.a, ps.PMap) | ||
assert isinstance(x.b, ps.PVector) | ||
assert isinstance(x.b[0], ps.PMap) | ||
assert dict_x(x) == data | ||
|
||
data = { | ||
'a': None, | ||
'b': [{'x': 'x', 'y': 'y'}], | ||
'c': {'x': 'x', 'y': 'y'} | ||
} | ||
with pytest.raises(ty.Invalid): | ||
mk_x(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from .parser import type_constructor | ||
from .codegen import typeit | ||
from . import flags | ||
from .schema.errors import Invalid | ||
from .utils import iter_invalid | ||
|
||
__all__ = ['type_constructor', 'typeit', 'flags'] | ||
__all__ = ['type_constructor', 'typeit', 'flags', 'Invalid', 'iter_invalid'] |
Oops, something went wrong.