Skip to content

Commit 31501ff

Browse files
committed
Fixes CI
1 parent da7c73c commit 31501ff

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

classes/_typeclass.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def supports(
498498

499499
def instance(
500500
self,
501-
type_: Optional[_NewInstanceType],
501+
type_argument: Optional[_NewInstanceType],
502502
*,
503503
# TODO: at one point I would like to remove `is_protocol`
504504
# and make this function decide whether this type is protocol or not.
@@ -510,27 +510,26 @@ def instance(
510510
The only setting we provide is ``is_protocol`` which is required
511511
when passing protocols. See our ``mypy`` plugin for that.
512512
"""
513-
if type_ is None: # `None` is a special case
514-
type_ = type(None) # type: ignore
513+
typ = type_argument or type(None) # `None` is a special case
515514

516515
# That's how we check for generics,
517516
# generics that look like `List[int]` or `set[T]` will fail this check,
518517
# because they are `_GenericAlias` instance,
519518
# which raises an exception for `__isinstancecheck__`
520-
isinstance(object(), type_) # type: ignore
519+
isinstance(object(), typ)
521520

522521
def decorator(implementation):
523522
container = self._protocols if is_protocol else self._instances
524-
container[type_] = implementation # type: ignore
523+
container[typ] = implementation
525524

526-
if isinstance(type_.__instancecheck__, MethodType): # noqa: WPS609
525+
if isinstance(getattr(typ, '__instancecheck__', None), MethodType):
527526
# This means that this type has `__instancecheck__` defined,
528527
# which allows dynamic checks of what `isinstance` of this type.
529528
# That's why we also treat this type as a protocol.
530-
self._protocols[type_] = implementation # type: ignore
529+
self._protocols[typ] = implementation
531530

532531
if self._cache_token is None: # pragma: no cover
533-
if getattr(type_, '__abstractmethods__', None):
532+
if getattr(typ, '__abstractmethods__', None):
534533
self._cache_token = get_cache_token()
535534

536535
self._dispatch_cache.clear()

0 commit comments

Comments
 (0)