Open sylvorg opened 1 month ago
Hey @sylvorg! Hmmm, this looks pretty complicated.
Concretely, the error comes up because process
is called with more arguments than defined. Could you try changing the definition to this, to see if that works?
@dispatch
def process(_: type, *args):
pass
Nope:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_decor/decorcore.py:214 in _beartype_object_nonfatal │
│ │
│ 211 │ │
│ 212 │ # Attempt to decorate the passed beartypeable. │
│ 213 │ try: │
│ ❱ 214 │ │ return _beartype_object_fatal(obj, conf=conf, **kwargs) │
│ 215 │ # If doing so unexpectedly raises an exception, coerce that fatal exception │
│ 216 │ # into a non-fatal warning for nebulous safety. │
│ 217 │ except Exception as exception: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ conf = BeartypeConf(warning_cls_on_decorator_exception=<class │ │
│ │ 'beartype.roar._roarwarn.BeartypeClawDecorWarning'>) │ │
│ │ error_message = '\n beartype.roar.BeartypeDecorWrappeeException: Uncallable None not │ │
│ │ decoratabl'+15 │ │
│ │ kwargs = {} │ │
│ │ obj = None │ │
│ │ warning_category = <class 'beartype.roar._roarwarn.BeartypeClawDecorWarning'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_decor/decorcore.py:136 in _beartype_object_fatal │
│ │
│ 133 │ │ if isinstance(obj, type) else │
│ 134 │ │ # Else, this object is a non-class. In this case, this non-class │
│ 135 │ │ # decorated with type-checking. │
│ ❱ 136 │ │ beartype_nontype(obj, **kwargs) # type: ignore[return-value] │
│ 137 │ ) │
│ 138 │
│ 139 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ kwargs = { │ │
│ │ │ 'conf': BeartypeConf(warning_cls_on_decorator_exception=<class │ │
│ │ 'beartype.roar._roarwarn.BeartypeClawDecorWarning'>) │ │
│ │ } │ │
│ │ obj = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_decor/_decornontype.py:122 in beartype_nontype │
│ │
│ 119 │ # │
│ 120 │ # If this object is uncallable, raise an exception. │
│ 121 │ elif not callable(obj): │
│ ❱ 122 │ │ raise BeartypeDecorWrappeeException( │
│ 123 │ │ │ f'Uncallable {repr(obj)} not decoratable by @beartype.') │
│ 124 │ # Else, this object is callable. │
│ 125 │ # │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ kwargs = { │ │
│ │ │ 'conf': BeartypeConf(warning_cls_on_decorator_exception=<class │ │
│ │ 'beartype.roar._roarwarn.BeartypeClawDecorWarning'>) │ │
│ │ } │ │
│ │ obj = None │ │
│ │ obj_type = <class 'NoneType'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
BeartypeDecorWrappeeException: Uncallable None not decoratable by @beartype.
During handling of the above exception, another exception occurred:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1 │
│ │
│ /mnt/wsl/sylvorg/tests/plum-off/plum_off/__init__.py:13 in <module> │
│ │
│ 10 │
│ 11 beartype_this_package() │
│ 12 │
│ ❱ 13 from plum_off.bundle import * │
│ 14 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ beartype_this_package = <function beartype_this_package at 0x7fac2998d4e0> │ │
│ │ python = <module 'plum_off.python' from │ │
│ │ '/mnt/wsl/sylvorg/tests/plum-off/plum_off/python.py'> │ │
│ │ RichPretty = <module 'rich.pretty' from │ │
│ │ '/nix/store/m3ww19ir18vfggdpjwmglar2rs6fg627-python3.11-rich-13.5.2… │ │
│ │ RichTraceback = <module 'rich.traceback' from │ │
│ │ '/nix/store/m3ww19ir18vfggdpjwmglar2rs6fg627-python3.11-rich-13.5.2… │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /mnt/wsl/sylvorg/tests/plum-off/plum_off/bundle.py:9 in <module> │
│ │
│ 6 │ │ pass │
│ 7 │
│ 8 │
│ ❱ 9 class bundle(metaclass=Bundle): │
│ 10 │ pass │
│ 11 │
│ │
│ ╭────────────────────────────────────────── locals ──────────────────────────────────────────╮ │
│ │ Bundle = <class 'plum_off.bundle.Bundle'> │ │
│ │ plumeta = <class 'plum_off.python.plumeta'> │ │
│ │ process = <multiple-dispatch function process (with 1 registered and 0 pending method(s))> │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_decor/decorcache.py:130 in beartype_confed │
│ │
│ 127 │ │ │
│ 128 │ │ # Decorate this object with type-checking configured by this │
│ 129 │ │ # configuration. │
│ ❱ 130 │ │ return beartype_object(obj, conf) │
│ 131 │ │
│ 132 │ # Cache this private decorator against this configuration. │
│ 133 │ _bear_conf_to_decor[conf] = beartype_confed │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ conf = BeartypeConf(warning_cls_on_decorator_exception=<class │ │
│ │ 'beartype.roar._roarwarn.BeartypeClawDecorWarning'>) │ │
│ │ obj = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_decor/decorcore.py:95 in beartype_object │
│ │
│ 92 │ │ # Else, this beartype configuration requests that this decorator emit │
│ 93 │ │ # fatal warnings at decoration time. In this case, defer to the │
│ 94 │ │ # lower-level decorator doing so. │
│ ❱ 95 │ │ _beartype_object_nonfatal(obj, conf=conf, **kwargs) │
│ 96 │ ) │
│ 97 │
│ 98 # ....................{ PRIVATE ~ decorators }.................... │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ conf = BeartypeConf(warning_cls_on_decorator_exception=<class │ │
│ │ 'beartype.roar._roarwarn.BeartypeClawDecorWarning'>) │ │
│ │ kwargs = {} │ │
│ │ obj = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_decor/decorcore.py:253 in _beartype_object_nonfatal │
│ │
│ 250 │ │ # capitalized such that the first character is uppercase. │
│ 251 │ │ # * This indented exception message. │
│ 252 │ │ warning_message = uppercase_str_char_first( │
│ ❱ 253 │ │ │ f'{prefix_beartypeable(obj)}{label_object_context(obj)}:' │
│ 254 │ │ │ f'{error_message}' │
│ 255 │ │ ) │
│ 256 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ conf = BeartypeConf(warning_cls_on_decorator_exception=<class │ │
│ │ 'beartype.roar._roarwarn.BeartypeClawDecorWarning'>) │ │
│ │ error_message = '\n beartype.roar.BeartypeDecorWrappeeException: Uncallable None not │ │
│ │ decoratabl'+15 │ │
│ │ kwargs = {} │ │
│ │ obj = None │ │
│ │ warning_category = <class 'beartype.roar._roarwarn.BeartypeClawDecorWarning'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_util/text/utiltextprefix.py:63 in prefix_beartypeable │
│ │
│ 60 │ │ if isinstance(obj, type) else │
│ 61 │ │ # Else, this beartypeable is a callable. In this case, a label │
│ 62 │ │ # describing this callable. │
│ ❱ 63 │ │ f'{label_callable(func=obj, is_color=is_color)} ' # type: ignore[arg-type] │
│ 64 │ ) │
│ 65 │
│ 66 │
│ │
│ ╭───── locals ─────╮ │
│ │ is_color = False │ │
│ │ obj = None │ │
│ ╰──────────────────╯ │
│ │
│ /nix/store/a1zmsz063k8fl5c6xvmzfnmw8bri0g36-python3.11-beartype-0.16.4/lib/python3.11/site-packa │
│ ges/beartype/_util/text/utiltextlabel.py:179 in label_callable │
│ │
│ 176 │ str │
│ 177 │ │ Human-readable label describing this callable. │
│ 178 │ ''' │
│ ❱ 179 │ assert callable(func), f'{repr(func)} uncallable.' │
│ 180 │ assert isinstance(is_context, bool) or is_context is None, ( # <-- "NoneTypeOr" is │
│ 181 │ │ f'{repr(is_context)} not tri-state boolean.') │
│ 182 │
│ │
│ ╭────── locals ──────╮ │
│ │ func = None │ │
│ │ is_color = False │ │
│ │ is_context = None │ │
│ ╰────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AssertionError: None uncallable.
@sylvorg Oof, I'm really not sure what is happening here. Are you sure that the issue here is on Plum's side?
@dispatch
def process(_: type, *args):
pass
Is this implementation correct? I'm not sure what process
is supposed to do.
Should it be something like this?
@dispatch
def process(x: type, *args):
return x
I'm not sure.
Oof, I'm really not sure what is happening here. Are you sure that the issue here is on Plum's side?
Unlikely; pinging @leycec again, as this seems to only be happening when beartype_this_package()
is used. 😅 Sorry about this, old friend!
Hello!
As in the title; if you test out the repository here, for some reason, the combination of these files:
__init__.py:
bundle.py:
python.py:
Cause the following traceback:
If the signatures are too difficult to read:
Since the problem seems to go away when
beartype_this_package
is removed or commented out, I'm pinging @leycec as well!Sorry for all the issues recently, and thank you kindly for the help!