Skip to content

Conversation

@ianhi
Copy link
Contributor

@ianhi ianhi commented Dec 12, 2025

PR summary

Make it more convenient to disconnect a callback by allowing passing back the function instead of requiring keeping track of the callback_id.

  • I added a new function instead of overloading the arguments to the existing disconnect because I felt it would get to complicated
  • I also updated disconnect to re-use the duplicated logic in _remove_proxy

I'm not 100% on the naming, but that is apparently what I thought was good in 2022, so trusting prior me.

Closes: #23306

AI 🤖 : Ideas all mine, actual code changes by claude. I have reviewed every changed line

PR checklist

@ianhi
Copy link
Contributor Author

ianhi commented Dec 12, 2025

The failing tests seem unrelated?

@timhoffm
Copy link
Member

timhoffm commented Dec 13, 2025

Would it make sense to fold this into the existing disconnect() method? So that you can do

disconnect(cid)
disconnect(func)  #from all events

And an one of these for event-specific disconnecting

disconnect(func, event=event)
disconnect((event, func))

API-wise this feels more intuitive than a separate function. If the implementation gets too messy, you should be able to dispatch to a helper function based on the parameters.

@ianhi
Copy link
Contributor Author

ianhi commented Dec 13, 2025

That's a nice suggestion. I have implemented it.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo fixing the change notes.

Comment on lines 8 to 9
``CallbackRegistry.disconnect_func`` has been removed; use
``disconnect(func, signal=...)`` instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove. Was this pedantic AI 😄 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aghh. that's embarassing. indeed.

The aggressive back compatibility from changes within a session has to be one of my least favorite aspects of AI code tools

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianhi Since you've been systematically using AI on our codebase, maybe you are interested or can give input to
#30848

@@ -0,0 +1,20 @@
``CallbackRegistry.disconnect_func`` to disconnect callbacks by function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops forgot to update this whats new with the most recent changes.

Are you saying that this should no longer get a whatsnews, or just I should update it to use disconnect?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, update is the correct way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: allow passing a function to CallbackRegistry.disconnect

2 participants