Repository: ramonhagenaars/nptyping

Issue:
typish 1.9.2 breaks isinstance(a, NDArray[...])
Recent update of [typish to 1.9.2](https://github.com/ramonhagenaars/typish/releases/tag/v1.9.2) has broken `isinstance(a, NDArray[(Any, 3), Float])` - now always returns False. Mypy checks seem to succeed still, downgrading typish to 1.9.1 resolves the issue

Discussion:

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index fb958ef..54abcc0 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,11 @@
 History
 -------
 
+1.4.2 (2021-05-08)
+++++++++++++++++++
+
+- Fixed instance check that was incompatible with `typish==1.9.2`.
+
 1.4.1 (2021-03-23)
 ++++++++++++++++++
 
diff --git a/nptyping/_meta.py b/nptyping/_meta.py
index b96e77a..5831923 100644
--- a/nptyping/_meta.py
+++ b/nptyping/_meta.py
@@ -1,5 +1,5 @@
 __title__ = 'nptyping'
-__version__ = '1.4.1'
+__version__ = '1.4.2'
 __author__ = 'Ramon Hagenaars'
 __author_email__ = 'ramon.hagenaars@gmail.com'
 __description__ = 'Type hints for Numpy.'
diff --git a/nptyping/types/_number.py b/nptyping/types/_number.py
index bd9d7c9..560c43a 100644
--- a/nptyping/types/_number.py
+++ b/nptyping/types/_number.py
@@ -1,3 +1,4 @@
+from inspect import getmro
 from typing import (
     Any,
     Type,
@@ -5,7 +6,7 @@ from typing import (
 )
 
 import numpy
-from typish import Literal, get_mro
+from typish import Literal
 
 from nptyping.types._nptype import NPType, SimpleNPTypeMeta
 
@@ -174,7 +175,7 @@ class Float(Number[float, numpy.floating]):
 
 def _is_a(this: Any, that: type) -> bool:
     # Return whether this is a subclass of that, considering the mro.
-    return that in get_mro(this)
+    return that in getmro(this)
 
 
 def _is_number_subclass_of(
diff --git a/nptyping/types/_unicode.py b/nptyping/types/_unicode.py
index 017d1a2..2745de0 100644
--- a/nptyping/types/_unicode.py
+++ b/nptyping/types/_unicode.py
@@ -1,7 +1,7 @@
+from inspect import getmro
 from typing import Any, Type
 
-import numpy
-from typish import get_mro
+import numpy as np
 
 from nptyping.types._nptype import NPType, SimpleNPTypeMeta
 
@@ -22,12 +22,12 @@ class _UnicodeMeta(SimpleNPTypeMeta):
         return issubclass(unicode, cls)
 
     def __subclasscheck__(cls, subclass: type) -> bool:
-        if Unicode in get_mro(subclass):
+        if Unicode in getmro(subclass):
             return cls.chars is Any or subclass.chars <= cls.chars
         return False
 
 
-class Unicode(NPType, numpy.unicode, metaclass=_UnicodeMeta):
+class Unicode(NPType, np.compat.unicode, metaclass=_UnicodeMeta):
     """
     A numpy unicode. Can be given the number of characters optionally.
 


Test patch:
diff --git a/tests/test_functions/test_get_type.py b/tests/test_functions/test_get_type.py
index f32630b..aa4510e 100644
--- a/tests/test_functions/test_get_type.py
+++ b/tests/test_functions/test_get_type.py
@@ -67,7 +67,7 @@ class TestGetType(TestCase):
         self.assertEqual(Float32, get_type(np.float32(42.0)))
         self.assertEqual(Float64, get_type(np.float64(42.0)))
 
-        self.assertEqual(Unicode, get_type(np.unicode))
+        self.assertEqual(Unicode, get_type(np.compat.unicode))
         self.assertEqual(Unicode[40], get_type(np.dtype(('U', 40))))
 
         self.assertEqual(Bool, get_type(np.bool_(True)))
diff --git a/tests/test_types/test_ndarray.py b/tests/test_types/test_ndarray.py
index 4fe6041..4d7559b 100644
--- a/tests/test_types/test_ndarray.py
+++ b/tests/test_types/test_ndarray.py
@@ -3,7 +3,7 @@ from unittest import TestCase
 
 import numpy as np
 
-from nptyping import NDArray, DEFAULT_INT_BITS, Int, Bool, Datetime64, StructuredType, SubArrayType, Int32
+from nptyping import NDArray, DEFAULT_INT_BITS, Int, Bool, Datetime64, StructuredType, SubArrayType, Int32, Float
 from nptyping.types._timedelta64 import Timedelta64
 
 
@@ -101,6 +101,7 @@ class TestNDArray(TestCase):
         self.assertTrue(isinstance(arr2x2, NDArray))
         self.assertTrue(isinstance(arr3x2x2, NDArray[int]))
         self.assertTrue(isinstance(arr2x2, NDArray[int]))
+        self.assertTrue(isinstance(arr2x2, NDArray[(Any, 2), Int]))
 
     def test_instance_check_types(self):
         arr2x2x2_float = np.array([[[1.0, 2.0], [3.0, 4.0]],
diff --git a/tests/test_types/test_number.py b/tests/test_types/test_number.py
index a75b26f..0f6e6aa 100644
--- a/tests/test_types/test_number.py
+++ b/tests/test_types/test_number.py
@@ -1,6 +1,7 @@
 from unittest import TestCase
 
 import numpy
+from typish import get_origin
 
 from nptyping import (
     Float,
@@ -92,8 +93,11 @@ class TestNumber(TestCase):
         self.assertTrue(Int32 != UInt32)
 
     def test_issubclass(self):
-        self.assertTrue(issubclass(Float[32], Float32))
-        self.assertTrue(issubclass(Int64, Int[64]))
+        # self.assertTrue(issubclass(Float[32], Float32))
+        # self.assertTrue(issubclass(Int64, Int[64]))
+
+        orig = Float.__origin__    # zou Float moeten zijn
+
         self.assertTrue(issubclass(Float16, Float))
         self.assertTrue(issubclass(Int64, Int))
         self.assertTrue(issubclass(Int64, Number))