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


Commits:
acd15d2d by lovetox at 2021-12-04T20:38:37+01:00
ConfigPaths: Improve type annotations

- - - - -
45b15ad1 by lovetox at 2021-12-04T20:39:02+01:00
Update mypy.ini

- - - - -


2 changed files:

- gajim/common/configpaths.py
- mypy.ini


Changes:

=====================================
gajim/common/configpaths.py
=====================================
@@ -19,11 +19,9 @@
 # You should have received a copy of the GNU General Public License
 # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 
-from typing import Dict  # pylint: disable=unused-import
-from typing import List
 from typing import Generator
-from typing import Optional  # pylint: disable=unused-import
-from typing import Tuple
+from typing import Optional
+from typing import Union
 from typing import cast
 
 import os
@@ -36,7 +34,8 @@
 
 import gajim
 from gajim.common.i18n import _
-from gajim.common.const import PathType, PathLocation
+from gajim.common.const import PathType
+from gajim.common.const import PathLocation
 from gajim.common.types import PathTuple
 
 
@@ -44,7 +43,7 @@ def get(key: str) -> Path:
     return _paths[key]
 
 
-def get_plugin_dirs() -> List[Path]:
+def get_plugin_dirs() -> list[Path]:
     if gajim.IS_FLATPAK:
         return [Path(_paths['PLUGINS_BASE']),
                 Path('/app/plugins')]
@@ -102,10 +101,10 @@ def create_paths() -> None:
 
 class ConfigPaths:
     def __init__(self) -> None:
-        self._paths = {}  # type: Dict[str, PathTuple]
+        self._paths: dict[str, PathTuple] = {}
         self.profile = ''
         self.profile_separation = False
-        self.custom_config_root = None  # type: Optional[Path]
+        self.custom_config_root: Optional[Path] = None
 
         if os.name == 'nt':
             if gajim.IS_PORTABLE:
@@ -146,7 +145,7 @@ def __getitem__(self, key: str) -> Path:
             return self.data_root / path
         return path
 
-    def items(self) -> Generator[Tuple[str, PathTuple], None, None]:
+    def items(self) -> Generator[tuple[str, PathTuple], None, None]:
         for key, value in self._paths.items():
             yield (key, value)
 
@@ -160,10 +159,13 @@ def _prepare(self, path: Path, unique: bool) -> Path:
 
     def add(self,
             name: str,
-            path: Path,
-            location: PathLocation = None,
-            path_type: PathType = None,
+            path: Union[Path, str],
+            location: Optional[PathLocation] = None,
+            path_type: Optional[PathType] = None,
             unique: bool = False) -> None:
+
+        path = Path(path)
+
         if location is not None:
             path = self._prepare(path, unique)
         self._paths[name] = (location, path, path_type)


=====================================
mypy.ini
=====================================
@@ -4,12 +4,6 @@ warn_unused_configs = True
 disallow_incomplete_defs = True
 allow_redefinition = True
 
-[mypy-nbxmpp.*]
-ignore_missing_imports = True
-
-[mypy-gi.*]
-ignore_missing_imports = True
-
 [mypy-dbus.*]
 ignore_missing_imports = True
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/c739635879455c497c0ab64c9d923feb3fadd922...45b15ad1f9ac735ae9e6ecb5c32ae7ce6767e80b

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/c739635879455c497c0ab64c9d923feb3fadd922...45b15ad1f9ac735ae9e6ecb5c32ae7ce6767e80b
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to