Philipp Hörist pushed to branch master at gajim / gajim
Commits: 015b8548 by lovetox at 2022-08-16T20:53:26+02:00 cq: Fix some annotations to prevent import cycles
- - - - - 3913515f by lovetox at 2022-08-16T20:58:52+02:00 refactor: Simplify QuoteWidget to prevent import cycles
- - - - -
5 changed files:
- gajim/gtk/chat_action_processor.py - gajim/gtk/conversation/message_widget.py - gajim/gtk/conversation/quote_widget.py - gajim/gtk/groupchat_nick_completion.py - pyrightconfig.json
Changes:
===================================== gajim/gtk/chat_action_processor.py ===================================== @@ -16,7 +16,6 @@
from typing import cast from typing import Optional -from typing import TYPE_CHECKING
from gi.repository import Gdk from gi.repository import Gio @@ -31,14 +30,12 @@ from .emoji_data_gtk import get_emoji_data from .groupchat_nick_completion import GroupChatNickCompletion
-if TYPE_CHECKING: - from .message_input import MessageInputTextView
MAX_ENTRIES = 5
class ChatActionProcessor(Gtk.Popover): - def __init__(self, message_input: MessageInputTextView) -> None: + def __init__(self, message_input: Gtk.TextView) -> None: Gtk.Popover.__init__(self) self._menu = Gio.Menu() self.bind_model(self._menu) @@ -75,7 +72,7 @@ def _on_destroy(self, _popover: Gtk.Popover) -> None: app.check_finalize(self)
def _on_key_press(self, - textview: MessageInputTextView, + textview: Gtk.TextView, event: Gdk.EventKey ) -> bool: if isinstance(self._contact, GroupchatContact): @@ -125,7 +122,7 @@ def _get_commands(self) -> list[tuple[str, str]]: assert self._contact is not None return app.commands.get_commands(self._contact.type_string)
- def _on_changed(self, _textview: MessageInputTextView) -> None: + def _on_changed(self, _text_buffer: Gtk.TextBuffer) -> None: insert = self._buf.get_insert() self._current_iter = self._buf.get_iter_at_mark(insert) current_offset = self._current_iter.get_offset()
===================================== gajim/gtk/conversation/message_widget.py ===================================== @@ -86,7 +86,7 @@ def add_content(self, content: ContentT) -> None: message_widget = MessageWidget(self._account, self._selectable) message_widget.add_content(block) widget = QuoteWidget(self._account) - widget.attach_message_widget(message_widget) + widget.add(message_widget) self.add(widget) continue
===================================== gajim/gtk/conversation/quote_widget.py ===================================== @@ -14,13 +14,8 @@
from __future__ import annotations
-import typing - from gi.repository import Gtk
-if typing.TYPE_CHECKING: - from .message_widget import MessageWidget -
class QuoteWidget(Gtk.Box): def __init__(self, account: str) -> None: @@ -32,16 +27,3 @@ def __init__(self, account: str) -> None: quote_bar.set_margin_end(6) quote_bar.get_style_context().add_class('conversation-quote-bar') self.add(quote_bar) - - self._account = account - - self._message_widget = None - - def attach_message_widget(self, message_widget: MessageWidget) -> None: - - # Purpose of this method is to prevent circular imports - if self._message_widget is not None: - raise ValueError( - 'QuoteWidget already has a MessageWidget attached') - self._message_widget = message_widget - self.add(message_widget)
===================================== gajim/gtk/groupchat_nick_completion.py ===================================== @@ -15,12 +15,12 @@ from __future__ import annotations
from typing import Optional -from typing import TYPE_CHECKING
import logging
from nbxmpp.structs import PresenceProperties
+from gi.repository import Gtk from gi.repository import Gdk
from gajim.common import app @@ -31,8 +31,6 @@ from gajim.common.helpers import jid_is_blocked from gajim.common.helpers import message_needs_highlight
-if TYPE_CHECKING: - from .message_input import MessageInputTextView
log = logging.getLogger('gajim.gui.groupchat_nick_completion')
@@ -186,7 +184,7 @@ def _nick_matching(nick: str) -> bool: return matches + other_nicks
def process_key_press(self, - textview: MessageInputTextView, + textview: Gtk.TextView, event: Gdk.EventKey ) -> bool: if (event.get_state() & Gdk.ModifierType.SHIFT_MASK or
===================================== pyrightconfig.json ===================================== @@ -2,7 +2,6 @@ "pythonPlatform": "All", "pythonVersion": "3.9", "typeCheckingMode": "strict", - "reportImportCycles": "none", "reportUnnecessaryTypeIgnoreComment": "error", "reportPropertyTypeMismatch": "error", "reportMissingModuleSource": "none",
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/f7fecc737cb14a9f3a8dd61ba3a5255a...