Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
d1005551
by lovetox at 2021-12-26T14:47:25+01:00
-
1218e6e4
by lovetox at 2021-12-26T14:47:25+01:00
-
b95664f4
by lovetox at 2021-12-26T14:47:25+01:00
-
8a2bccca
by lovetox at 2021-12-26T14:47:25+01:00
-
91bbd15f
by lovetox at 2021-12-26T14:47:25+01:00
-
1710897f
by lovetox at 2021-12-26T14:47:25+01:00
8 changed files:
- gajim/common/modules/contacts.py
- gajim/common/structs.py
- gajim/gtk/controls/groupchat.py
- gajim/gtk/controls/private.py
- gajim/gtk/groupchat_roster.py
- gajim/gtk/tooltips.py
- pylintrc
- scripts/ci/pylint.sh
Changes:
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 |
from gajim.common.const import SimpleClientState
|
| 32 | 32 |
from gajim.common.structs import UNKNOWN_PRESENCE
|
| 33 | 33 |
from gajim.common.structs import UNKNOWN_MUC_PRESENCE
|
| 34 |
+from gajim.common.structs import MUCPresenceData
|
|
| 34 | 35 |
from gajim.common.helpers import Observable
|
| 35 | 36 |
from gajim.common.modules.base import BaseModule
|
| 36 | 37 |
from gajim.common.helpers import get_groupchat_name
|
| ... | ... | @@ -573,10 +574,10 @@ def is_in_roster(self) -> bool: |
| 573 | 574 |
return False
|
| 574 | 575 |
|
| 575 | 576 |
@property
|
| 576 |
- def presence(self):
|
|
| 577 |
+ def presence(self) -> MUCPresenceData:
|
|
| 577 | 578 |
return self._presence
|
| 578 | 579 |
|
| 579 |
- def set_presence(self, presence):
|
|
| 580 |
+ def set_presence(self, presence: MUCPresenceData) -> None:
|
|
| 580 | 581 |
self._presence = presence
|
| 581 | 582 |
|
| 582 | 583 |
@property
|
| ... | ... | @@ -631,7 +632,10 @@ def get_avatar(self, |
| 631 | 632 |
return app.interface.avatar_storage.get_surface(
|
| 632 | 633 |
self, size, scale, show, style=style)
|
| 633 | 634 |
|
| 634 |
- def update_presence(self, presence, *args, notify: bool = True) -> None:
|
|
| 635 |
+ def update_presence(self,
|
|
| 636 |
+ presence: MUCPresenceData,
|
|
| 637 |
+ *args: Any,
|
|
| 638 |
+ notify: bool = True) -> None:
|
|
| 635 | 639 |
if not notify:
|
| 636 | 640 |
self._presence = presence
|
| 637 | 641 |
return
|
| ... | ... | @@ -661,7 +665,7 @@ def update_presence(self, presence, *args, notify: bool = True) -> None: |
| 661 | 665 |
for signal in signals:
|
| 662 | 666 |
self.notify(signal, *args)
|
| 663 | 667 |
|
| 664 |
- def set_state(self, state, presence) -> None:
|
|
| 668 |
+ def set_state(self, state, presence: MUCPresenceData) -> None:
|
|
| 665 | 669 |
self._presence = presence
|
| 666 | 670 |
self.notify(state)
|
| 667 | 671 |
|
| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 |
from nbxmpp.protocol import JID
|
| 24 | 24 |
from nbxmpp.const import Role
|
| 25 | 25 |
from nbxmpp.const import Affiliation
|
| 26 |
+from nbxmpp.const import PresenceShow
|
|
| 26 | 27 |
|
| 27 | 28 |
from gajim.common.const import MUCJoinedState
|
| 28 | 29 |
from gajim.common.const import KindConstant
|
| ... | ... | @@ -207,13 +208,13 @@ def from_presence(cls, properties): |
| 207 | 208 |
|
| 208 | 209 |
@dataclass(frozen=True)
|
| 209 | 210 |
class MUCPresenceData:
|
| 210 |
- show: str
|
|
| 211 |
+ show: PresenceShow
|
|
| 211 | 212 |
status: str
|
| 212 |
- idle_time: str
|
|
| 213 |
+ idle_time: Optional[float]
|
|
| 213 | 214 |
available: bool
|
| 214 |
- affiliation: str
|
|
| 215 |
- role: str
|
|
| 216 |
- real_jid: JID
|
|
| 215 |
+ affiliation: Affiliation
|
|
| 216 |
+ role: Role
|
|
| 217 |
+ real_jid: Optional[JID]
|
|
| 217 | 218 |
|
| 218 | 219 |
@classmethod
|
| 219 | 220 |
def from_presence(cls, properties):
|
| ... | ... | @@ -703,9 +703,6 @@ def draw_banner_text(self) -> None: |
| 703 | 703 |
"""
|
| 704 | 704 |
self.xml.banner_name_label.set_text(self.contact.name)
|
| 705 | 705 |
|
| 706 |
- def _on_update_gc_avatar(self, event):
|
|
| 707 |
- self.roster.process_avatar_update(event)
|
|
| 708 |
- |
|
| 709 | 706 |
def _on_bookmarks_received(self, _event):
|
| 710 | 707 |
self.draw_banner_text()
|
| 711 | 708 |
|
| ... | ... | @@ -52,9 +52,6 @@ def __init__(self, account: str, jid: JID) -> None: |
| 52 | 52 |
|
| 53 | 53 |
ChatControl.__init__(self, account, jid)
|
| 54 | 54 |
|
| 55 |
- # self.register_events([
|
|
| 56 |
- # ('update-gc-avatar', ged.GUI1, self._on_update_gc_avatar),
|
|
| 57 |
- |
|
| 58 | 55 |
def _connect_contact_signals(self) -> None:
|
| 59 | 56 |
self.contact.multi_connect({
|
| 60 | 57 |
'user-avatar-update': self._on_user_avatar_update,
|
| ... | ... | @@ -13,10 +13,10 @@ |
| 13 | 13 |
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
| 14 | 14 |
|
| 15 | 15 |
from __future__ import annotations
|
| 16 |
+ |
|
| 16 | 17 |
from typing import Any
|
| 17 |
-from typing import cast
|
|
| 18 | 18 |
from typing import Optional
|
| 19 |
-from typing import Tuple
|
|
| 19 |
+from typing import cast
|
|
| 20 | 20 |
|
| 21 | 21 |
import locale
|
| 22 | 22 |
from enum import IntEnum
|
| ... | ... | @@ -26,7 +26,6 @@ |
| 26 | 26 |
from gi.repository import GLib
|
| 27 | 27 |
from gi.repository import GObject
|
| 28 | 28 |
from nbxmpp.const import Affiliation
|
| 29 |
-from nbxmpp.const import Role
|
|
| 30 | 29 |
from nbxmpp.structs import MessageProperties
|
| 31 | 30 |
|
| 32 | 31 |
from gajim.common import app
|
| ... | ... | @@ -37,6 +36,7 @@ |
| 37 | 36 |
from gajim.common.helpers import jid_is_blocked
|
| 38 | 37 |
from gajim.common.const import AvatarSize
|
| 39 | 38 |
from gajim.common.const import StyleAttr
|
| 39 |
+from gajim.common.nec import NetworkEvent
|
|
| 40 | 40 |
|
| 41 | 41 |
from gajim.gui_menu_builder import get_groupchat_roster_menu
|
| 42 | 42 |
from .tooltips import GCTooltip
|
| ... | ... | @@ -84,9 +84,8 @@ def __init__(self, |
| 84 | 84 |
self.room_jid = room_jid
|
| 85 | 85 |
self._control = control
|
| 86 | 86 |
self._control_id = control.control_id
|
| 87 |
- self._show_roles = True
|
|
| 88 | 87 |
self._tooltip = GCTooltip()
|
| 89 |
- self._group_chat_contact = control.contact
|
|
| 88 |
+ self._group_chat_contact = cast(types.GroupchatContact, control.contact)
|
|
| 90 | 89 |
self._group_chat_contact.connect(
|
| 91 | 90 |
'user-avatar-update', self._on_user_avatar_update)
|
| 92 | 91 |
self._group_chat_contact.connect('user-joined', self._on_user_joined)
|
| ... | ... | @@ -99,22 +98,18 @@ def __init__(self, |
| 99 | 98 |
'user-status-show-changed', self._on_user_status_show_changed)
|
| 100 | 99 |
self._group_chat_contact.connect(
|
| 101 | 100 |
'user-nickname-changed', self._on_user_nickname_changed)
|
| 102 |
- # self._group_chat_contact.connect('muc-user-presence-update',
|
|
| 103 |
- # self._on_muc_user_presence_update)
|
|
| 104 | 101 |
|
| 105 | 102 |
self._ui = get_builder('groupchat_roster.ui')
|
| 106 | 103 |
self._ui.roster_treeview.set_model(None)
|
| 107 | 104 |
self.add(self._ui.roster_treeview)
|
| 108 | 105 |
|
| 109 |
- # Holds the Gtk.TreeRowReference for each contact
|
|
| 110 | 106 |
self._contact_refs: dict[str, Gtk.TreeRowReference] = {}
|
| 111 |
- # Holds the Gtk.TreeRowReference for each group
|
|
| 112 | 107 |
self._group_refs: dict[str, Gtk.TreeRowReference] = {}
|
| 113 | 108 |
|
| 114 |
- self._store = cast(Gtk.TreeStore, self._ui.participant_store)
|
|
| 109 |
+ self._store = self._ui.participant_store
|
|
| 115 | 110 |
self._store.set_sort_func(Column.TEXT, self._tree_compare_iters)
|
| 116 | 111 |
|
| 117 |
- self._roster = cast(Gtk.TreeView, self._ui.roster_treeview)
|
|
| 112 |
+ self._roster = self._ui.roster_treeview
|
|
| 118 | 113 |
self._roster.set_search_equal_func(self._search_func)
|
| 119 | 114 |
self._roster.set_has_tooltip(True)
|
| 120 | 115 |
self._roster.connect('query-tooltip', self._query_tooltip)
|
| ... | ... | @@ -135,12 +130,9 @@ def __init__(self, |
| 135 | 130 |
def _on_focus_out(treeview: Gtk.TreeView, _param: Gdk.EventFocus) -> None:
|
| 136 | 131 |
treeview.get_selection().unselect_all()
|
| 137 | 132 |
|
| 138 |
- def set_model(self) -> None:
|
|
| 133 |
+ def _set_model(self) -> None:
|
|
| 139 | 134 |
self._roster.set_model(self._store)
|
| 140 | 135 |
|
| 141 |
- def set_show_roles(self, enabled: bool) -> None:
|
|
| 142 |
- self._show_roles = enabled
|
|
| 143 |
- |
|
| 144 | 136 |
def _query_tooltip(self,
|
| 145 | 137 |
widget: Gtk.Widget,
|
| 146 | 138 |
x_pos: int,
|
| ... | ... | @@ -148,18 +140,20 @@ def _query_tooltip(self, |
| 148 | 140 |
_keyboard_mode: bool,
|
| 149 | 141 |
tooltip: Gtk.Tooltip
|
| 150 | 142 |
) -> bool:
|
| 151 |
- try:
|
|
| 152 |
- row = self._roster.get_path_at_pos(x_pos, y_pos)[0]
|
|
| 153 |
- except TypeError:
|
|
| 143 |
+ |
|
| 144 |
+ row = self._roster.get_path_at_pos(x_pos, y_pos)
|
|
| 145 |
+ if row is None:
|
|
| 154 | 146 |
self._tooltip.clear_tooltip()
|
| 155 | 147 |
return False
|
| 156 |
- if not row:
|
|
| 148 |
+ |
|
| 149 |
+ path, _, _, _ = row
|
|
| 150 |
+ if path is None:
|
|
| 157 | 151 |
self._tooltip.clear_tooltip()
|
| 158 | 152 |
return False
|
| 159 | 153 |
|
| 160 | 154 |
iter_ = None
|
| 161 | 155 |
try:
|
| 162 |
- iter_ = self._store.get_iter(row)
|
|
| 156 |
+ iter_ = self._store.get_iter(path)
|
|
| 163 | 157 |
except Exception:
|
| 164 | 158 |
self._tooltip.clear_tooltip()
|
| 165 | 159 |
return False
|
| ... | ... | @@ -223,7 +217,7 @@ def _add_contact(self, contact: types.GroupchatParticipant) -> None: |
| 223 | 217 |
role_path = None
|
| 224 | 218 |
if not group_iter:
|
| 225 | 219 |
group_iter = self._store.append(
|
| 226 |
- None, (None, group_text, None, False, group_name))
|
|
| 220 |
+ None, [None, group_text, None, False, group_name])
|
|
| 227 | 221 |
role_path = self._store.get_path(group_iter)
|
| 228 | 222 |
group_ref = Gtk.TreeRowReference(self._store, role_path)
|
| 229 | 223 |
self._group_refs[group_name] = group_ref
|
| ... | ... | @@ -233,12 +227,12 @@ def _add_contact(self, contact: types.GroupchatParticipant) -> None: |
| 233 | 227 |
self.get_scale_factor())
|
| 234 | 228 |
|
| 235 | 229 |
iter_ = self._store.append(group_iter,
|
| 236 |
- (surface, nick, None, True, nick))
|
|
| 230 |
+ [surface, nick, None, True, nick])
|
|
| 237 | 231 |
self._contact_refs[nick] = Gtk.TreeRowReference(
|
| 238 | 232 |
self._store, self._store.get_path(iter_))
|
| 239 | 233 |
|
| 240 |
- self.draw_groups()
|
|
| 241 |
- self.draw_contact(nick)
|
|
| 234 |
+ self._draw_groups()
|
|
| 235 |
+ self._draw_contact(nick)
|
|
| 242 | 236 |
|
| 243 | 237 |
if (role_path is not None and
|
| 244 | 238 |
self._roster.get_model() is not None):
|
| ... | ... | @@ -251,7 +245,7 @@ def _on_user_left(self, |
| 251 | 245 |
*args: Any
|
| 252 | 246 |
) -> None:
|
| 253 | 247 |
self._remove_contact(user_contact)
|
| 254 |
- self.draw_groups()
|
|
| 248 |
+ self._draw_groups()
|
|
| 255 | 249 |
|
| 256 | 250 |
def _update_contact(self,
|
| 257 | 251 |
_contact: types.GroupchatContact,
|
| ... | ... | @@ -279,7 +273,7 @@ def _on_user_status_show_changed(self, |
| 279 | 273 |
user_contact: types.GroupchatParticipant,
|
| 280 | 274 |
*args: Any
|
| 281 | 275 |
) -> None:
|
| 282 |
- self.draw_contact(user_contact.name)
|
|
| 276 |
+ self._draw_contact(user_contact.name)
|
|
| 283 | 277 |
|
| 284 | 278 |
def _remove_contact(self, contact: types.GroupchatParticipant) -> None:
|
| 285 | 279 |
nick = contact.name
|
| ... | ... | @@ -300,7 +294,7 @@ def _remove_contact(self, contact: types.GroupchatParticipant) -> None: |
| 300 | 294 |
|
| 301 | 295 |
@staticmethod
|
| 302 | 296 |
def _get_group_from_contact(contact: types.GroupchatParticipant
|
| 303 |
- ) -> Tuple[str, str]:
|
|
| 297 |
+ ) -> tuple[str, str]:
|
|
| 304 | 298 |
if contact.affiliation in (Affiliation.OWNER, Affiliation.ADMIN):
|
| 305 | 299 |
return contact.affiliation.value, get_uf_affiliation(
|
| 306 | 300 |
contact.affiliation, plural=True)
|
| ... | ... | @@ -357,6 +351,9 @@ def _on_roster_button_press_event(self, |
| 357 | 351 |
return
|
| 358 | 352 |
|
| 359 | 353 |
path, _, _, _ = pos
|
| 354 |
+ if path is None:
|
|
| 355 |
+ return
|
|
| 356 |
+ |
|
| 360 | 357 |
iter_ = self._store.get_iter(path)
|
| 361 | 358 |
if self._store.iter_parent(iter_) is None:
|
| 362 | 359 |
# Group row
|
| ... | ... | @@ -380,7 +377,7 @@ def _show_contact_menu(self, nick: str) -> None: |
| 380 | 377 |
self_contact,
|
| 381 | 378 |
contact)
|
| 382 | 379 |
|
| 383 |
- def destroy(menu, _pspec):
|
|
| 380 |
+ def destroy(menu: Gtk.Menu, _pspec: GObject.ParamSpec) -> None:
|
|
| 384 | 381 |
visible = menu.get_property('visible')
|
| 385 | 382 |
if not visible:
|
| 386 | 383 |
GLib.idle_add(menu.destroy)
|
| ... | ... | @@ -438,22 +435,22 @@ def invalidate_sort(self) -> None: |
| 438 | 435 |
|
| 439 | 436 |
def initial_draw(self) -> None:
|
| 440 | 437 |
self.enable_sort(True)
|
| 441 |
- self.set_model()
|
|
| 438 |
+ self._set_model()
|
|
| 442 | 439 |
self._roster.expand_all()
|
| 443 | 440 |
|
| 444 |
- def redraw(self) -> None:
|
|
| 441 |
+ def _redraw(self) -> None:
|
|
| 445 | 442 |
self._roster.set_model(None)
|
| 446 | 443 |
self._roster.set_model(self._store)
|
| 447 | 444 |
self._roster.expand_all()
|
| 448 | 445 |
|
| 449 |
- def draw_contact(self, nick: str) -> None:
|
|
| 446 |
+ def _draw_contact(self, nick: str) -> None:
|
|
| 450 | 447 |
iter_ = self._get_contact_iter(nick)
|
| 451 | 448 |
if not iter_:
|
| 452 | 449 |
return
|
| 453 | 450 |
|
| 454 | 451 |
contact = self._group_chat_contact.get_resource(nick)
|
| 455 | 452 |
|
| 456 |
- self.draw_avatar(contact)
|
|
| 453 |
+ self._draw_avatar(contact)
|
|
| 457 | 454 |
|
| 458 | 455 |
self._store[iter_][Column.EVENT] = False
|
| 459 | 456 |
|
| ... | ... | @@ -480,9 +477,13 @@ def draw_contact(self, nick: str) -> None: |
| 480 | 477 |
|
| 481 | 478 |
def draw_contacts(self) -> None:
|
| 482 | 479 |
for nick in self._contact_refs:
|
| 483 |
- self.draw_contact(nick)
|
|
| 480 |
+ self._draw_contact(nick)
|
|
| 481 |
+ |
|
| 482 |
+ def _draw_groups(self) -> None:
|
|
| 483 |
+ for group in self._group_refs:
|
|
| 484 |
+ self._draw_group(group)
|
|
| 484 | 485 |
|
| 485 |
- def draw_group(self, group: str) -> None:
|
|
| 486 |
+ def _draw_group(self, group: str) -> None:
|
|
| 486 | 487 |
group_iter = self._get_group_iter(group)
|
| 487 | 488 |
if not group_iter:
|
| 488 | 489 |
return
|
| ... | ... | @@ -499,11 +500,7 @@ def draw_group(self, group: str) -> None: |
| 499 | 500 |
|
| 500 | 501 |
self._store[group_iter][Column.TEXT] = group_text
|
| 501 | 502 |
|
| 502 |
- def draw_groups(self) -> None:
|
|
| 503 |
- for group in self._group_refs:
|
|
| 504 |
- self.draw_group(group)
|
|
| 505 |
- |
|
| 506 |
- def draw_avatar(self, contact: types.GroupchatParticipant) -> None:
|
|
| 503 |
+ def _draw_avatar(self, contact: types.GroupchatParticipant) -> None:
|
|
| 507 | 504 |
iter_ = self._get_contact_iter(contact.name)
|
| 508 | 505 |
if iter_ is None:
|
| 509 | 506 |
return
|
| ... | ... | @@ -512,8 +509,11 @@ def draw_avatar(self, contact: types.GroupchatParticipant) -> None: |
| 512 | 509 |
self.get_scale_factor())
|
| 513 | 510 |
self._store[iter_][Column.AVATAR] = surface
|
| 514 | 511 |
|
| 515 |
- def _on_user_avatar_update(self, _contact, _signal_name, user_contact):
|
|
| 516 |
- self.draw_avatar(user_contact)
|
|
| 512 |
+ def _on_user_avatar_update(self,
|
|
| 513 |
+ _contact: types.GroupchatContact,
|
|
| 514 |
+ _signal_name: str,
|
|
| 515 |
+ user_contact: types.GroupchatParticipant):
|
|
| 516 |
+ self._draw_avatar(user_contact)
|
|
| 517 | 517 |
|
| 518 | 518 |
def _get_total_user_count(self) -> int:
|
| 519 | 519 |
count = 0
|
| ... | ... | @@ -521,15 +521,8 @@ def _get_total_user_count(self) -> int: |
| 521 | 521 |
count += self._store.iter_n_children(group_row.iter)
|
| 522 | 522 |
return count
|
| 523 | 523 |
|
| 524 |
- def get_role(self, nick: str) -> Role:
|
|
| 525 |
- contact = self._group_chat_contact.get_resource(nick)
|
|
| 526 |
- return contact.role
|
|
| 527 |
- |
|
| 528 |
- def _on_theme_update(self, _event):
|
|
| 529 |
- self.redraw()
|
|
| 530 |
- |
|
| 531 |
- def process_avatar_update(self, event):
|
|
| 532 |
- self.draw_avatar(event.contact)
|
|
| 524 |
+ def _on_theme_update(self, _event: NetworkEvent) -> None:
|
|
| 525 |
+ self._redraw()
|
|
| 533 | 526 |
|
| 534 | 527 |
def clear(self) -> None:
|
| 535 | 528 |
self._contact_refs = {}
|
| ... | ... | @@ -538,16 +531,15 @@ def clear(self) -> None: |
| 538 | 531 |
|
| 539 | 532 |
def _on_destroy(self, _roster: Any) -> None:
|
| 540 | 533 |
self._group_chat_contact.disconnect(self)
|
| 541 |
- |
|
| 542 | 534 |
self._contact_refs = {}
|
| 543 | 535 |
self._group_refs = {}
|
| 544 |
- self._control = None
|
|
| 545 | 536 |
self._roster.set_model(None)
|
| 546 |
- self._roster = None
|
|
| 547 | 537 |
self._store.clear()
|
| 548 | 538 |
# Store keeps a ref on the object if we dont unset the sort func
|
| 549 | 539 |
self._store.set_sort_func(Column.TEXT, print)
|
| 550 |
- self._store = None
|
|
| 551 | 540 |
self._tooltip.destroy()
|
| 552 |
- self._tooltip = None
|
|
| 541 |
+ del self._roster
|
|
| 542 |
+ del self._store
|
|
| 543 |
+ del self._control
|
|
| 544 |
+ del self._tooltip
|
|
| 553 | 545 |
app.check_finalize(self)
|
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 |
|
| 36 | 36 |
from nbxmpp import JID
|
| 37 | 37 |
|
| 38 |
-from gajim.common import app
|
|
| 38 |
+from gajim.common import app, types
|
|
| 39 | 39 |
from gajim.common import helpers
|
| 40 | 40 |
from gajim.common.const import AvatarSize
|
| 41 | 41 |
from gajim.common.const import PEPEventType
|
| ... | ... | @@ -51,15 +51,18 @@ |
| 51 | 51 |
|
| 52 | 52 |
|
| 53 | 53 |
class GCTooltip:
|
| 54 |
- def __init__(self):
|
|
| 54 |
+ def __init__(self) -> None:
|
|
| 55 | 55 |
self._contact = None
|
| 56 | 56 |
|
| 57 | 57 |
self._ui = get_builder('groupchat_roster_tooltip.ui')
|
| 58 | 58 |
|
| 59 |
- def clear_tooltip(self):
|
|
| 59 |
+ def clear_tooltip(self) -> None:
|
|
| 60 | 60 |
self._contact = None
|
| 61 | 61 |
|
| 62 |
- def get_tooltip(self, contact):
|
|
| 62 |
+ def get_tooltip(self,
|
|
| 63 |
+ contact: types.GroupchatParticipant
|
|
| 64 |
+ ) -> tuple[bool, Gtk.Grid]:
|
|
| 65 |
+ |
|
| 63 | 66 |
if self._contact == contact:
|
| 64 | 67 |
return True, self._ui.tooltip_grid
|
| 65 | 68 |
|
| ... | ... | @@ -67,14 +70,14 @@ def get_tooltip(self, contact): |
| 67 | 70 |
self._contact = contact
|
| 68 | 71 |
return False, self._ui.tooltip_grid
|
| 69 | 72 |
|
| 70 |
- def _hide_grid_children(self):
|
|
| 73 |
+ def _hide_grid_children(self) -> None:
|
|
| 71 | 74 |
"""
|
| 72 | 75 |
Hide all Elements of the Tooltip Grid
|
| 73 | 76 |
"""
|
| 74 | 77 |
for child in self._ui.tooltip_grid.get_children():
|
| 75 | 78 |
child.hide()
|
| 76 | 79 |
|
| 77 |
- def _populate_grid(self, contact):
|
|
| 80 |
+ def _populate_grid(self, contact: types.GroupchatParticipant) -> None:
|
|
| 78 | 81 |
"""
|
| 79 | 82 |
Populate the Tooltip Grid with data of from the contact
|
| 80 | 83 |
"""
|
| ... | ... | @@ -119,18 +122,20 @@ def destroy(self): |
| 119 | 122 |
|
| 120 | 123 |
|
| 121 | 124 |
class RosterTooltip:
|
| 122 |
- def __init__(self):
|
|
| 125 |
+ def __init__(self) -> None:
|
|
| 123 | 126 |
self._row = None
|
| 124 | 127 |
self._ui = get_builder('roster_tooltip.ui')
|
| 125 | 128 |
|
| 126 |
- def clear_tooltip(self):
|
|
| 129 |
+ def clear_tooltip(self) -> None:
|
|
| 127 | 130 |
self._row = None
|
| 128 | 131 |
for widget in self._ui.resources_box.get_children():
|
| 129 | 132 |
widget.destroy()
|
| 130 | 133 |
for widget in self._ui.tooltip_grid.get_children():
|
| 131 | 134 |
widget.hide()
|
| 132 | 135 |
|
| 133 |
- def get_tooltip(self, row, contact):
|
|
| 136 |
+ def get_tooltip(self,
|
|
| 137 |
+ row: Gtk.TreePath,
|
|
| 138 |
+ contact: types.BareContact) -> tuple[bool, Gtk.Grid]:
|
|
| 134 | 139 |
if self._row == row:
|
| 135 | 140 |
return True, self._ui.tooltip_grid
|
| 136 | 141 |
|
| ... | ... | @@ -138,7 +143,7 @@ def get_tooltip(self, row, contact): |
| 138 | 143 |
self._row = row
|
| 139 | 144 |
return False, self._ui.tooltip_grid
|
| 140 | 145 |
|
| 141 |
- def _populate_grid(self, contact):
|
|
| 146 |
+ def _populate_grid(self, contact: types.BareContact) -> None:
|
|
| 142 | 147 |
self.clear_tooltip()
|
| 143 | 148 |
scale = self._ui.tooltip_grid.get_scale_factor()
|
| 144 | 149 |
|
| ... | ... | @@ -184,7 +189,7 @@ def _populate_grid(self, contact): |
| 184 | 189 |
break
|
| 185 | 190 |
last_widget.set_vexpand(True)
|
| 186 | 191 |
|
| 187 |
- def _add_resources(self, contact):
|
|
| 192 |
+ def _add_resources(self, contact: types.BareContact) -> None:
|
|
| 188 | 193 |
for resource in contact.iter_resources():
|
| 189 | 194 |
resource_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
| 190 | 195 |
|
| ... | ... | @@ -241,7 +246,7 @@ def _add_resources(self, contact): |
| 241 | 246 |
|
| 242 | 247 |
self._ui.resources_box.show_all()
|
| 243 | 248 |
|
| 244 |
- def _append_pep_info(self, contact):
|
|
| 249 |
+ def _append_pep_info(self, contact: types.BareContact) -> None:
|
|
| 245 | 250 |
if PEPEventType.TUNE in contact.pep:
|
| 246 | 251 |
tune = format_tune(*contact.pep[PEPEventType.TUNE])
|
| 247 | 252 |
self._ui.tune.set_markup(tune)
|
| ... | ... | @@ -256,7 +261,7 @@ def _append_pep_info(self, contact): |
| 256 | 261 |
|
| 257 | 262 |
|
| 258 | 263 |
class FileTransfersTooltip:
|
| 259 |
- def __init__(self):
|
|
| 264 |
+ def __init__(self) -> None:
|
|
| 260 | 265 |
self.sid = None
|
| 261 | 266 |
self.widget = None
|
| 262 | 267 |
if app.settings.get('use_kib_mib'):
|
| ... | ... | @@ -264,11 +269,11 @@ def __init__(self): |
| 264 | 269 |
else:
|
| 265 | 270 |
self.units = GLib.FormatSizeFlags.DEFAULT
|
| 266 | 271 |
|
| 267 |
- def clear_tooltip(self):
|
|
| 272 |
+ def clear_tooltip(self) -> None:
|
|
| 268 | 273 |
self.sid = None
|
| 269 | 274 |
self.widget = None
|
| 270 | 275 |
|
| 271 |
- def get_tooltip(self, file_props, sid):
|
|
| 276 |
+ def get_tooltip(self, file_props, sid) -> tuple[bool, Gtk.Widget]:
|
|
| 272 | 277 |
if self.sid == sid:
|
| 273 | 278 |
return True, self.widget
|
| 274 | 279 |
|
| ... | ... | @@ -276,7 +281,7 @@ def get_tooltip(self, file_props, sid): |
| 276 | 281 |
self.sid = sid
|
| 277 | 282 |
return False, self.widget
|
| 278 | 283 |
|
| 279 |
- def _create_tooltip(self, file_props, _sid):
|
|
| 284 |
+ def _create_tooltip(self, file_props, _sid) -> None:
|
|
| 280 | 285 |
ft_grid = Gtk.Grid.new()
|
| 281 | 286 |
ft_grid.insert_column(0)
|
| 282 | 287 |
ft_grid.set_row_spacing(6)
|
| ... | ... | @@ -336,7 +341,7 @@ def _create_tooltip(self, file_props, _sid): |
| 336 | 341 |
return ft_grid
|
| 337 | 342 |
|
| 338 | 343 |
@staticmethod
|
| 339 |
- def _get_current_status(file_props):
|
|
| 344 |
+ def _get_current_status(file_props) -> None:
|
|
| 340 | 345 |
if file_props.stopped:
|
| 341 | 346 |
return Q_('?transfer status:Aborted')
|
| 342 | 347 |
if file_props.completed:
|
| ... | ... | @@ -50,9 +50,12 @@ confidence= |
| 50 | 50 |
# --enable=similarities". If you want to run only the classes checker, but have
|
| 51 | 51 |
# no Warning level messages displayed, use"--disable=all --enable=classes
|
| 52 | 52 |
# --disable=W"
|
| 53 |
+#
|
|
| 54 |
+# Most errors here are disabled because they are covered by pyright
|
|
| 53 | 55 |
# C0111 missing-docstring
|
| 54 | 56 |
# W0511 fix-me
|
| 55 |
-disable=C0111,W0511
|
|
| 57 |
+#
|
|
| 58 |
+disable=C0111,W0511,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1140,E1141,E1142,I1101,W0212,W1113,W1114,W1115,W1116
|
|
| 56 | 59 |
|
| 57 | 60 |
# Enable the message, report, category or checker with the given id(s). You can
|
| 58 | 61 |
# either give multiple identifier separated by comma (,) or put this option
|
| ... | ... | @@ -5,18 +5,54 @@ set -e |
| 5 | 5 |
|
| 6 | 6 |
PYLINT=${PYLINT:-pylint}
|
| 7 | 7 |
|
| 8 |
+# Errors which are covered by pyright
|
|
| 9 |
+#
|
|
| 10 |
+# E1101 no-member
|
|
| 11 |
+# E1102 not-callable
|
|
| 12 |
+# E1111 assignment-from-no-return
|
|
| 13 |
+# E1120 no-value-for-parameter
|
|
| 14 |
+# E1121 too-many-function-args
|
|
| 15 |
+# E1123 unexpected-keyword-arg
|
|
| 16 |
+# E1124 redundant-keyword-arg
|
|
| 17 |
+# E1125 missing-kwoa
|
|
| 18 |
+# E1126 invalid-sequence-index
|
|
| 19 |
+# E1127 invalid-slice-index
|
|
| 20 |
+# E1128 assignment-from-none
|
|
| 21 |
+# E1129 not-context-manager
|
|
| 22 |
+# E1130 invalid-unary-operand-type
|
|
| 23 |
+# E1131 unsupported-binary-operation
|
|
| 24 |
+# E1132 repeated-keyword
|
|
| 25 |
+# E1133 not-an-iterable
|
|
| 26 |
+# E1134 not-a-mapping
|
|
| 27 |
+# E1135 unsupported-membership-test
|
|
| 28 |
+# E1136 unsubscriptable-object
|
|
| 29 |
+# E1137 unsupported-assignment-operation
|
|
| 30 |
+# E1138 unsupported-delete-operation
|
|
| 31 |
+# E1139 invalid-metaclass
|
|
| 32 |
+# E1140 unhashable-dict-key
|
|
| 33 |
+# E1141 dict-iter-missing-items
|
|
| 34 |
+# E1142 await-outside-async
|
|
| 35 |
+# I1101 c-extension-no-member
|
|
| 36 |
+# W0212 protected-access
|
|
| 37 |
+# W1113 keyword-arg-before-vararg
|
|
| 38 |
+# W1114 arguments-out-of-order
|
|
| 39 |
+# W1115 non-str-assignment-to-dunder-name
|
|
| 40 |
+# W1116 isinstance-second-argument-not-valid-type
|
|
| 41 |
+ |
|
| 42 |
+IGNORE_PYRIGHT='E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1140,E1141,E1142,I1101,W0212,W1113,W1114,W1115,W1116'
|
|
| 43 |
+ |
|
| 8 | 44 |
IGNORE_ALWAYS='R0801,C0209,W0237,W0707,R1732,W1404,W1406,R1725'
|
| 9 | 45 |
|
| 10 |
-IGNORE_ERRORS=C0103,C0302,C0301,C0330,C0411,C0415,E0401,E0611,E1101,E1133,E1136,R0201,R0901,R0904,R0912,R0913,R0914,R0915,R0916,R1702,R1710,W0201,W0212,W0221,W0223,W0231,W0233,W0603,W0613
|
|
| 46 |
+IGNORE_ERRORS=C0103,C0302,C0301,C0330,C0411,C0415,E0401,E0611,R0201,R0901,R0904,R0912,R0913,R0914,R0915,R0916,R1702,R1710,W0201,W0221,W0223,W0231,W0233,W0603,W0613
|
|
| 11 | 47 |
|
| 12 |
-IGNORE_GTK_MODULE_ERRORS=C0103,C0301,C0330,C0415,E0401,E0611,E1101,E1133,E1136,R0201,R0904,R0915,R1710,W0201,W0212,W0233,W0221,W0613
|
|
| 48 |
+IGNORE_GTK_MODULE_ERRORS=C0103,C0301,C0330,C0415,E0401,E0611,R0201,R0904,R0915,R1710,W0201,W0233,W0221,W0613
|
|
| 13 | 49 |
|
| 14 | 50 |
"$PYLINT" --version
|
| 15 | 51 |
|
| 16 |
-"$PYLINT" --disable="$IGNORE_ALWAYS,$IGNORE_ERRORS" --ignore=modules,dbus,gtk "$@"
|
|
| 17 |
-"$PYLINT" --disable="$IGNORE_ALWAYS,$IGNORE_GTK_MODULE_ERRORS" "$@/gtk"
|
|
| 18 |
-"$PYLINT" --disable="$IGNORE_ALWAYS,E0401,C0415" "$@/common/modules"
|
|
| 19 |
-"$PYLINT" --disable=$IGNORE_ALWAYS "$@/common/dbus"
|
|
| 52 |
+"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS,$IGNORE_ERRORS" --ignore=modules,dbus,gtk "$@"
|
|
| 53 |
+"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS,$IGNORE_GTK_MODULE_ERRORS" "$@/gtk"
|
|
| 54 |
+"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS,E0401,C0415" "$@/common/modules"
|
|
| 55 |
+"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS" "$@/common/dbus"
|
|
| 20 | 56 |
|
| 21 | 57 |
# C0103 invalid-name
|
| 22 | 58 |
# C0209 use-f-string
|
| ... | ... | @@ -26,9 +62,6 @@ IGNORE_GTK_MODULE_ERRORS=C0103,C0301,C0330,C0415,E0401,E0611,E1101,E1133,E1136,R |
| 26 | 62 |
# C0415 import-outside-toplevel
|
| 27 | 63 |
# E0401 import-error
|
| 28 | 64 |
# E0611 no-name-in-module
|
| 29 |
-# E1101 no-member
|
|
| 30 |
-# E1133 not-an-iterable
|
|
| 31 |
-# E1136 unsubscriptable-object
|
|
| 32 | 65 |
# R0201 no-self-use
|
| 33 | 66 |
# R0801 duplicat-code
|
| 34 | 67 |
# R0901 too-many-ancestors
|
| ... | ... | @@ -43,7 +76,6 @@ IGNORE_GTK_MODULE_ERRORS=C0103,C0301,C0330,C0415,E0401,E0611,E1101,E1133,E1136,R |
| 43 | 76 |
# R1732 consider-using-with
|
| 44 | 77 |
# R1725 super-with-arguments
|
| 45 | 78 |
# W0201 attribute-defined-outside-init
|
| 46 |
-# W0212 protected-access
|
|
| 47 | 79 |
# W0221 arguments-differ
|
| 48 | 80 |
# W0223 abstract-method
|
| 49 | 81 |
# W0231 super-init-not-called
|