python-dbus-next icon indicating copy to clipboard operation
python-dbus-next copied to clipboard

signal handlers: check for number of arguments gets fooled by **kwargs handler

Open hsteinhaus opened this issue 3 years ago • 4 comments

I am trying to register one generic handler to a couple of DBus signals with different signatures. This should be not a big deal in the world of duck typing - just use **kwargs in your handler and see what number of args you get.

Unfortunately, dbus-next is stopping me here: https://github.com/altdesktop/python-dbus-next/blob/04e7c0428ec2e4020d4b95aa70e10feb8e53e22e/dbus_next/proxy_object.py#L105

This check comes to the conclusion that my handler has one argument (**kwargs), but my signal has two.

Is there any chance to improve this check, opt out of it or remove it completely? I think this static understanding of the number of arguments is not very Pythonic.

hsteinhaus avatar May 07 '21 07:05 hsteinhaus

A keyword argument needs a keyword for naming, where would you expect them to come from ?

ydirson avatar May 07 '21 07:05 ydirson

Correct, my mistake. However, *args would probably trigger exactly the same problem.

hsteinhaus avatar May 07 '21 11:05 hsteinhaus

I think I can remove that check.

acrisci avatar May 07 '21 14:05 acrisci

A keyword argument needs a keyword for naming, where would you expect them to come from

From DBus introspection information?

Currently thinking about implementig that way - would be extremely helpful for my usecase (a single subscriber monitors a bunch of signals). Has anybody tried that before and is there a reason against that I should be aware?

hsteinhaus avatar May 10 '21 07:05 hsteinhaus