Philipp Hörist pushed to branch master at gajim / gajim


Commits:
f22cf3b7 by André Apitzsch at 2024-04-02T09:26:21+00:00
cq: Fix style issues revealed by ruff 0.3.2

- - - - -
92bd2fb9 by André Apitzsch at 2024-04-02T09:26:21+00:00
refactor: Use 'join' to create groups string

- - - - -


4 changed files:

- gajim/common/client.py
- gajim/common/settings.py
- gajim/gtk/roster_item_exchange.py
- gajim/gtk/vcard_grid.py


Changes:

=====================================
gajim/common/client.py
=====================================
@@ -359,8 +359,7 @@ def change_status(self, show: str, message: str) -> None:
                 helpers.to_one_line(message))
 
         if self._state.is_disconnecting:
-            log.warning("Can\'t change status while "
-                        'disconnect is in progress')
+            log.warning("Can't change status while disconnect is in progress")
             return
 
         if self._state.is_disconnected:


=====================================
gajim/common/settings.py
=====================================
@@ -91,7 +91,7 @@
     INSERT INTO settings(name, settings) VALUES ('workspaces', '{workspaces}');
 
     PRAGMA user_version={version};
-    '''.format(status=json.dumps(STATUS_PRESET_EXAMPLES),
+    '''.format(status=json.dumps(STATUS_PRESET_EXAMPLES),  # noqa: UP032
                proxies=json.dumps(PROXY_EXAMPLES),
                workspaces=json.dumps(INITAL_WORKSPACE),
                version=CURRENT_USER_VERSION)


=====================================
gajim/gtk/roster_item_exchange.py
=====================================
@@ -123,15 +123,7 @@ def _add(self) -> None:
             contact = self._client.get_module('Contacts').get_contact(jid)
             assert isinstance(contact, BareContact)
             name = self._exchange_list[jid][0]
-            groups = ''
-            num_list = len(self._exchange_list[jid][1])
-            current = 0
-            for group in self._exchange_list[jid][1]:
-                current += 1
-                if current == num_list:
-                    groups = groups + group
-                else:
-                    groups = groups + group + ', '
+            groups = ', '.join(self._exchange_list[jid][1])
             if not contact.is_in_roster:
                 self.show_all()
                 assert isinstance(self._model, Gtk.ListStore)
@@ -150,20 +142,13 @@ def _modify(self) -> None:
             contact = self._client.get_module('Contacts').get_contact(jid)
             assert isinstance(contact, BareContact)
             name = self._exchange_list[jid][0]
-            groups = ''
+            groups = ', '.join(self._exchange_list[jid][1])
 
             if name != contact.name:
                 is_right = False
-            num_list = len(self._exchange_list[jid][1])
-            current = 0
             for group in self._exchange_list[jid][1]:
-                current += 1
                 if group not in contact.groups:
                     is_right = False
-                if current == num_list:
-                    groups = groups + group
-                else:
-                    groups = groups + group + ', '
             if not is_right and contact.is_in_roster:
                 self.show_all()
                 assert isinstance(self._model, Gtk.ListStore)
@@ -181,15 +166,7 @@ def _delete(self) -> None:
             contact = self._client.get_module('Contacts').get_contact(jid)
             assert isinstance(contact, BareContact)
             name = self._exchange_list[jid][0]
-            groups = ''
-            num_list = len(self._exchange_list[jid][1])
-            current = 0
-            for group in self._exchange_list[jid][1]:
-                current += 1
-                if current == num_list:
-                    groups = groups + group
-                else:
-                    groups = groups + group + ', '
+            groups = ', '.join(self._exchange_list[jid][1])
             if contact.is_in_roster:
                 self.show_all()
                 assert isinstance(self._model, Gtk.ListStore)


=====================================
gajim/gtk/vcard_grid.py
=====================================
@@ -277,7 +277,7 @@ def set_value_with_uri(self, value: str, uri: str) -> None:
             self.set_text(value)
             return
         self._uri = puri
-        super().set_markup('<a href="{}">{}</a>'.format(
+        super().set_markup('<a href="{}">{}</a>'.format(  # noqa: UP032
             GLib.markup_escape_text(uri),
             GLib.markup_escape_text(value)))
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/633eaf9395de18ca63afb2d5d4a20aac54b3f7d9...92bd2fb91c59e527bad23cf6944d9106feed02f0

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/633eaf9395de18ca63afb2d5d4a20aac54b3f7d9...92bd2fb91c59e527bad23cf6944d9106feed02f0
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to