Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to type *_
#1
I have two graphics widgets, say a check button and a combo box. When I change the values in these controls, I want to call a function. Even though the controls are different types, the function is the same.

not actual code
check = checkbox()
check.value_changed_signal.connect(function)

cbox = combobox()
cbox.value_changed_signal.connect(function)

def function(*_) -> None:
    """I don't use the event.  I don't care if there is an event""
    # do something important when the checkbox or combobox value changes.
Static analysis tools complain that I am missing type information for *_ (ANN002). If I only had a checkbox I would write the function like this:
def function(event: checkbox_change_event) -> None:
If I only had the combobox I would do something similar, but with a different event type. In both cases I would ignore the event and the analysis software would complain about that too!

I could write separate callback functions for the checkbox and the combobox, and have those call my function, but that is extra code to maintain

Any suggestion on how to make a tool like ruff happy? I try to avoid using # noqa.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Type hinting - return type based on parameter micseydel 2 3,109 Jan-14-2020, 01:20 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020