Closed SimonKoop closed 1 week ago
Oh wow, now that really is super weird.
This actually doesn't look to be a bug in Equinox, but a bug in Python's abc
itself. Here's a reproducer that doesn't use Equinox at all:
import abc
class X(metaclass=abc.ABCMeta):
pass
class Y(X):
pass
class Z(X):
pass
define_magic = True # try toggling this value
if define_magic:
class Magic(Y):
@classmethod
def __subclasshook__(cls, maybe_subclass):
if issubclass(maybe_subclass, Z):
return True
return NotImplemented
assert issubclass(Z, Y) == define_magic
(FWIW using Python 3.11.9 in my case.)
I'd suggest verifying if this is still present in recent Python releases, and if so then opening a bug against Python itself.
Thank you for your reply! Indeed, the bug seems to still exist in Python 3.13, so I'll file a bug report there.
When using a
__subclasshook__
with equinox modules, it may happen thatissubclass
returnsTrue
on pairs of classes where normally (if they weren't equinox modules) this would result inFalse
. For example, in the following code, the print statement at the end will return the same boolean as set inwith_eqx
.