edelvalle / reactor

Phoenix LiveView but for Django
630 stars 25 forks source link

Bug? '__signature__' attribute of 'BlockEditor' is class-only #38

Closed nerdoc closed 2 years ago

nerdoc commented 2 years ago

When using the simplest possible reactor component, I always get this error... ATM, current reactor is not installable via pip. It's only possible using the git version, so you have to use this one, not the Pypi package.

I've put together a small demo app, that basically creates a small component and includes it in a simple template.

It always raises this error:

'__signature__' attribute of 'BlockEditor' is class-only`.
Exception Location: | pydantic/utils.py, line 612, in pydantic.utils.ClassAttribute.__get__
Python Version: | 3.10.2

during rendering of {% component "TestComponent" %}.

I can't figure out what this means.

nerdoc commented 2 years ago

I tried to track this down further. It might be possible that this is a bug in reactor. in component.py, Line 144ff, you seem to want to return all component's attrs, without the ones starting with "_" - and without the ones starting with settings.RECEIVER_PREFIX - correct?

But when you put an or between them, they exclude them when both are not.

A simple

[
    a for a in dir(str) 
    if not attr.startswith("_") 
    or not attr.startswith("recv_")
]

returns

['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

WITH the __* attrs.

I don't know, but replacing or with and should fix this.