diff options
author | wurstsalat <mailtrash@posteo.de> | 2023-06-11 13:39:01 +0300 |
---|---|---|
committer | wurstsalat <mailtrash@posteo.de> | 2023-06-11 13:39:01 +0300 |
commit | 77c9c8818f9ed19bb71172048e1d81f634a5a5e6 (patch) | |
tree | 0afa411791cea26b77c219dd7691434a29a7d099 | |
parent | 298406cc223302b11f46f36700833526f5f33d4c (diff) |
cq: Use union operator
-rw-r--r-- | clients_icons/clients.py | 5 | ||||
-rw-r--r-- | clients_icons/clients_icons.py | 10 | ||||
-rw-r--r-- | openpgp/backend/gpgme.py | 4 | ||||
-rw-r--r-- | openpgp/backend/pygpg.py | 4 | ||||
-rw-r--r-- | triggers/util.py | 9 |
5 files changed, 12 insertions, 20 deletions
diff --git a/clients_icons/clients.py b/clients_icons/clients.py index 745fafe..baa9d53 100644 --- a/clients_icons/clients.py +++ b/clients_icons/clients.py @@ -16,7 +16,6 @@ from __future__ import annotations from typing import Any -from typing import Optional from collections import UserDict from dataclasses import dataclass @@ -26,8 +25,8 @@ from gajim.plugins.plugins_i18n import _ @dataclass class ClientData: - default: Optional[tuple[str, str]] = None - variations: Optional[dict[str, str]] = None + default: tuple[str, str] | None = None + variations: dict[str, str] | None = None def get_variations(client_name: str) -> list[str]: diff --git a/clients_icons/clients_icons.py b/clients_icons/clients_icons.py index da30e8a..594c336 100644 --- a/clients_icons/clients_icons.py +++ b/clients_icons/clients_icons.py @@ -16,8 +16,6 @@ from __future__ import annotations from typing import cast -from typing import Optional -from typing import Union import logging from pathlib import Path @@ -64,17 +62,17 @@ class ClientsIconsPlugin(GajimPlugin): _icon_theme.append_search_path(str(Path(__file__).parent)) @staticmethod - def _get_client_identity_name(disco_info: DiscoInfo) -> Optional[str]: + def _get_client_identity_name(disco_info: DiscoInfo) -> str | None: for identity in disco_info.identities: if identity.category == 'client': return identity.name return None def _get_image_and_client_name(self, - contact: Union[ - GroupchatParticipant, ResourceContact], + contact: + GroupchatParticipant | ResourceContact, _widget: Gtk.Widget - ) -> Optional[tuple[Gtk.Image, str]]: + ) -> tuple[Gtk.Image, str] | None: disco_info = app.storage.cache.get_last_disco_info(contact.jid) if disco_info is None: diff --git a/openpgp/backend/gpgme.py b/openpgp/backend/gpgme.py index 54b8619..d485742 100644 --- a/openpgp/backend/gpgme.py +++ b/openpgp/backend/gpgme.py @@ -14,8 +14,6 @@ # You should have received a copy of the GNU General Public License # along with OpenPGP Gajim Plugin. If not, see <http://www.gnu.org/licenses/>. -from typing import Optional - import logging from nbxmpp.protocol import JID @@ -46,7 +44,7 @@ class KeyringItem: return False return jid == self.jid - def _get_uid(self) -> Optional[str]: + def _get_uid(self) -> str | None: for uid in self._key.uids: try: return parse_uid(uid.uid) diff --git a/openpgp/backend/pygpg.py b/openpgp/backend/pygpg.py index 009114f..aaf1fa9 100644 --- a/openpgp/backend/pygpg.py +++ b/openpgp/backend/pygpg.py @@ -14,8 +14,6 @@ # You should have received a copy of the GNU General Public License # along with OpenPGP Gajim Plugin. If not, see <http://www.gnu.org/licenses/>. -from typing import Optional - import logging import gnupg @@ -53,7 +51,7 @@ class KeyringItem: def keyid(self) -> str: return self._key['keyid'] - def _get_uid(self) -> Optional[str]: + def _get_uid(self) -> str | None: for uid in self._key['uids']: try: return parse_uid(uid) diff --git a/triggers/util.py b/triggers/util.py index d9f705b..ab712a0 100644 --- a/triggers/util.py +++ b/triggers/util.py @@ -16,7 +16,6 @@ from __future__ import annotations from typing import Any from typing import Callable -from typing import Optional from typing import TYPE_CHECKING import logging @@ -39,7 +38,7 @@ def log_result(func: Callable[..., Any]) -> Callable[..., bool]: @dataclass class RuleResult: - show_notification: Optional[bool] = None - command: Optional[str] = None - sound: Optional[bool] = None - sound_file: Optional[str] = None + show_notification: bool | None = None + command: str | None = None + sound: bool | None = None + sound_file: str | None = None |