Skip to content

Commit

Permalink
Merge f70e79d into 1eb48b8
Browse files Browse the repository at this point in the history
  • Loading branch information
avanov committed Jun 9, 2019
2 parents 1eb48b8 + f70e79d commit 144c0bf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Expand Up @@ -2,8 +2,8 @@
CHANGELOG
=========

0.12.1
============
0.12.1, 0.12.2
==============

* Experimental support for SumType.

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -53,7 +53,7 @@
# The short X.Y version.
version = '0.12'
# The full version, including alpha/beta/rc tags.
release = '0.12.1'
release = '0.12.2'

# 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 @@ -38,7 +38,7 @@ def requirements(at_path: Path):
# ----------------------------

setup(name='typeit',
version='0.12.1',
version='0.12.2',
description='typeit brings typed data into your project',
long_description=README,
classifiers=[
Expand Down
6 changes: 3 additions & 3 deletions tests/test_parser.py
Expand Up @@ -12,7 +12,7 @@
from typeit import parser as p
from typeit import flags
from typeit import schema
from typeit.sums import SumType, Either
from typeit.sums import Either


def test_parser_empty_struct():
Expand Down Expand Up @@ -260,7 +260,7 @@ class X(NamedTuple):
assert isinstance(x.x, Either)
assert isinstance(x.x, MyEither)
assert isinstance(x.x, MyEither.Left)
assert not isinstance(x.x, Either.Left)
assert isinstance(x.x, Either.Left)
assert not isinstance(x.x, Either.Right)
assert not isinstance(x.x, MyEither.Right)
assert isinstance(x.x.err, str)
Expand All @@ -278,7 +278,7 @@ class X(NamedTuple):
assert isinstance(x.x, Either)
assert isinstance(x.x, MyEither)
assert isinstance(x.x, MyEither.Right)
assert not isinstance(x.x, Either.Right)
assert isinstance(x.x, Either.Right)
assert not isinstance(x.x, Either.Left)
assert not isinstance(x.x, MyEither.Left)
assert isinstance(x.x.data, Data)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sums.py
Expand Up @@ -113,7 +113,7 @@ class Right:
assert isinstance(x, ServiceResponse)
assert isinstance(x, ServiceResponse.Left)
assert isinstance(x, Either)
assert not isinstance(x, Either.Left)
assert isinstance(x, Either.Left)

class AlternativeEither(SumType):
class Left: ...
Expand Down
8 changes: 7 additions & 1 deletion typeit/sums/impl.py
Expand Up @@ -127,10 +127,16 @@ class SumType(metaclass=SumTypeMetaclass):

def __instancecheck__(self, other) -> bool:
try:
return self.__variant_meta__ is other.__variant_meta__
m1 = self.__variant_meta__
m2 = other.__variant_meta__
except AttributeError:
return False

if not issubclass(m2.variant_of, self.__class__):
return False

return m1.variant_name == m2.variant_name

@classmethod
def values(cls) -> Set:
return set(cls.__sum_meta__.values.keys())
Expand Down

0 comments on commit 144c0bf

Please sign in to comment.