Skip to content

Commit 04b9315

Browse files
committed
Fixes CI
1 parent bdeaffa commit 04b9315

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

classes/_typeclass.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117

118118
from abc import get_cache_token
119119
from functools import _find_impl # type: ignore # noqa: WPS450
120+
from types import MethodType
120121
from typing import ( # noqa: WPS235
121122
TYPE_CHECKING,
122123
Callable,
@@ -499,6 +500,8 @@ def instance(
499500
self,
500501
type_argument: Optional[_NewInstanceType],
501502
*,
503+
# TODO: at one point I would like to remove `is_protocol`
504+
# and make this function decide whether this type is protocol or not.
502505
is_protocol: bool = False,
503506
) -> '_TypeClassInstanceDef[_NewInstanceType, _TypeClassType]':
504507
"""
@@ -520,7 +523,7 @@ def decorator(implementation):
520523
container = self._protocols if is_protocol else self._instances
521524
container[type_argument] = implementation # type: ignore
522525

523-
if getattr(type_argument, '__instancecheck__', None):
526+
if isinstance(type_argument.__instancecheck__, MethodType):
524527
# This means that this type has `__instancecheck__` defined,
525528
# which allows dynamic checks of what `isinstance` of this type.
526529
# That's why we also treat this type as a protocol.

tests/test_typeclass/test_call.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ def _my_len_list(instance: list) -> int:
3232
])
3333
def test_call_order(data_type, expected):
3434
"""Ensures that call order is correct."""
35+
print(my_len._protocols)
3536
assert my_len(data_type) == expected

0 commit comments

Comments
 (0)