Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
f8f4f934
by Philipp Hörist at 2023-01-05T19:44:33+01:00
-
b81e8ac8
by Philipp Hörist at 2023-01-05T19:55:27+01:00
28 changed files:
- .pre-commit-config.yaml
- gajim/common/configpaths.py
- gajim/common/helpers.py
- gajim/common/modules/contacts.py
- gajim/common/modules/roster.py
- gajim/common/storage/archive.py
- gajim/gtk/chat_list_stack.py
- gajim/gtk/conversation/jump_to_end_button.py
- gajim/gtk/conversation/message_widget.py
- gajim/gtk/conversation/plain_widget.py
- gajim/gtk/conversation/rows/call.py
- gajim/gtk/conversation/rows/command_output.py
- gajim/gtk/conversation/rows/file_transfer.py
- gajim/gtk/conversation/rows/file_transfer_jingle.py
- gajim/gtk/conversation/rows/info.py
- gajim/gtk/conversation/rows/message.py
- gajim/gtk/conversation/rows/muc_join_left.py
- gajim/gtk/conversation/rows/muc_subject.py
- gajim/gtk/conversation/rows/user_status.py
- gajim/gtk/conversation/rows/widgets.py
- gajim/gtk/conversation/view.py
- gajim/gtk/groupchat_affiliation.py
- gajim/gtk/groupchat_outcasts.py
- gajim/gtk/preferences.py
- gajim/gui/__init__.py
- gajim/plugins/gajimplugin.py
- gajim/plugins/manifest.py
- pyproject.toml
Changes:
| 1 | 1 | repos:
|
| 2 | 2 | - repo: https://github.com/charliermarsh/ruff-pre-commit
|
| 3 | - rev: v0.0.206
|
|
| 3 | + rev: v0.0.211
|
|
| 4 | 4 | hooks:
|
| 5 | 5 | - id: ruff
|
| 6 | 6 | exclude: ".githooks/"
|
| ... | ... | @@ -15,7 +15,7 @@ repos: |
| 15 | 15 | - tomli
|
| 16 | 16 | |
| 17 | 17 | - repo: https://github.com/RobertCraigie/pyright-python
|
| 18 | - rev: v1.1.286
|
|
| 18 | + rev: v1.1.287
|
|
| 19 | 19 | hooks:
|
| 20 | 20 | - id: pyright
|
| 21 | 21 | pass_filenames: false
|
| ... | ... | @@ -144,8 +144,7 @@ def __getitem__(self, key: str) -> Path: |
| 144 | 144 | return path
|
| 145 | 145 | |
| 146 | 146 | def items(self) -> Generator[tuple[str, PathTupleT], None, None]:
|
| 147 | - for key, value in self._paths.items():
|
|
| 148 | - yield (key, value)
|
|
| 147 | + yield from self._paths.items()
|
|
| 149 | 148 | |
| 150 | 149 | def _prepare(self, path: Path, unique: bool) -> Path:
|
| 151 | 150 | if os.name == 'nt':
|
| ... | ... | @@ -1422,10 +1422,7 @@ def warn_about_plain_connection(account: str, |
| 1422 | 1422 | ) -> bool:
|
| 1423 | 1423 | warn = app.settings.get_account_setting(
|
| 1424 | 1424 | account, 'confirm_unencrypted_connection')
|
| 1425 | - for type_ in connection_types:
|
|
| 1426 | - if type_.is_plain and warn:
|
|
| 1427 | - return True
|
|
| 1428 | - return False
|
|
| 1425 | + return any(type_.is_plain and warn for type_ in connection_types)
|
|
| 1429 | 1426 | |
| 1430 | 1427 | |
| 1431 | 1428 | def get_idle_status_message(state: str, status_message: str) -> str:
|
| ... | ... | @@ -351,10 +351,8 @@ def is_self(self): |
| 351 | 351 | return own_jid == self.jid
|
| 352 | 352 | |
| 353 | 353 | def supports(self, requested_feature: str) -> bool:
|
| 354 | - for resource in self.iter_resources():
|
|
| 355 | - if resource.supports(requested_feature):
|
|
| 356 | - return True
|
|
| 357 | - return False
|
|
| 354 | + return any(resource.supports(requested_feature)
|
|
| 355 | + for resource in self.iter_resources())
|
|
| 358 | 356 | |
| 359 | 357 | def supports_audio(self) -> bool:
|
| 360 | 358 | if (self.supports(Namespace.JINGLE_ICE_UDP) and
|
| ... | ... | @@ -600,10 +598,8 @@ def is_phone(self): |
| 600 | 598 | if disco_info is None:
|
| 601 | 599 | return False
|
| 602 | 600 | |
| 603 | - for identity in disco_info.identities:
|
|
| 604 | - if identity.type == 'phone':
|
|
| 605 | - return True
|
|
| 606 | - return False
|
|
| 601 | + return any(identity.type == 'phone' for
|
|
| 602 | + identity in disco_info.identities)
|
|
| 607 | 603 | |
| 608 | 604 | @property
|
| 609 | 605 | def is_available(self) -> bool:
|
| ... | ... | @@ -204,8 +204,7 @@ def change_group(self, jid: JID, old_group: str, new_group: str) -> None: |
| 204 | 204 | self._nbxmpp('Roster').set_item(jid, item.name, groups)
|
| 205 | 205 | |
| 206 | 206 | def iter(self) -> Iterator[tuple[JID, RosterItem]]:
|
| 207 | - for jid, data in self._roster.items():
|
|
| 208 | - yield jid, data
|
|
| 207 | + yield from self._roster.items()
|
|
| 209 | 208 | |
| 210 | 209 | def iter_contacts(self) -> Iterator[BareContact]:
|
| 211 | 210 | for jid in self._roster:
|
| ... | ... | @@ -1367,8 +1367,7 @@ def get_messages_for_export(self, |
| 1367 | 1367 | results = cursor.fetchmany(10)
|
| 1368 | 1368 | if not results:
|
| 1369 | 1369 | break
|
| 1370 | - for result in results:
|
|
| 1371 | - yield result
|
|
| 1370 | + yield from results
|
|
| 1372 | 1371 | |
| 1373 | 1372 | def remove_history(self, account: str, jid: JID) -> None:
|
| 1374 | 1373 | '''
|
| ... | ... | @@ -309,10 +309,8 @@ def find_chat(self, account: str, jid: JID) -> Optional[ChatList]: |
| 309 | 309 | def contains_chat(self, account: str, jid: JID,
|
| 310 | 310 | workspace_id: Optional[str] = None) -> bool:
|
| 311 | 311 | if workspace_id is None:
|
| 312 | - for chat_list in self._chat_lists.values():
|
|
| 313 | - if chat_list.contains_chat(account, jid):
|
|
| 314 | - return True
|
|
| 315 | - return False
|
|
| 312 | + return any(chat_list.contains_chat(account, jid) for
|
|
| 313 | + chat_list in self._chat_lists.values())
|
|
| 316 | 314 | |
| 317 | 315 | chat_list = self._chat_lists[workspace_id]
|
| 318 | 316 | return chat_list.contains_chat(account, jid)
|
| ... | ... | @@ -19,10 +19,9 @@ |
| 19 | 19 | from gi.repository import GObject
|
| 20 | 20 | from gi.repository import Gtk
|
| 21 | 21 | |
| 22 | +from gajim.common.modules.contacts import BareContact
|
|
| 22 | 23 | from gajim.common.modules.contacts import GroupchatContact
|
| 23 | 24 | from gajim.common.modules.contacts import GroupchatParticipant
|
| 24 | -from gajim.common.modules.contacts import BareContact
|
|
| 25 | - |
|
| 26 | 25 | |
| 27 | 26 | ContactT = Union[BareContact, GroupchatContact, GroupchatParticipant]
|
| 28 | 27 |
| ... | ... | @@ -14,22 +14,21 @@ |
| 14 | 14 | |
| 15 | 15 | from __future__ import annotations
|
| 16 | 16 | |
| 17 | +from typing import cast
|
|
| 17 | 18 | from typing import Optional
|
| 18 | 19 | from typing import Union
|
| 19 | -from typing import cast
|
|
| 20 | 20 | |
| 21 | 21 | from gi.repository import Gtk
|
| 22 | 22 | |
| 23 | -from gajim.common.styling import process
|
|
| 24 | 23 | from gajim.common.styling import ParsingResult
|
| 25 | 24 | from gajim.common.styling import PlainBlock
|
| 26 | 25 | from gajim.common.styling import PreBlock
|
| 26 | +from gajim.common.styling import process
|
|
| 27 | 27 | from gajim.common.styling import QuoteBlock
|
| 28 | 28 | |
| 29 | 29 | from .code_widget import CodeWidget
|
| 30 | -from .quote_widget import QuoteWidget
|
|
| 31 | 30 | from .plain_widget import PlainWidget
|
| 32 | - |
|
| 31 | +from .quote_widget import QuoteWidget
|
|
| 33 | 32 | |
| 34 | 33 | ContentT = Union[ParsingResult, QuoteBlock]
|
| 35 | 34 |
| ... | ... | @@ -16,10 +16,10 @@ |
| 16 | 16 | |
| 17 | 17 | import logging
|
| 18 | 18 | |
| 19 | -from gi.repository import Gtk
|
|
| 20 | -from gi.repository import Pango
|
|
| 21 | 19 | from gi.repository import Gdk
|
| 22 | 20 | from gi.repository import GLib
|
| 21 | +from gi.repository import Gtk
|
|
| 22 | +from gi.repository import Pango
|
|
| 23 | 23 | |
| 24 | 24 | from gajim.common.helpers import open_uri
|
| 25 | 25 | from gajim.common.helpers import parse_uri
|
| ... | ... | @@ -31,10 +31,10 @@ |
| 31 | 31 | from gajim.common.jingle_session import JingleSession
|
| 32 | 32 | from gajim.common.storage.archive import ConversationRow
|
| 33 | 33 | |
| 34 | +from .base import BaseRow
|
|
| 34 | 35 | from .widgets import DateTimeLabel
|
| 35 | 36 | from .widgets import NicknameLabel
|
| 36 | 37 | from .widgets import SimpleLabel
|
| 37 | -from .base import BaseRow
|
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | class CallRow(BaseRow):
|
| ... | ... | @@ -20,9 +20,9 @@ |
| 20 | 20 | |
| 21 | 21 | from gajim.common.const import AvatarSize
|
| 22 | 22 | |
| 23 | +from .base import BaseRow
|
|
| 23 | 24 | from .widgets import DateTimeLabel
|
| 24 | 25 | from .widgets import SimpleLabel
|
| 25 | -from .base import BaseRow
|
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | class CommandOutputRow(BaseRow):
|
| ... | ... | @@ -26,12 +26,12 @@ |
| 26 | 26 | from gajim.common.i18n import _
|
| 27 | 27 | from gajim.common.modules.httpupload import HTTPFileTransfer
|
| 28 | 28 | |
| 29 | -from .base import BaseRow
|
|
| 30 | -from .widgets import DateTimeLabel
|
|
| 29 | +from ...builder import get_builder
|
|
| 31 | 30 | from ...dialogs import ErrorDialog
|
| 32 | 31 | from ...util import EventHelper
|
| 33 | -from ...builder import get_builder
|
|
| 34 | 32 | from ...util import format_eta
|
| 33 | +from .base import BaseRow
|
|
| 34 | +from .widgets import DateTimeLabel
|
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | class FileTransferRow(BaseRow, EventHelper):
|
| ... | ... | @@ -14,8 +14,8 @@ |
| 14 | 14 | |
| 15 | 15 | from __future__ import annotations
|
| 16 | 16 | |
| 17 | -from typing import Union
|
|
| 18 | 17 | from typing import Optional
|
| 18 | +from typing import Union
|
|
| 19 | 19 | |
| 20 | 20 | import logging
|
| 21 | 21 | import time
|
| ... | ... | @@ -30,14 +30,14 @@ |
| 30 | 30 | from gajim.common import ged
|
| 31 | 31 | from gajim.common.const import AvatarSize
|
| 32 | 32 | from gajim.common.const import KindConstant
|
| 33 | -from gajim.common.events import FileRequestReceivedEvent
|
|
| 34 | -from gajim.common.events import FileRequestSent
|
|
| 35 | 33 | from gajim.common.events import FileCompleted
|
| 36 | -from gajim.common.events import FileProgress
|
|
| 37 | 34 | from gajim.common.events import FileError
|
| 38 | 35 | from gajim.common.events import FileHashError
|
| 39 | -from gajim.common.events import FileSendError
|
|
| 36 | +from gajim.common.events import FileProgress
|
|
| 40 | 37 | from gajim.common.events import FileRequestError
|
| 38 | +from gajim.common.events import FileRequestReceivedEvent
|
|
| 39 | +from gajim.common.events import FileRequestSent
|
|
| 40 | +from gajim.common.events import FileSendError
|
|
| 41 | 41 | from gajim.common.events import JingleErrorReceived
|
| 42 | 42 | from gajim.common.events import JingleFtCancelledReceived
|
| 43 | 43 | from gajim.common.file_props import FileProp
|
| ... | ... | @@ -48,11 +48,11 @@ |
| 48 | 48 | from gajim.common.modules.contacts import BareContact
|
| 49 | 49 | from gajim.common.storage.archive import ConversationRow
|
| 50 | 50 | |
| 51 | +from ...builder import get_builder
|
|
| 52 | +from ...util import format_eta
|
|
| 51 | 53 | from .base import BaseRow
|
| 52 | 54 | from .widgets import DateTimeLabel
|
| 53 | 55 | from .widgets import NicknameLabel
|
| 54 | -from ...builder import get_builder
|
|
| 55 | -from ...util import format_eta
|
|
| 56 | 56 | |
| 57 | 57 | TransferEventT = Union[FileRequestReceivedEvent, FileRequestSent]
|
| 58 | 58 |
| ... | ... | @@ -23,9 +23,9 @@ |
| 23 | 23 | |
| 24 | 24 | from gajim.common.const import AvatarSize
|
| 25 | 25 | |
| 26 | +from .base import BaseRow
|
|
| 26 | 27 | from .widgets import DateTimeLabel
|
| 27 | 28 | from .widgets import SimpleLabel
|
| 28 | -from .base import BaseRow
|
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | class InfoMessage(BaseRow):
|
| ... | ... | @@ -17,17 +17,15 @@ |
| 17 | 17 | from typing import Optional
|
| 18 | 18 | from typing import Union
|
| 19 | 19 | |
| 20 | +import textwrap
|
|
| 20 | 21 | from datetime import datetime
|
| 21 | 22 | from datetime import timedelta
|
| 22 | -import textwrap
|
|
| 23 | 23 | |
| 24 | +import cairo
|
|
| 24 | 25 | from gi.repository import GdkPixbuf
|
| 25 | 26 | from gi.repository import GLib
|
| 26 | 27 | from gi.repository import Gtk
|
| 27 | 28 | from gi.repository import Pango
|
| 28 | - |
|
| 29 | -import cairo
|
|
| 30 | - |
|
| 31 | 29 | from nbxmpp.errors import StanzaError
|
| 32 | 30 | from nbxmpp.modules.security_labels import Displaymarking
|
| 33 | 31 | from nbxmpp.structs import CommonError
|
| ... | ... | @@ -46,16 +44,15 @@ |
| 46 | 44 | from gajim.common.modules.contacts import GroupchatParticipant
|
| 47 | 45 | from gajim.common.types import ChatContactT
|
| 48 | 46 | |
| 47 | +from ...preview import PreviewWidget
|
|
| 48 | +from ...util import format_fingerprint
|
|
| 49 | +from ..message_widget import MessageWidget
|
|
| 49 | 50 | from .base import BaseRow
|
| 50 | 51 | from .widgets import AvatarBox
|
| 51 | 52 | from .widgets import DateTimeLabel
|
| 52 | -from .widgets import NicknameLabel
|
|
| 53 | 53 | from .widgets import MessageIcons
|
| 54 | 54 | from .widgets import MoreMenuButton
|
| 55 | -from ..message_widget import MessageWidget
|
|
| 56 | -from ...preview import PreviewWidget
|
|
| 57 | -from ...util import format_fingerprint
|
|
| 58 | - |
|
| 55 | +from .widgets import NicknameLabel
|
|
| 59 | 56 | |
| 60 | 57 | MERGE_TIMEFRAME = timedelta(seconds=120)
|
| 61 | 58 |
| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | |
| 20 | 20 | from gi.repository import Gtk
|
| 21 | 21 | |
| 22 | -from gajim.common.i18n import _
|
|
| 23 | 22 | from gajim.common.const import AvatarSize
|
| 23 | +from gajim.common.i18n import _
|
|
| 24 | 24 | |
| 25 | -from .widgets import SimpleLabel
|
|
| 26 | -from .widgets import DateTimeLabel
|
|
| 27 | 25 | from .base import BaseRow
|
| 26 | +from .widgets import DateTimeLabel
|
|
| 27 | +from .widgets import SimpleLabel
|
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | class MUCJoinLeft(BaseRow):
|
| ... | ... | @@ -25,9 +25,9 @@ |
| 25 | 25 | from gajim.common.const import AvatarSize
|
| 26 | 26 | from gajim.common.i18n import _
|
| 27 | 27 | |
| 28 | +from ..message_widget import MessageWidget
|
|
| 28 | 29 | from .base import BaseRow
|
| 29 | 30 | from .widgets import DateTimeLabel
|
| 30 | -from ..message_widget import MessageWidget
|
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | class MUCSubject(BaseRow):
|
| ... | ... | @@ -21,15 +21,15 @@ |
| 21 | 21 | |
| 22 | 22 | from gi.repository import Gtk
|
| 23 | 23 | |
| 24 | -from gajim.common.i18n import _
|
|
| 25 | 24 | from gajim.common.const import AvatarSize
|
| 26 | 25 | from gajim.common.helpers import get_uf_show
|
| 26 | +from gajim.common.i18n import _
|
|
| 27 | 27 | |
| 28 | -from .widgets import SimpleLabel
|
|
| 29 | -from .widgets import DateTimeLabel
|
|
| 30 | -from .base import BaseRow
|
|
| 31 | -from ..message_widget import MessageWidget
|
|
| 32 | 28 | from ...avatar import get_show_circle
|
| 29 | +from ..message_widget import MessageWidget
|
|
| 30 | +from .base import BaseRow
|
|
| 31 | +from .widgets import DateTimeLabel
|
|
| 32 | +from .widgets import SimpleLabel
|
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | class UserStatus(BaseRow):
|
| ... | ... | @@ -14,16 +14,16 @@ |
| 14 | 14 | |
| 15 | 15 | from __future__ import annotations
|
| 16 | 16 | |
| 17 | -from typing import TYPE_CHECKING
|
|
| 18 | 17 | from typing import Optional
|
| 18 | +from typing import TYPE_CHECKING
|
|
| 19 | 19 | |
| 20 | 20 | from datetime import datetime
|
| 21 | 21 | |
| 22 | -from gi.repository import Gtk
|
|
| 22 | +import cairo
|
|
| 23 | 23 | from gi.repository import Gdk
|
| 24 | -from gi.repository import Pango
|
|
| 25 | 24 | from gi.repository import GLib
|
| 26 | -import cairo
|
|
| 25 | +from gi.repository import Gtk
|
|
| 26 | +from gi.repository import Pango
|
|
| 27 | 27 | |
| 28 | 28 | from gajim.common import app
|
| 29 | 29 | from gajim.common.const import AvatarSize
|
| ... | ... | @@ -36,9 +36,9 @@ |
| 36 | 36 | |
| 37 | 37 | from ...menus import get_chat_row_menu
|
| 38 | 38 | from ...menus import get_groupchat_participant_menu
|
| 39 | -from ...util import wrap_with_event_box
|
|
| 40 | -from ...util import get_cursor
|
|
| 41 | 39 | from ...util import GajimPopover
|
| 40 | +from ...util import get_cursor
|
|
| 41 | +from ...util import wrap_with_event_box
|
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | class SimpleLabel(Gtk.Label):
|
| ... | ... | @@ -15,53 +15,51 @@ |
| 15 | 15 | from __future__ import annotations
|
| 16 | 16 | |
| 17 | 17 | from typing import Any
|
| 18 | +from typing import cast
|
|
| 19 | +from typing import Generator
|
|
| 18 | 20 | from typing import Literal
|
| 19 | 21 | from typing import Optional
|
| 20 | 22 | from typing import Union
|
| 21 | -from typing import Generator
|
|
| 22 | -from typing import cast
|
|
| 23 | 23 | |
| 24 | 24 | import logging
|
| 25 | 25 | import time
|
| 26 | - |
|
| 27 | 26 | from datetime import datetime
|
| 28 | 27 | from datetime import timedelta
|
| 29 | 28 | |
| 30 | 29 | from gi.repository import Gdk
|
| 31 | -from gi.repository import Gtk
|
|
| 32 | -from gi.repository import GObject
|
|
| 33 | 30 | from gi.repository import Gio
|
| 34 | - |
|
| 31 | +from gi.repository import GObject
|
|
| 32 | +from gi.repository import Gtk
|
|
| 35 | 33 | from nbxmpp.errors import StanzaError
|
| 36 | 34 | from nbxmpp.modules.security_labels import Displaymarking
|
| 35 | +from nbxmpp.protocol import JID
|
|
| 37 | 36 | from nbxmpp.structs import CommonError
|
| 38 | 37 | from nbxmpp.structs import MucSubject
|
| 39 | -from nbxmpp.protocol import JID
|
|
| 40 | 38 | |
| 41 | 39 | from gajim.common import app
|
| 42 | -from gajim.common import types
|
|
| 43 | 40 | from gajim.common import events
|
| 41 | +from gajim.common import types
|
|
| 44 | 42 | from gajim.common.helpers import AdditionalDataDict
|
| 45 | -from gajim.common.helpers import to_user_string
|
|
| 46 | 43 | from gajim.common.helpers import get_start_of_day
|
| 44 | +from gajim.common.helpers import to_user_string
|
|
| 45 | +from gajim.common.modules.contacts import BareContact
|
|
| 47 | 46 | from gajim.common.modules.contacts import GroupchatContact
|
| 48 | 47 | from gajim.common.modules.httpupload import HTTPFileTransfer
|
| 49 | 48 | from gajim.common.storage.archive import ConversationRow
|
| 50 | -from gajim.common.modules.contacts import BareContact
|
|
| 51 | 49 | from gajim.common.types import ChatContactT
|
| 52 | 50 | |
| 53 | 51 | from .rows.base import BaseRow
|
| 54 | -from .rows.read_marker import ReadMarkerRow
|
|
| 55 | -from .rows.scroll_hint import ScrollHintRow
|
|
| 56 | -from .rows.message import MessageRow
|
|
| 57 | -from .rows.info import InfoMessage
|
|
| 58 | 52 | from .rows.call import CallRow
|
| 59 | 53 | from .rows.command_output import CommandOutputRow
|
| 60 | 54 | from .rows.date import DateRow
|
| 61 | 55 | from .rows.file_transfer import FileTransferRow
|
| 62 | 56 | from .rows.file_transfer_jingle import FileTransferJingleRow
|
| 63 | -from .rows.muc_subject import MUCSubject
|
|
| 57 | +from .rows.info import InfoMessage
|
|
| 58 | +from .rows.message import MessageRow
|
|
| 64 | 59 | from .rows.muc_join_left import MUCJoinLeft
|
| 60 | +from .rows.muc_subject import MUCSubject
|
|
| 61 | +from .rows.read_marker import ReadMarkerRow
|
|
| 62 | +from .rows.scroll_hint import ScrollHintRow
|
|
| 65 | 63 | from .rows.user_status import UserStatus
|
| 66 | 64 | |
| 67 | 65 | log = logging.getLogger('gajim.gui.conversation_view')
|
| ... | ... | @@ -701,8 +699,7 @@ def get_row_by_stanza_id(self, stanza_id: str) -> Optional[MessageRow]: |
| 701 | 699 | return None
|
| 702 | 700 | |
| 703 | 701 | def iter_rows(self) -> Generator[BaseRow, None, None]:
|
| 704 | - for row in cast(list[BaseRow], self._list_box.get_children()):
|
|
| 705 | - yield row
|
|
| 702 | + yield from cast(list[BaseRow], self._list_box.get_children())
|
|
| 706 | 703 | |
| 707 | 704 | def remove_rows_by_type(self, row_type: str) -> None:
|
| 708 | 705 | for row in self.iter_rows():
|
| ... | ... | @@ -179,10 +179,7 @@ def _on_selection_changed(self, tree_selection: Gtk.TreeSelection) -> None: |
| 179 | 179 | self._set_remove_button_state(sensitive, selected_affiliations)
|
| 180 | 180 | |
| 181 | 181 | def _jid_exists(self, jid: str) -> bool:
|
| 182 | - for row in self._store:
|
|
| 183 | - if row[Column.JID] == jid:
|
|
| 184 | - return True
|
|
| 185 | - return False
|
|
| 182 | + return any(row[Column.JID] == jid for row in self._store)
|
|
| 186 | 183 | |
| 187 | 184 | @staticmethod
|
| 188 | 185 | def _get_selected_affiliations(tree_selection: Gtk.TreeSelection
|
| ... | ... | @@ -144,10 +144,7 @@ def _on_selection_changed(self, tree_selection: Gtk.TreeSelection) -> None: |
| 144 | 144 | self._set_remove_button_state(sensitive)
|
| 145 | 145 | |
| 146 | 146 | def _jid_exists(self, jid: str) -> bool:
|
| 147 | - for row in self._store:
|
|
| 148 | - if row[Column.JID] == jid:
|
|
| 149 | - return True
|
|
| 150 | - return False
|
|
| 147 | + return any(row[Column.JID] == jid for row in self._store)
|
|
| 151 | 148 | |
| 152 | 149 | def _set_remove_button_state(self, sensitive: bool) -> None:
|
| 153 | 150 | value = self._own_affiliation in ('admin', 'owner')
|
| ... | ... | @@ -916,10 +916,7 @@ def update_proxy_list(self) -> None: |
| 916 | 916 | popover_row.update_entries(self._get_proxies())
|
| 917 | 917 | |
| 918 | 918 | def _check_hints_reset(self) -> bool:
|
| 919 | - for hint in self._hints_list:
|
|
| 920 | - if app.settings.get(hint) is False:
|
|
| 921 | - return True
|
|
| 922 | - return False
|
|
| 919 | + return any(app.settings.get(hint) is False for hint in self._hints_list)
|
|
| 923 | 920 | |
| 924 | 921 | def _on_reset_hints(self, button: Gtk.Button) -> None:
|
| 925 | 922 | for hint in self._hints_list:
|
| 1 | 1 | |
| 2 | 2 | from __future__ import annotations
|
| 3 | 3 | |
| 4 | -from typing import Union
|
|
| 5 | -from typing import Sequence
|
|
| 6 | 4 | from typing import Optional
|
| 5 | +from typing import Sequence
|
|
| 6 | +from typing import Union
|
|
| 7 | 7 | |
| 8 | -import types
|
|
| 9 | 8 | import sys
|
| 9 | +import types
|
|
| 10 | 10 | from importlib.abc import MetaPathFinder
|
| 11 | -from importlib.util import spec_from_file_location
|
|
| 12 | 11 | from importlib.machinery import ModuleSpec
|
| 12 | +from importlib.util import spec_from_file_location
|
|
| 13 | 13 | from pathlib import Path
|
| 14 | 14 | |
| 15 | 15 |
| ... | ... | @@ -146,8 +146,7 @@ def __contains__(self, key: str) -> bool: |
| 146 | 146 | return key in self.data
|
| 147 | 147 | |
| 148 | 148 | def __iter__(self):
|
| 149 | - for key in self.data:
|
|
| 150 | - yield key
|
|
| 149 | + yield from self.data
|
|
| 151 | 150 | |
| 152 | 151 | def keys(self):
|
| 153 | 152 | return self.data.keys()
|
| ... | ... | @@ -98,10 +98,7 @@ def from_path(cls, path: Path) -> PluginManifest: |
| 98 | 98 | return cls.from_manifest_json(manifest, manifest_path)
|
| 99 | 99 | |
| 100 | 100 | def _check_requirements(self) -> bool:
|
| 101 | - for req in self.requirements:
|
|
| 102 | - if GAJIM_VERSION in req.specifier:
|
|
| 103 | - return True
|
|
| 104 | - return False
|
|
| 101 | + return any(GAJIM_VERSION in req.specifier for req in self.requirements)
|
|
| 105 | 102 | |
| 106 | 103 | @classmethod
|
| 107 | 104 | def from_manifest_json(cls,
|
| ... | ... | @@ -133,6 +133,8 @@ ignore = [ |
| 133 | 133 | "RUF003", # AmbiguousUnicodeCharacterComment
|
| 134 | 134 | "RUF100", # Unused `noqa` directive
|
| 135 | 135 | "S101", # Use of `assert` detected
|
| 136 | + "SIM102", # Use a single `if` statement instead of nested `if` statements
|
|
| 137 | + "SIM105", # Use `contextlib.suppress(Exception)` instead of try-except-pass
|
|
| 136 | 138 | "UP007", # Use X | Y for type annotations
|
| 137 | 139 | ]
|
| 138 | 140 |