Repository: Stewori/pytypes

Issue:
Frozenset seems to not be equal to set?
```python
>>> import typing
>>> from pytypes import type_util
>>> type_util._isinstance(frozenset({1, 2, 'a', None, 'b'}), typing.AbstractSet[typing.Union[str, int, None]])
False
>>> type_util._isinstance({1, 2, 'a', None, 'b'}, typing.AbstractSet[typing.Union[str, int, type(None)]])
True
>>> issubclass(frozenset, typing.AbstractSet)
True
```

Discussion:

Patch:
diff --git a/pytypes/type_util.py b/pytypes/type_util.py
index f6227c8..976f96f 100644
--- a/pytypes/type_util.py
+++ b/pytypes/type_util.py
@@ -22,10 +22,10 @@ import typing
 import collections
 from inspect import isfunction, ismethod, isclass, ismodule
 try:
-    from backports.typing import Tuple, Dict, List, Set, Union, Any, \
+    from backports.typing import Tuple, Dict, List, Set, FrozenSet, Union, Any, \
         Sequence, Mapping, TypeVar, Container, Generic, Sized, Iterable
 except ImportError:
-    from typing import Tuple, Dict, List, Set, Union, Any, \
+    from typing import Tuple, Dict, List, Set, FrozenSet, Union, Any, \
         Sequence, Mapping, TypeVar, Container, Generic, Sized, Iterable
 try:
     # Python 3.7
@@ -465,9 +465,13 @@ def _deep_type(obj, checked, checked_len, depth = None, max_sample = None):
             tpl1 = tuple(_deep_type(t, checked, checked_len2, depth-1) for t in ksmpl)
             tpl2 = tuple(_deep_type(t, checked, checked_len2, depth-1) for t in vsmpl)
         res = Dict[Union[tpl1], Union[tpl2]]
-    elif res == set:
+    elif res == set or res == frozenset:
+        if res == set:
+            typ = Set
+        else:
+            typ = FrozenSet
         if len(obj) == 0:
-            return Empty[Set]
+            return Empty[typ]
         if max_sample == -1 or max_sample >= len(obj)-1 or len(obj) <= 2:
             tpl = tuple(_deep_type(t, checked, depth-1) for t in obj)
         else:
@@ -485,7 +489,7 @@ def _deep_type(obj, checked, checked_len, depth = None, max_sample = None):
                         j -= 1
                 smpl.append(next(itr))
             tpl = tuple(_deep_type(t, checked, depth-1) for t in smpl)
-        res = Set[Union[tpl]]
+        res = typ[Union[tpl]]
     elif res == types.GeneratorType:
         res = get_generator_type(obj)
     elif sys.version_info.major == 2 and isinstance(obj, types.InstanceType):


Test patch:
diff --git a/tests/test_typechecker.py b/tests/test_typechecker.py
index ddd2745..9106d6b 100644
--- a/tests/test_typechecker.py
+++ b/tests/test_typechecker.py
@@ -4664,6 +4664,10 @@ class Test_utils(unittest.TestCase):
         # No exception.
         resolve_fw_decl(Foo)
 
+    # See: https://github.com/Stewori/pytypes/issues/35
+    def test_frozenset(self):
+        self.assertTrue(pytypes.is_of_type(frozenset({1, 2, 'a', None, 'b'}), typing.AbstractSet[typing.Union[str, int, None]]))
+
 
 if __name__ == '__main__':
     unittest.main()