-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some deprecation warnings on core24 #2067
Conversation
urwid deprecated the user of the user_arg parameter of connect_signal (and might get dropped sometime). Instead, the suggested approach is to use user_args (plural!) as a kw-only argument. We have to change the signature of callbacks functions because `user_args` is passed as an argument at the beginning ; whereas `user_arg` is passed as an argument at the end. Signed-off-by: Olivier Gayot <[email protected]>
urwid deprecated AttrWrap in favor of AttrMap. It is pretty easy to replace one with the other and is backward compatible with urwid from core22. Signed-off-by: Olivier Gayot <[email protected]>
urwid from core24 raises deprecation notices when using set_focus on widgets. In core24, one can use the `container.focus = widget` setter property or `container.focus_position = index` setter property. However, in core22, the `container.focus` property is read-only. `container.focus_position` is available in core22 and core24 and does not produce deprecation warnings ; so let's use it. Signed-off-by: Olivier Gayot <[email protected]>
Although ListBox.get_focus() is deprecated, using ListWalker.get_focus() through ListBox.body.get_focus() is not. However, the ListBox.focus property exists and makes it easy to access the underlying focused widget ; so use it instead of dereferencing the ListWalker object. Signed-off-by: Olivier Gayot <[email protected]>
4fd089a
to
38315ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The argument order change when you switch from user_arg to user_args is unfortunate!
Should we stop using on_press / on_state_change?
That sounds like a lot of work! We're using on_press everywhere. Maybe we subclass urwid.Button, and do something like: class Button(urwid.Button):
def __init__(self, *args, on_press=None, user_args=(), **kwargs) -> None:
if "user_data" in kwargs:
raise ValueError("For this implementation, use user_args instead")
super().__init__(*args, **kwargs)
if on_press is not None:
connect_signal(self, "click", on_press, user_args=list(user_args)) and then adjust the argument order. Something for another day, I guess :) |
Oh definitely, nothing for this branch!! |
Looking at most of our actual uses, having a wrapper that discarded the 'sender' argument to the callback would be useful .... |
On oracular, this PR makes
make unit
produce 59 warnings instead of 146. The remaining warnings (emitted multiple times) are:-> should be addressed with https://launchpad.net/ubuntu/+source/pymongo/4.7.3-1 (won't be addressed for core24 probably though)
-> to be investigated
-> internal to urwid, when using on_press or on_state_change. Won't be fixed anytime soon.