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

Commits:

2 changed files:

Changes:

  • gajim/common/configpaths.py
    ... ... @@ -19,11 +19,9 @@
    19 19
     # You should have received a copy of the GNU General Public License
    
    20 20
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    21 21
     
    
    22
    -from typing import Dict  # pylint: disable=unused-import
    
    23
    -from typing import List
    
    24 22
     from typing import Generator
    
    25
    -from typing import Optional  # pylint: disable=unused-import
    
    26
    -from typing import Tuple
    
    23
    +from typing import Optional
    
    24
    +from typing import Union
    
    27 25
     from typing import cast
    
    28 26
     
    
    29 27
     import os
    
    ... ... @@ -36,7 +34,8 @@
    36 34
     
    
    37 35
     import gajim
    
    38 36
     from gajim.common.i18n import _
    
    39
    -from gajim.common.const import PathType, PathLocation
    
    37
    +from gajim.common.const import PathType
    
    38
    +from gajim.common.const import PathLocation
    
    40 39
     from gajim.common.types import PathTuple
    
    41 40
     
    
    42 41
     
    
    ... ... @@ -44,7 +43,7 @@ def get(key: str) -> Path:
    44 43
         return _paths[key]
    
    45 44
     
    
    46 45
     
    
    47
    -def get_plugin_dirs() -> List[Path]:
    
    46
    +def get_plugin_dirs() -> list[Path]:
    
    48 47
         if gajim.IS_FLATPAK:
    
    49 48
             return [Path(_paths['PLUGINS_BASE']),
    
    50 49
                     Path('/app/plugins')]
    
    ... ... @@ -102,10 +101,10 @@ def create_paths() -> None:
    102 101
     
    
    103 102
     class ConfigPaths:
    
    104 103
         def __init__(self) -> None:
    
    105
    -        self._paths = {}  # type: Dict[str, PathTuple]
    
    104
    +        self._paths: dict[str, PathTuple] = {}
    
    106 105
             self.profile = ''
    
    107 106
             self.profile_separation = False
    
    108
    -        self.custom_config_root = None  # type: Optional[Path]
    
    107
    +        self.custom_config_root: Optional[Path] = None
    
    109 108
     
    
    110 109
             if os.name == 'nt':
    
    111 110
                 if gajim.IS_PORTABLE:
    
    ... ... @@ -146,7 +145,7 @@ def __getitem__(self, key: str) -> Path:
    146 145
                 return self.data_root / path
    
    147 146
             return path
    
    148 147
     
    
    149
    -    def items(self) -> Generator[Tuple[str, PathTuple], None, None]:
    
    148
    +    def items(self) -> Generator[tuple[str, PathTuple], None, None]:
    
    150 149
             for key, value in self._paths.items():
    
    151 150
                 yield (key, value)
    
    152 151
     
    
    ... ... @@ -160,10 +159,13 @@ def _prepare(self, path: Path, unique: bool) -> Path:
    160 159
     
    
    161 160
         def add(self,
    
    162 161
                 name: str,
    
    163
    -            path: Path,
    
    164
    -            location: PathLocation = None,
    
    165
    -            path_type: PathType = None,
    
    162
    +            path: Union[Path, str],
    
    163
    +            location: Optional[PathLocation] = None,
    
    164
    +            path_type: Optional[PathType] = None,
    
    166 165
                 unique: bool = False) -> None:
    
    166
    +
    
    167
    +        path = Path(path)
    
    168
    +
    
    167 169
             if location is not None:
    
    168 170
                 path = self._prepare(path, unique)
    
    169 171
             self._paths[name] = (location, path, path_type)
    

  • mypy.ini
    ... ... @@ -4,12 +4,6 @@ warn_unused_configs = True
    4 4
     disallow_incomplete_defs = True
    
    5 5
     allow_redefinition = True
    
    6 6
     
    
    7
    -[mypy-nbxmpp.*]
    
    8
    -ignore_missing_imports = True
    
    9
    -
    
    10
    -[mypy-gi.*]
    
    11
    -ignore_missing_imports = True
    
    12
    -
    
    13 7
     [mypy-dbus.*]
    
    14 8
     ignore_missing_imports = True
    
    15 9