From ff9cedf90a455649c0ba4f5c0271c58e9e23d2bf Mon Sep 17 00:00:00 2001 From: wurstsalat Date: Tue, 29 Nov 2022 19:34:20 +0100 Subject: [plugins_translations] Type annotations, linting --- plugins_translations/__init__.py | 2 +- plugins_translations/plugins_translations.py | 30 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'plugins_translations') diff --git a/plugins_translations/__init__.py b/plugins_translations/__init__.py index ac2604e..214ea73 100644 --- a/plugins_translations/__init__.py +++ b/plugins_translations/__init__.py @@ -1 +1 @@ -from .plugins_translations import PluginsTranslationsPlugin +from .plugins_translations import PluginsTranslationsPlugin # type: ignore diff --git a/plugins_translations/plugins_translations.py b/plugins_translations/plugins_translations.py index a8e0c14..684cb50 100644 --- a/plugins_translations/plugins_translations.py +++ b/plugins_translations/plugins_translations.py @@ -1,3 +1,21 @@ +# This file is part of Gajim. +# +# Gajim is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; version 3 only. +# +# Gajim is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Gajim. If not, see . + +from __future__ import annotations + +from typing import cast + import logging import os import shutil @@ -13,17 +31,17 @@ log = logging.getLogger('gajim.p.plugins_translations') class PluginsTranslationsPlugin(GajimPlugin): - def init(self): + def init(self) -> None: self.description = _('This plugin contains translations for other ' 'Gajim plugins. Please restart Gajim after ' 'enabling this plugin.') self.config_dialog = None - self.config_default_values = {'last_version': '0'} + self.config_default_values = {'last_version': ('0', '')} self.locale_dir = Path(configpaths.get('PLUGINS_USER')) / 'locale' - def activate(self): + def activate(self) -> None: current_version = str(self.manifest.version) - if self.config['last_version'] == current_version: + if cast(str, self.config['last_version']) == current_version: return files = glob(self.__path__ + '/*.mo') @@ -43,11 +61,11 @@ class PluginsTranslationsPlugin(GajimPlugin): self.config['last_version'] = current_version - def _remove_translations(self): + def _remove_translations(self) -> None: log.info('Removing old translations...') if self.locale_dir.exists(): shutil.rmtree(str(self.locale_dir)) - def deactivate(self): + def deactivate(self) -> None: self._remove_translations() self.config['last_version'] = '0' -- cgit v1.2.3