Repository: youknowone/ring

Issue:
type '<class 'abc.ABCMeta'>' is not a key-compatible type
```
import abc

import ring


class Foo(abc.ABC):
    @classmethod
    @abc.abstractmethod
    def foo(cls) -> str:
        pass


class SubFoo(Foo):
    @classmethod
    @ring.lru()
    def foo(cls):
        return "Hi."


f = SubFoo()
f.foo()
```

This code triggers `TypeError: The given value '<class '__main__.SubFoo'>' of type '<class 'abc.ABCMeta'>' is not a key-compatible type. add __ring_key__(), __str__() or __hash__(). str__() or __hash__(). `

Discussion:
wy-z: The CI failed, but it doesn’t seem to be caused by my PR—it might be due to the `black` version.

Thank you! If you have time to review this PR, that would be even better.

Best wishes! @youknowone 
youknowone: Thanks! let me check it
youknowone: I fixed the CI. could you rebase the PR on main?
wy-z: > I fixed the CI. could you rebase the PR on main?

It’s done. Please review again when you have a chance.
youknowone: Thank you. Could you add a test under `tests/test_coerce.py` to ensure this is working?
wy-z: > Thank you. Could you add a test under `tests/test_coerce.py` to ensure this is working?

Okay, I'll add unit test later  
wy-z: > Thank you. Could you add a test under `tests/test_coerce.py` to ensure this is working?

tests/test_coerce.py::test_coerce[User-User] PASSED                      [ 15%]
tests/test_coerce.py::test_coerce[ABCUser-ABCUser] PASSED                [ 15%]

Patch:
diff --git a/ring/func/base.py b/ring/func/base.py
index 166f8bc..11d025e 100644
--- a/ring/func/base.py
+++ b/ring/func/base.py
@@ -214,7 +214,7 @@ def coerce_function(t):
     if issubclass(t, (list, tuple)):
         return _coerce_list_and_tuple
 
-    if t is type:
+    if t is type or t is abc.ABCMeta:
         return _coerce_type
 
     if issubclass(t, dict):


Test patch:
diff --git a/tests/test_coerce.py b/tests/test_coerce.py
index 9a3e43e..ea394e1 100644
--- a/tests/test_coerce.py
+++ b/tests/test_coerce.py
@@ -1,3 +1,4 @@
+import abc
 import sys
 
 import pytest
@@ -37,6 +38,10 @@ class HashUser(object):
         return str(self.user_id)
 
 
+class ABCUser(abc.ABC):
+    pass
+
+
 ring_key_instance = User(42)
 ring_hash_instance = HashUser(42)
 test_parameters = [
@@ -49,6 +54,8 @@ test_parameters = [
     ({1, 2, 3, 4}, "{1,2,3,4}"),
     ({"1", "2", "3", "4"}, "{'1','2','3','4'}"),
     (("1", "2", "3", "4"), "('1','2','3','4')"),
+    (User, "User"),
+    (ABCUser, "ABCUser"),
 ]
 if numpy is not None:
     test_parameters.extend(