From ed6ba633174c212df96b9de3104be62f5849e41f Mon Sep 17 00:00:00 2001 From: Aleksei Stepanov Date: Thu, 18 Jan 2024 10:22:38 +0100 Subject: [PATCH] Ban `urwid==2.4.3` as containing UI regression. Fix urwid entities init: use correct `super()`, hack `__super` is officially deprecated. Method .method(self, ...) is only for fallback in corner cases (normally not recommended to use). --- nomadnet/ui/textui/Config.py | 4 +-- nomadnet/ui/textui/Conversations.py | 6 ++--- nomadnet/ui/textui/Guide.py | 4 +-- nomadnet/ui/textui/Log.py | 2 +- nomadnet/ui/textui/MicronParser.py | 6 ++--- nomadnet/ui/textui/Network.py | 38 ++++++++++++++--------------- setup.py | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/nomadnet/ui/textui/Config.py b/nomadnet/ui/textui/Config.py index 6b7039f..f94037c 100644 --- a/nomadnet/ui/textui/Config.py +++ b/nomadnet/ui/textui/Config.py @@ -13,7 +13,7 @@ class ConfigFiller(urwid.WidgetWrap): def __init__(self, widget, app): self.app = app self.filler = urwid.Filler(widget, "top") - urwid.WidgetWrap.__init__(self, self.filler) + super().__init__(self.filler) def keypress(self, size, key): @@ -71,7 +71,7 @@ def quit_term(*args, **kwargs): urwid.connect_signal(self.term, 'closed', quit_term) - urwid.WidgetWrap.__init__(self, self.term) + super().__init__(self.term) def keypress(self, size, key): diff --git a/nomadnet/ui/textui/Conversations.py b/nomadnet/ui/textui/Conversations.py index 9bb8e02..3d1d857 100644 --- a/nomadnet/ui/textui/Conversations.py +++ b/nomadnet/ui/textui/Conversations.py @@ -788,7 +788,7 @@ def __init__(self, source_hash): if source_hash == None: self.frame = None display_widget = urwid.LineBox(urwid.Filler(urwid.Text("\n No conversation selected"), "top")) - urwid.WidgetWrap.__init__(self, display_widget) + super().__init__(display_widget) else: if source_hash in ConversationsDisplay.cached_conversation_widgets: return ConversationsDisplay.cached_conversation_widgets[source_hash] @@ -852,7 +852,7 @@ def __init__(self, source_hash): self.frame ) - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def clear_history_dialog(self): def dismiss_dialog(sender): @@ -1141,7 +1141,7 @@ def __init__(self, message): urwid.Text("") ]) - urwid.WidgetWrap.__init__(self, display_widget) + super().__init__(display_widget) class SyncProgressBar(urwid.ProgressBar): def get_text(self): diff --git a/nomadnet/ui/textui/Guide.py b/nomadnet/ui/textui/Guide.py index 95cf5bf..ccd2b52 100644 --- a/nomadnet/ui/textui/Guide.py +++ b/nomadnet/ui/textui/Guide.py @@ -75,7 +75,7 @@ def __init__(self, app, parent, reader, topic_name): style = "topic_list_normal" focus_style = "list_focus" self.display_widget = urwid.AttrMap(widget, style, focus_style) - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def display_topic(self, event, topic): markup = TOPICS[topic] @@ -125,7 +125,7 @@ def __init__(self, app, guide_display): highlight_offFocus="list_off_focus" ) - urwid.WidgetWrap.__init__(self, urwid.LineBox(self.ilb, title="Topics")) + super().__init__(urwid.LineBox(self.ilb, title="Topics")) def keypress(self, size, key): diff --git a/nomadnet/ui/textui/Log.py b/nomadnet/ui/textui/Log.py index 853acf7..28cc22e 100644 --- a/nomadnet/ui/textui/Log.py +++ b/nomadnet/ui/textui/Log.py @@ -40,7 +40,7 @@ def __init__(self, app): escape_sequence="up", main_loop=self.app.ui.loop, ) - urwid.WidgetWrap.__init__(self, self.log_term) + super().__init__(self.log_term) def terminate(self): self.log_term.terminate() diff --git a/nomadnet/ui/textui/MicronParser.py b/nomadnet/ui/textui/MicronParser.py index 3885a15..335d2c0 100644 --- a/nomadnet/ui/textui/MicronParser.py +++ b/nomadnet/ui/textui/MicronParser.py @@ -608,7 +608,7 @@ def __init__(self, link_target, orig_spec): self.link_target = link_target self.link_fields = None - urwid.AttrSpec.__init__(self, orig_spec.foreground, orig_spec.background) + super().__init__(orig_spec.foreground, orig_spec.background) class LinkableText(urwid.Text): @@ -618,7 +618,7 @@ class LinkableText(urwid.Text): signals = ["click", "change"] def __init__(self, text, align=None, cursor_position=0, delegate=None): - self.__super.__init__(text, align=align) + super().__init__(text, align=align) self.delegate = delegate self._cursor_position = 0 self.key_timeout = 3 @@ -729,7 +729,7 @@ def kt_event(self, loop, user_data): def render(self, size, focus=False): now = time.time() - c = self.__super.render(size, focus) + c = super().render(size, focus) if focus and (self.delegate == None or now < self.delegate.last_keypress+self.key_timeout): c = urwid.CompositeCanvas(c) diff --git a/nomadnet/ui/textui/Network.py b/nomadnet/ui/textui/Network.py index 19ef8af..f0c40a3 100644 --- a/nomadnet/ui/textui/Network.py +++ b/nomadnet/ui/textui/Network.py @@ -234,7 +234,7 @@ def use_pn(sender): self.display_widget = urwid.Filler(pile, valign="top", height="pack") - urwid.WidgetWrap.__init__(self, urwid.LineBox(self.display_widget, title="Announce Info")) + super().__init__(urwid.LineBox(self.display_widget, title="Announce Info")) class AnnounceStreamEntry(urwid.WidgetWrap): @@ -296,7 +296,7 @@ def __init__(self, app, announce, delegate): urwid.connect_signal(widget, "click", self.display_announce, announce) self.display_widget = urwid.AttrMap(widget, style, focus_style) - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def display_announce(self, event, announce): try: @@ -365,7 +365,7 @@ def __init__(self, app, parent): ) self.display_widget = self.ilb - urwid.WidgetWrap.__init__(self, urwid.LineBox(self.display_widget, title="Announce Stream")) + super().__init__(urwid.LineBox(self.display_widget, title="Announce Stream")) def keypress(self, size, key): if key == "up" and (self.no_content or self.ilb.first_item_is_selected()): @@ -681,7 +681,7 @@ def save_node(sender): self.display_widget = urwid.Filler(pile, valign="top", height="pack") - urwid.WidgetWrap.__init__(self, urwid.LineBox(self.display_widget, title="Node Info")) + super().__init__(urwid.LineBox(self.display_widget, title="Node Info")) # Yes, this is weird. There is a bug in Urwid/ILB that causes @@ -726,7 +726,7 @@ def __init__(self, app): self.pile = urwid.Pile([urwid.Text(("warning_text", g["info"]+"\n"), align="center"), SelectText(("warning_text", "Currently, no nodes are saved\n\nCtrl+L to view the announce stream\n\n"), align="center")]) self.display_widget = urwid.Filler(self.pile, valign="top", height="pack") - urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title="Saved Nodes"), widget_style)) + super().__init__(urwid.AttrMap(urwid.LineBox(self.display_widget, title="Saved Nodes"), widget_style)) def keypress(self, size, key): if key == "up" and (self.no_content or self.ilb.first_item_is_selected()): @@ -869,7 +869,7 @@ def __init__(self, app, node, delegate): self.display_widget = urwid.AttrMap(widget, style, focus_style) self.display_widget.source_hash = source_hash - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) class AnnounceTime(urwid.WidgetWrap): @@ -880,7 +880,7 @@ def __init__(self, app): self.display_widget = urwid.Text("") self.update_time() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update_time(self): self.last_announce_string = "Never" @@ -912,7 +912,7 @@ def __init__(self, app): self.display_widget = urwid.Text("") self.update_time() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update_time(self): self.last_announce_string = "Never" @@ -943,7 +943,7 @@ def __init__(self, app): self.display_widget = urwid.Text("") self.update_stat() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update_stat(self): self.stat_string = "None" @@ -974,7 +974,7 @@ def __init__(self, app): self.display_widget = urwid.Text("") self.update_stat() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update_stat(self): self.stat_string = "None" @@ -1017,7 +1017,7 @@ def __init__(self, app): self.display_widget = urwid.Text("") self.update_stat() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update_stat(self): self.stat_string = "None" @@ -1049,7 +1049,7 @@ def __init__(self, app): self.display_widget = urwid.Text("") self.update_stat() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update_stat(self): self.stat_string = "None" @@ -1081,7 +1081,7 @@ def __init__(self, app): self.display_widget = urwid.Text("") self.update_stat() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update_stat(self): self.stat_string = "None" @@ -1193,7 +1193,7 @@ def node_info_query(sender): ] ) - urwid.WidgetWrap.__init__(self, urwid.LineBox(self.display_widget, title="Local Peer Info")) + super().__init__(urwid.LineBox(self.display_widget, title="Local Peer Info")) def start(self): self.t_last_announce.start() @@ -1369,7 +1369,7 @@ def connect_query(sender): self.display_widget = pile - urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title="Local Node Info"), widget_style)) + super().__init__(urwid.AttrMap(urwid.LineBox(self.display_widget, title="Local Node Info"), widget_style)) def start(self): if self.app.node != None: @@ -1392,7 +1392,7 @@ def __init__(self, app, title, value_method, append_text=""): self.append_text = append_text self.update() - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def update(self): self.value = self.value_method() @@ -1434,7 +1434,7 @@ def get_num_nodes(): self.display_widget = urwid.LineBox(pile, title="Network Stats") - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def start(self): self.w_heard_peers.start() @@ -1620,7 +1620,7 @@ def __init__(self, app): pl = len(self.peer_list) else: pl = 0 - urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title=f"LXMF Propagation Peers ({pl})"), widget_style)) + super().__init__(urwid.AttrMap(urwid.LineBox(self.display_widget, title=f"LXMF Propagation Peers ({pl})"), widget_style)) def keypress(self, size, key): if key == "up" and (self.no_content or self.ilb.first_item_is_selected()): @@ -1741,7 +1741,7 @@ def __init__(self, app, peer, delegate, trust_level): widget = ListEntry(sym+" "+display_str+"\n "+alive_string+", last heard "+pretty_date(int(peer.last_heard))+"\n "+str(len(peer.unhandled_messages))+" unhandled LXMs, "+RNS.prettysize(peer.link_establishment_rate/8, "b")+"/s LER") self.display_widget = urwid.AttrMap(widget, style, focus_style) self.display_widget.destination_hash = destination_hash - urwid.WidgetWrap.__init__(self, self.display_widget) + super().__init__(self.display_widget) def pretty_date(time=False): diff --git a/setup.py b/setup.py index 5e16086..2bc72d0 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,6 @@ entry_points= { 'console_scripts': ['nomadnet=nomadnet.nomadnet:main'] }, - install_requires=["rns>=0.7.0", "lxmf>=0.3.9", "urwid==2.4.2", "qrcode"], + install_requires=["rns>=0.7.0", "lxmf>=0.3.9", "urwid>=2.4.2,!=2.4.3", "qrcode"], python_requires=">=3.6", )