Skip to content

Can't inherit from a proxied class #80

Open
@benrg

Description

@benrg

In 1.10.0, this fails with a TypeError:

import lazy_object_proxy

@lazy_object_proxy.Proxy
def Base():
    class Base: pass
    return Base

class Derived(Base): pass

The problem is that class takes type(Base) to be Derived's metaclass, and calls it with three arguments, but Proxy.__init__ expects only one.

Adding three metaclass methods to Proxy appears to fix the problem:

class FixedProxy(lazy_object_proxy.Proxy):
    def __mro_entries__(self, bases):
        return (self.__wrapped__,)

    def __subclasscheck__(self, subclass):
        return issubclass(subclass, self.__wrapped__)

    def __instancecheck__(self, instance):
        return isinstance(instance, self.__wrapped__)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions