Reformat with ruff format
This commit is contained in:
@@ -106,7 +106,6 @@ def get_dir_list(ftp: FTP_TLS) -> set[str]:
|
||||
|
||||
|
||||
def upload_file(ftp: FTP_TLS, filepath: Path) -> None:
|
||||
|
||||
name = filepath.name
|
||||
console.print("Upload file", name)
|
||||
with open(filepath, "rb") as f:
|
||||
@@ -114,7 +113,6 @@ def upload_file(ftp: FTP_TLS, filepath: Path) -> None:
|
||||
|
||||
|
||||
def create_release_folder(ftp: FTP_TLS, packages_to_publish: list[PackageT]) -> None:
|
||||
|
||||
folders = {manifest["short_name"] for manifest, _ in packages_to_publish}
|
||||
dir_list = get_dir_list(ftp)
|
||||
missing_folders = folders - dir_list
|
||||
|
||||
@@ -95,7 +95,6 @@ class AcronymsExpanderPlugin(GajimPlugin):
|
||||
self._save_acronyms(acronyms)
|
||||
|
||||
def _on_buffer_changed(self, message_input: MessageInputTextView) -> None:
|
||||
|
||||
if self._contact is None:
|
||||
# If no chat has been activated yet
|
||||
return
|
||||
@@ -160,7 +159,6 @@ class AcronymsExpanderPlugin(GajimPlugin):
|
||||
end: Gtk.TextIter,
|
||||
substitute: str,
|
||||
) -> None:
|
||||
|
||||
self._replace_in_progress = True
|
||||
buffer_.delete(start, end)
|
||||
buffer_.insert(start, substitute)
|
||||
|
||||
@@ -44,7 +44,6 @@ class ConfigBuilder(Gtk.Builder):
|
||||
|
||||
class ConfigDialog(GajimAppWindow):
|
||||
def __init__(self, plugin: AcronymsExpanderPlugin, transient: Gtk.Window) -> None:
|
||||
|
||||
GajimAppWindow.__init__(
|
||||
self,
|
||||
name="AcronymsConfigDialog",
|
||||
@@ -84,14 +83,12 @@ class ConfigDialog(GajimAppWindow):
|
||||
def _on_acronym_edited(
|
||||
self, _renderer: Gtk.CellRendererText, path: str, new_text: str
|
||||
) -> None:
|
||||
|
||||
iter_ = self._ui.acronyms_store.get_iter(path)
|
||||
self._ui.acronyms_store.set_value(iter_, 0, new_text)
|
||||
|
||||
def _on_substitute_edited(
|
||||
self, _renderer: Gtk.CellRendererText, path: str, new_text: str
|
||||
) -> None:
|
||||
|
||||
iter_ = self._ui.acronyms_store.get_iter(path)
|
||||
self._ui.acronyms_store.set_value(iter_, 1, new_text)
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ class AntiSpam(BaseModule):
|
||||
def _message_received(
|
||||
self, _con: Client, _stanza: Message, properties: MessageProperties
|
||||
) -> None:
|
||||
|
||||
if properties.is_sent_carbon:
|
||||
# Another device already sent a message
|
||||
assert properties.jid
|
||||
@@ -155,7 +154,6 @@ class AntiSpam(BaseModule):
|
||||
def _subscribe_received(
|
||||
self, _con: Client, _stanza: Presence, properties: PresenceProperties
|
||||
) -> None:
|
||||
|
||||
msg_from = properties.jid
|
||||
assert msg_from is not None
|
||||
block_sub = self._config["block_subscription_requests"]
|
||||
|
||||
@@ -66,7 +66,6 @@ class ClientsIconsPlugin(GajimPlugin):
|
||||
def _get_image_and_client_name(
|
||||
self, contact: GroupchatParticipant | ResourceContact, _widget: Gtk.Widget
|
||||
) -> tuple[Gtk.Image, str] | None:
|
||||
|
||||
disco_info = app.storage.cache.get_last_disco_info(contact.jid)
|
||||
if disco_info is None:
|
||||
return None
|
||||
@@ -86,7 +85,6 @@ class ClientsIconsPlugin(GajimPlugin):
|
||||
def _contact_tooltip_resource_populate(
|
||||
self, resource_box: Gtk.Box, resource: ResourceContact
|
||||
) -> None:
|
||||
|
||||
result = self._get_image_and_client_name(resource, resource_box)
|
||||
if result is None:
|
||||
return
|
||||
|
||||
@@ -32,7 +32,6 @@ if TYPE_CHECKING:
|
||||
|
||||
class ClientsIconsConfigDialog(SettingsDialog):
|
||||
def __init__(self, plugin: ClientsIconsPlugin, parent: Gtk.Window) -> None:
|
||||
|
||||
self.plugin = plugin
|
||||
settings = [
|
||||
Setting(
|
||||
|
||||
@@ -32,7 +32,6 @@ if TYPE_CHECKING:
|
||||
|
||||
class LengthNotifierConfigDialog(SettingsDialog):
|
||||
def __init__(self, plugin: LengthNotifierPlugin, parent: Gtk.Window) -> None:
|
||||
|
||||
self.plugin = plugin
|
||||
jids = self.plugin.config["JIDS"] or ""
|
||||
if isinstance(jids, list):
|
||||
|
||||
@@ -20,6 +20,7 @@ Message length notifier plugin.
|
||||
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
|
||||
:license: GPL
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
@@ -71,8 +72,7 @@ class LengthNotifierPlugin(GajimPlugin):
|
||||
),
|
||||
"JIDS": (
|
||||
"",
|
||||
"Enable the plugin for selected XMPP addresses "
|
||||
"only (comma separated)",
|
||||
"Enable the plugin for selected XMPP addresses only (comma separated)",
|
||||
),
|
||||
}
|
||||
|
||||
@@ -101,7 +101,6 @@ class LengthNotifierPlugin(GajimPlugin):
|
||||
def _message_actions_box_created(
|
||||
self, message_actions_box: MessageActionsBox, gtk_box: Gtk.Box
|
||||
) -> None:
|
||||
|
||||
self._message_action_box = message_actions_box
|
||||
self._actions_box_widget = gtk_box
|
||||
self._create_counter()
|
||||
@@ -121,7 +120,6 @@ class Counter(Gtk.Label):
|
||||
def __init__(
|
||||
self, message_input: MessageInputTextView, config: GajimPluginConfig
|
||||
) -> None:
|
||||
|
||||
Gtk.Label.__init__(self)
|
||||
self.set_tooltip_text(_("Number of typed characters"))
|
||||
self.add_css_class("dim-label")
|
||||
@@ -168,7 +166,6 @@ class Counter(Gtk.Label):
|
||||
self._inverted_color = f"rgb({red}, {green}, {blue})"
|
||||
|
||||
def _set_css(self) -> None:
|
||||
|
||||
css = """
|
||||
.length-warning {
|
||||
color: %s;
|
||||
|
||||
@@ -33,7 +33,6 @@ if TYPE_CHECKING:
|
||||
|
||||
class MessageBoxSizeConfigDialog(SettingsDialog):
|
||||
def __init__(self, plugin: MsgBoxSizePlugin, parent: Gtk.Window) -> None:
|
||||
|
||||
self.plugin = plugin
|
||||
settings = [
|
||||
Setting(
|
||||
|
||||
@@ -32,7 +32,6 @@ if TYPE_CHECKING:
|
||||
|
||||
class NowListenConfigDialog(SettingsDialog):
|
||||
def __init__(self, plugin: NowListenPlugin, parent: Gtk.Window) -> None:
|
||||
|
||||
self.plugin = plugin
|
||||
settings = [
|
||||
Setting(
|
||||
|
||||
@@ -80,7 +80,6 @@ class NowListenPlugin(GajimPlugin):
|
||||
_keycode: int,
|
||||
state: Gdk.ModifierType,
|
||||
) -> bool:
|
||||
|
||||
if keyval != Gdk.KEY_n:
|
||||
return Gdk.EVENT_PROPAGATE
|
||||
|
||||
|
||||
@@ -82,9 +82,7 @@ class Storage:
|
||||
%s
|
||||
PRAGMA user_version=1;
|
||||
END TRANSACTION;
|
||||
""" % (
|
||||
query
|
||||
)
|
||||
""" % (query)
|
||||
self._con.executescript(transaction)
|
||||
|
||||
def _migrate_database(self) -> None:
|
||||
|
||||
@@ -46,7 +46,6 @@ TRUST_DATA = {
|
||||
|
||||
class KeyDialog(GajimAppWindow):
|
||||
def __init__(self, account: str, jid: JID, transient: Gtk.Window) -> None:
|
||||
|
||||
GajimAppWindow.__init__(
|
||||
self,
|
||||
name="PGPKeyDialog",
|
||||
@@ -201,7 +200,6 @@ class TrustPopver(Gtk.Popover):
|
||||
|
||||
|
||||
class MenuOption(Gtk.ListBoxRow):
|
||||
|
||||
type_: Trust | None
|
||||
icon: str
|
||||
label: str
|
||||
@@ -223,7 +221,6 @@ class MenuOption(Gtk.ListBoxRow):
|
||||
|
||||
|
||||
class VerifiedOption(MenuOption):
|
||||
|
||||
type_ = Trust.VERIFIED
|
||||
icon = "security-high-symbolic"
|
||||
label = _("Verified")
|
||||
@@ -234,7 +231,6 @@ class VerifiedOption(MenuOption):
|
||||
|
||||
|
||||
class NotTrustedOption(MenuOption):
|
||||
|
||||
type_ = Trust.NOT_TRUSTED
|
||||
icon = "dialog-error-symbolic"
|
||||
label = _("Not Trusted")
|
||||
@@ -245,7 +241,6 @@ class NotTrustedOption(MenuOption):
|
||||
|
||||
|
||||
class DeleteOption(MenuOption):
|
||||
|
||||
type_ = None
|
||||
icon = "user-trash-symbolic"
|
||||
label = _("Delete")
|
||||
|
||||
@@ -103,7 +103,6 @@ class KeyWizard(Gtk.Assistant):
|
||||
|
||||
|
||||
class WelcomePage(Gtk.Box):
|
||||
|
||||
type_ = Gtk.AssistantPageType.INTRO
|
||||
title = _("Welcome")
|
||||
complete = True
|
||||
@@ -118,7 +117,6 @@ class WelcomePage(Gtk.Box):
|
||||
|
||||
|
||||
class RequestPage(Gtk.Box):
|
||||
|
||||
type_ = Gtk.AssistantPageType.INTRO
|
||||
title = _("Request OpenPGP Key")
|
||||
complete = False
|
||||
@@ -150,7 +148,6 @@ class RequestPage(Gtk.Box):
|
||||
|
||||
|
||||
class NewKeyPage(RequestPage):
|
||||
|
||||
type_ = Gtk.AssistantPageType.PROGRESS
|
||||
title = _("Generating new Key")
|
||||
complete = False
|
||||
@@ -203,7 +200,6 @@ class NewKeyPage(RequestPage):
|
||||
|
||||
|
||||
class SuccessfulPage(Gtk.Box):
|
||||
|
||||
type_ = Gtk.AssistantPageType.SUMMARY
|
||||
title = _("Setup successful")
|
||||
complete = True
|
||||
@@ -225,7 +221,6 @@ class SuccessfulPage(Gtk.Box):
|
||||
|
||||
|
||||
class ErrorPage(Gtk.Box):
|
||||
|
||||
type_ = Gtk.AssistantPageType.SUMMARY
|
||||
title = _("Setup failed")
|
||||
complete = True
|
||||
|
||||
@@ -73,7 +73,6 @@ name = ENCRYPTION_NAME
|
||||
|
||||
|
||||
class OpenPGP(BaseModule):
|
||||
|
||||
_nbxmpp_extends = "OpenPGP"
|
||||
_nbxmpp_methods = [
|
||||
"set_keylist",
|
||||
|
||||
@@ -75,10 +75,14 @@ class OpenPGPPlugin(GajimPlugin):
|
||||
self.gui_extension_points = {
|
||||
"encrypt" + self.encryption_name: (self._encrypt_message, None),
|
||||
"send_message" + self.encryption_name: (self._before_sendmessage, None),
|
||||
"encryption_dialog"
|
||||
+ self.encryption_name: (self._on_encryption_button_clicked, None),
|
||||
"encryption_state"
|
||||
+ self.encryption_name: (self._get_encryption_state, None),
|
||||
"encryption_dialog" + self.encryption_name: (
|
||||
self._on_encryption_button_clicked,
|
||||
None,
|
||||
),
|
||||
"encryption_state" + self.encryption_name: (
|
||||
self._get_encryption_state,
|
||||
None,
|
||||
),
|
||||
"update_caps": (self._update_caps, None),
|
||||
}
|
||||
|
||||
@@ -133,8 +137,7 @@ class OpenPGPPlugin(GajimPlugin):
|
||||
openpgp = self.get_openpgp_module(account)
|
||||
if openpgp.secret_key_available:
|
||||
log.info(
|
||||
"%s => Publish keylist and public key "
|
||||
"after plugin activation",
|
||||
"%s => Publish keylist and public key after plugin activation",
|
||||
account,
|
||||
)
|
||||
openpgp.request_keylist()
|
||||
|
||||
@@ -45,7 +45,6 @@ class ConfigBuilder(Gtk.Builder):
|
||||
|
||||
class PGPConfigDialog(GajimAppWindow):
|
||||
def __init__(self, plugin: PGPPlugin, transient: Gtk.Window) -> None:
|
||||
|
||||
GajimAppWindow.__init__(
|
||||
self,
|
||||
name="PGPConfigDialog",
|
||||
|
||||
@@ -50,7 +50,6 @@ class KeyDialog(GajimAppWindow):
|
||||
def __init__(
|
||||
self, plugin: PGPPlugin, account: str, jid: JID, transient: Gtk.Window
|
||||
) -> None:
|
||||
|
||||
GajimAppWindow.__init__(
|
||||
self,
|
||||
name="PGPKeyDialog",
|
||||
@@ -128,7 +127,6 @@ class ChooseGPGKeyDialog(GajimAppWindow):
|
||||
transient: Gtk.Window,
|
||||
callback: Callable[[tuple[str, str] | None], None],
|
||||
) -> None:
|
||||
|
||||
GajimAppWindow.__init__(
|
||||
self,
|
||||
name="PGPChooseKeyDialog",
|
||||
|
||||
@@ -213,7 +213,6 @@ class PGPLegacy(BaseModule):
|
||||
callback: Callable[[OutgoingMessage], None],
|
||||
always_trust: bool,
|
||||
) -> None:
|
||||
|
||||
text = message.get_text()
|
||||
assert text is not None
|
||||
|
||||
@@ -263,7 +262,6 @@ class PGPLegacy(BaseModule):
|
||||
def _raise_message_not_sent(
|
||||
client: Client, message: OutgoingMessage, error: str
|
||||
) -> None:
|
||||
|
||||
text = message.get_text()
|
||||
assert text is not None
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ if BINARY is None or error:
|
||||
|
||||
|
||||
class PGPPlugin(GajimPlugin):
|
||||
|
||||
def init(self):
|
||||
self.description = _("PGP encryption as per XEP-0027")
|
||||
if error_msg:
|
||||
@@ -140,7 +139,6 @@ class PGPPlugin(GajimPlugin):
|
||||
|
||||
@staticmethod
|
||||
def _on_not_trusted(event: PGPNotTrusted) -> None:
|
||||
|
||||
def _on_response(response_id: str, do_not_ask_again: bool) -> None:
|
||||
if response_id == "accept":
|
||||
event.on_yes(do_not_ask_again)
|
||||
|
||||
@@ -43,7 +43,6 @@ class ConfigBuilder(Gtk.Builder):
|
||||
|
||||
class ConfigDialog(GajimAppWindow):
|
||||
def __init__(self, plugin: QuickRepliesPlugin, transient: Gtk.Window) -> None:
|
||||
|
||||
GajimAppWindow.__init__(
|
||||
self,
|
||||
name="QuickRepliesConfigDialog",
|
||||
@@ -90,7 +89,6 @@ class ConfigDialog(GajimAppWindow):
|
||||
def _on_reply_edited(
|
||||
self, _renderer: Gtk.CellRendererText, path: str, new_text: str
|
||||
) -> None:
|
||||
|
||||
iter_ = self._ui.replies_store.get_iter(path)
|
||||
self._ui.replies_store.set_value(iter_, 0, new_text)
|
||||
|
||||
|
||||
@@ -82,7 +82,6 @@ class QuickRepliesPlugin(GajimPlugin):
|
||||
def _message_actions_box_created(
|
||||
self, message_actions_box: MessageActionsBox, gtk_box: Gtk.Box
|
||||
) -> None:
|
||||
|
||||
for action in self._actions:
|
||||
app.window.add_action(action)
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ def parse(path: Path) -> tuple[str, str]:
|
||||
continue
|
||||
klass = node.attrib["class"]
|
||||
if klass.startswith("GtkSource"):
|
||||
klass = f'GtkSource.{klass.removeprefix("GtkSource")}'
|
||||
klass = f"GtkSource.{klass.removeprefix('GtkSource')}"
|
||||
elif klass.startswith("Atk"):
|
||||
klass = f'Atk.{klass.removeprefix("Atk")}'
|
||||
klass = f"Atk.{klass.removeprefix('Atk')}"
|
||||
else:
|
||||
klass = f'Gtk.{klass.removeprefix("Gtk")}'
|
||||
klass = f"Gtk.{klass.removeprefix('Gtk')}"
|
||||
|
||||
lines.append(ATTR % (id_.replace("-", "_"), klass))
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ class ConfigBuilder(Gtk.Builder):
|
||||
|
||||
class ConfigDialog(GajimAppWindow):
|
||||
def __init__(self, plugin: Triggers, transient: Gtk.Window) -> None:
|
||||
|
||||
GajimAppWindow.__init__(
|
||||
self,
|
||||
name="TriggersConfigDialog",
|
||||
@@ -467,7 +466,6 @@ class ConfigDialog(GajimAppWindow):
|
||||
self._set_treeview_string()
|
||||
|
||||
def _on_recipient_type_combobox_changed(self, widget: Gtk.ComboBox) -> None:
|
||||
|
||||
if self._active_num < 0:
|
||||
return
|
||||
recipient_type = RECIPIENT_TYPES[widget.get_active()]
|
||||
@@ -578,7 +576,6 @@ class ConfigDialog(GajimAppWindow):
|
||||
def _on_use_it_toggled(
|
||||
self, widget: Gtk.CheckButton, opposite_widget: Gtk.CheckButton, option: str
|
||||
) -> None:
|
||||
|
||||
if widget.get_active():
|
||||
if opposite_widget.get_active():
|
||||
opposite_widget.set_active(False)
|
||||
@@ -591,7 +588,6 @@ class ConfigDialog(GajimAppWindow):
|
||||
def _on_disable_it_toggled(
|
||||
self, widget: Gtk.CheckButton, opposite_widget: Gtk.CheckButton, option: str
|
||||
) -> None:
|
||||
|
||||
if widget.get_active():
|
||||
if opposite_widget.get_active():
|
||||
opposite_widget.set_active(False)
|
||||
|
||||
@@ -103,7 +103,6 @@ class Triggers(GajimPlugin):
|
||||
check_func: Callable[..., bool],
|
||||
apply_func: Callable[..., Any],
|
||||
) -> RuleResult:
|
||||
|
||||
result = RuleResult()
|
||||
|
||||
rules_num = [int(item) for item in self.config]
|
||||
@@ -290,7 +289,6 @@ class Triggers(GajimPlugin):
|
||||
def _excecute_notification_rules(
|
||||
self, result: RuleResult, event: Notification
|
||||
) -> bool:
|
||||
|
||||
if result.sound is False:
|
||||
event.sound = None
|
||||
|
||||
|
||||
@@ -29,13 +29,11 @@ class _ReadableFile(Protocol):
|
||||
def read(self, size: int) -> bytes: ...
|
||||
|
||||
class StatusHandler:
|
||||
|
||||
on_data_failure: Exception | None = ...
|
||||
def __init__(self, gpg: GPG) -> None: ...
|
||||
def handle_status(self, key: str, value: str) -> None: ...
|
||||
|
||||
class Verify(StatusHandler):
|
||||
|
||||
TRUST_EXPIRED: int = ...
|
||||
TRUST_UNDEFINED: int = ...
|
||||
TRUST_NEVER: int = ...
|
||||
@@ -74,7 +72,6 @@ class ImportResultDict(TypedDict):
|
||||
text: str
|
||||
|
||||
class ImportResult(StatusHandler):
|
||||
|
||||
counts: list[str] = ...
|
||||
returncode: int | None = ...
|
||||
results: list[ImportResultDict]
|
||||
@@ -92,12 +89,10 @@ ESCAPE_PATTERN: re.Pattern[Any] = ...
|
||||
BASIC_ESCAPES: dict[str, str] = ...
|
||||
|
||||
class SendResult(StatusHandler):
|
||||
|
||||
returncode: int | None = ...
|
||||
def handle_status(self, key: str, value: str) -> None: ...
|
||||
|
||||
class SearchKeys(StatusHandler, list[dict[Any, Any]]):
|
||||
|
||||
UID_INDEX: int = ...
|
||||
FIELDS: list[str] = ...
|
||||
returncode: int | None = ...
|
||||
@@ -108,7 +103,6 @@ class SearchKeys(StatusHandler, list[dict[Any, Any]]):
|
||||
def handle_status(self, key: str, value: str) -> None: ...
|
||||
|
||||
class ListKeys(SearchKeys):
|
||||
|
||||
UID_INDEX: int = ...
|
||||
FIELDS: list[str] = ...
|
||||
def __init__(self, gpg: GPG) -> None: ...
|
||||
@@ -126,7 +120,6 @@ class ScanKeys(ListKeys):
|
||||
class TextHandler: ...
|
||||
|
||||
class Crypt(Verify, TextHandler):
|
||||
|
||||
data: bytes
|
||||
ok: bool
|
||||
status_detail: str
|
||||
@@ -137,7 +130,6 @@ class Crypt(Verify, TextHandler):
|
||||
def handle_status(self, key: str, value: str) -> None: ...
|
||||
|
||||
class GenKey(StatusHandler):
|
||||
|
||||
returncode: int | None = ...
|
||||
def __init__(self, gpg: GPG) -> None: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
@@ -145,7 +137,6 @@ class GenKey(StatusHandler):
|
||||
def handle_status(self, key: str, value: str) -> None: ...
|
||||
|
||||
class AddSubkey(StatusHandler):
|
||||
|
||||
returncode: int | None = ...
|
||||
def __init__(self, gpg: GPG) -> None: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
@@ -156,7 +147,6 @@ class ExportResult(GenKey):
|
||||
def handle_status(self, key: str, value: str) -> None: ...
|
||||
|
||||
class DeleteResult(StatusHandler):
|
||||
|
||||
returncode: int | None = ...
|
||||
def __init__(self, gpg: GPG) -> None: ...
|
||||
|
||||
@@ -168,7 +158,6 @@ class DeleteResult(StatusHandler):
|
||||
class TrustResult(DeleteResult): ...
|
||||
|
||||
class Sign(StatusHandler, TextHandler):
|
||||
|
||||
returncode: int | None = ...
|
||||
def __init__(self, gpg: GPG) -> None: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
@@ -188,7 +177,6 @@ HEX_DIGITS_RE: re.Pattern[Any] = ...
|
||||
PUBLIC_KEY_RE: re.Pattern[Any] = ...
|
||||
|
||||
class GPG:
|
||||
|
||||
error_map: None = ...
|
||||
decode_errors: str = ...
|
||||
buffer_size: int = ...
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
class GpgError(Exception):
|
||||
|
||||
error: Any | None
|
||||
context: str | None
|
||||
result: Any | None
|
||||
|
||||
Reference in New Issue
Block a user