Repository: Stewori/pytypes

Issue:
NoneType' object is not iterable in resolve_fw_decl
```python
>>> import typing
>>> from pytypes import type_util
>>> T = typing.TypeVar('T')
>>> class Foo(typing.Generic[T]):
...   pass
... 
>>> type_util.resolve_fw_decl(Foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable
```

Discussion:

Patch:
diff --git a/pytypes/type_util.py b/pytypes/type_util.py
index 13c991e..f6227c8 100644
--- a/pytypes/type_util.py
+++ b/pytypes/type_util.py
@@ -900,7 +900,7 @@ def resolve_fw_decl(in_type, module_name=None, globs=None, level=0):
                 for in_tp in args])
         ret = resolve_fw_decl(res, None, globs)[1] or ret
         return in_type, ret
-    elif hasattr(in_type, '__args__'):
+    elif hasattr(in_type, '__args__') and in_type.__args__ is not None:
         return in_type, any([resolve_fw_decl(in_tp, None, globs)[1] \
                 for in_tp in in_type.__args__])
     return in_type, False


Test patch:
diff --git a/tests/test_typechecker.py b/tests/test_typechecker.py
index d6acaf9..ddd2745 100644
--- a/tests/test_typechecker.py
+++ b/tests/test_typechecker.py
@@ -23,7 +23,7 @@ from numbers import Real
 import pytypes
 from pytypes import typechecked, override, auto_override, no_type_check, get_types, \
     get_type_hints, TypeCheckError, InputTypeError, ReturnTypeError, OverrideError, \
-    TypeSyntaxError, check_argument_types, annotations, get_member_types
+    TypeSyntaxError, check_argument_types, annotations, get_member_types, resolve_fw_decl
 pytypes.clean_traceback = False
 try:
     from backports import typing
@@ -4652,5 +4652,18 @@ class Test_check_argument_types_Python3_5(unittest.TestCase):
         self.assertRaises(InputTypeError, lambda:
                 py3.test_inner_class_testf1_err())
 
+
+class Test_utils(unittest.TestCase):
+    # See: https://github.com/Stewori/pytypes/issues/36
+    def test_resolve_fw_decl(self):
+        T = typing.TypeVar('T')
+
+        class Foo(typing.Generic[T]):
+            pass
+
+        # No exception.
+        resolve_fw_decl(Foo)
+
+
 if __name__ == '__main__':
     unittest.main()