Repository: ilevkivskyi/typing_inspect

Issue:
`get_parameters` throws exception with non-indexed types from `typing` on python 3.10
**python 3.7**
```
>>> from typing import List
>>> from typing_inspect import get_parameters
>>> get_parameters(List)
(~T,)
```

**python 3.10.6**
```
>>> from typing import List
>>> from typing_inspect import get_parameters
>>> get_parameters(List)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/james.robson/code/pio_utilities/.venv/lib/python3.10/site-packages/typing_inspect.py", line 414, in get_parameters
    return tp.__parameters__
  File "/usr/lib/python3.10/typing.py", line 984, in __getattr__
    raise AttributeError(attr)
AttributeError: __parameters__
```

When you don't provide type parameters the `typing` classes lacks the `__parameters__`, `_paramspec_tvars` and `_typevar_types` members.



Discussion:

Patch:
diff --git a/typing_inspect.py b/typing_inspect.py
index d786e96..0268b16 100644
--- a/typing_inspect.py
+++ b/typing_inspect.py
@@ -408,7 +408,11 @@ def get_parameters(tp):
         else:
             return ()
     elif NEW_TYPING:
-        if (isinstance(tp, typingGenericAlias) or
+        if (
+                (
+                    isinstance(tp, typingGenericAlias) and
+                    hasattr(tp, '__parameters__')
+                ) or
                 isinstance(tp, type) and issubclass(tp, Generic) and
                 tp is not Generic):
             return tp.__parameters__


Test patch:
diff --git a/test_typing_inspect.py b/test_typing_inspect.py
index 9f6be56..eaea460 100644
--- a/test_typing_inspect.py
+++ b/test_typing_inspect.py
@@ -14,6 +14,7 @@ from typing import (
     Union, Callable, Optional, TypeVar, Sequence, AnyStr, Mapping,
     MutableMapping, Iterable, Generic, List, Any, Dict, Tuple, NamedTuple,
 )
+from typing import T as typing_T
 
 from mypy_extensions import TypedDict as METypedDict
 from typing_extensions import TypedDict as TETypedDict
@@ -354,6 +355,10 @@ class GetUtilityTestCase(TestCase):
         self.assertEqual(get_parameters(Union), ())
         if not LEGACY_TYPING:
             self.assertEqual(get_parameters(List[int]), ())
+            if PY39:
+                self.assertEqual(get_parameters(List), ())
+            else:
+                self.assertEqual(get_parameters(List), (typing_T,))
         else:
             # in 3.5.3 a list has no __args__ and instead they are used in __parameters__
             # in 3.5.1 the behaviour is normal again.