Skip to content

Commit c471804

Browse files
[pre-commit.ci] Auto fixes from pre-commit.com hooks.
1 parent 75d1f35 commit c471804

50 files changed

Lines changed: 86 additions & 138 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ from ..basic_game import BasicGame
100100

101101

102102
class Witcher3Game(BasicGame):
103-
104103
Name = "Witcher 3 Support Plugin"
105104
Author = "Holt59"
106105
Version = "1.0.0a"
@@ -129,7 +128,6 @@ import mobase
129128

130129

131130
class Witcher3Game(BasicGame):
132-
133131
Name = "Witcher 3 Support Plugin"
134132
Author = "Holt59"
135133

‎__init__.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def createPlugins():
2525
# List of game class from python:
26-
game_plugins: typing.List[IPlugin] = []
26+
game_plugins: list[IPlugin] = []
2727

2828
# We are going to list all game plugins:
2929
curpath = os.path.abspath(os.path.dirname(__file__))
@@ -43,9 +43,9 @@ def createPlugins():
4343
try:
4444
module = importlib.import_module(".games." + module_p[:-3], __package__)
4545
except ImportError as e:
46-
print("Failed to import module {}: {}".format(module_p, e), file=sys.stderr)
46+
print(f"Failed to import module {module_p}: {e}", file=sys.stderr)
4747
except Exception as e:
48-
print("Failed to import module {}: {}".format(module_p, e), file=sys.stderr)
48+
print(f"Failed to import module {module_p}: {e}", file=sys.stderr)
4949

5050
# Lookup game plugins:
5151
for name in dir(module):
@@ -60,7 +60,7 @@ def createPlugins():
6060
game_plugins.append(obj())
6161
except Exception as e:
6262
print(
63-
"Failed to instantiate {}: {}".format(name, e),
63+
f"Failed to instantiate {name}: {e}",
6464
file=sys.stderr,
6565
)
6666
for path in pathlib.Path(escaped_games_path).rglob("plugins/__init__.py"):

‎basic_features/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from .basic_save_game_info import BasicGameSaveGameInfo
44

55
__all__ = [
6-
"BasicModDataChecker",
76
"BasicGameSaveGameInfo",
8-
"GlobPatterns",
97
"BasicLocalSavegames",
8+
"BasicModDataChecker",
9+
"GlobPatterns",
1010
]

‎basic_features/basic_mod_data_checker.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import fnmatch
44
import re
5+
from collections.abc import Iterable
56
from dataclasses import dataclass, field
6-
from typing import Iterable, Literal
7+
from typing import Literal
78

89
import mobase
910

@@ -28,7 +29,7 @@ def regex_from_glob_list(glob_list: Iterable[str]) -> re.Pattern[str]:
2829
give the `glob_list` index.
2930
"""
3031
return re.compile(
31-
"|".join(f"({fnmatch.translate(f)})" for f in glob_list), re.I
32+
"|".join(f"({fnmatch.translate(f)})" for f in glob_list), re.IGNORECASE
3233
)
3334

3435
def match(self, value: str) -> bool:
@@ -48,7 +49,7 @@ def __init__(self, globs: GlobPatterns) -> None:
4849
self.valid = OptionalRegexPattern(globs.valid)
4950

5051
self.move = {
51-
key: re.compile(fnmatch.translate(key), re.I) for key in globs.move
52+
key: re.compile(fnmatch.translate(key), re.IGNORECASE) for key in globs.move
5253
}
5354
self.ignore = OptionalRegexPattern(globs.ignore)
5455

‎basic_features/basic_save_game_info.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# -*- encoding: utf-8 -*-
2-
31
import sys
4-
from collections.abc import Mapping
2+
from collections.abc import Callable, Mapping, Sequence
53
from datetime import datetime
64
from pathlib import Path
7-
from typing import Any, Callable, Self, Sequence
5+
from typing import Any, Self
86

97
from PyQt6.QtCore import QDateTime, QLocale, Qt
108
from PyQt6.QtGui import QImage, QPixmap

‎basic_game.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import shutil
44
import sys
5+
from collections.abc import Callable
56
from pathlib import Path
6-
from typing import Callable, Generic, TypeVar
7+
from typing import Generic, TypeVar
78

89
from PyQt6.QtCore import QDir, QFileInfo, QStandardPaths
910
from PyQt6.QtGui import QIcon
@@ -49,7 +50,7 @@ def replace_variables(value: str, game: BasicGame) -> str:
4950

5051
class BasicGameMapping(Generic[_T]):
5152
# The game:
52-
_game: "BasicGame"
53+
_game: BasicGame
5354

5455
# Name of the attribute for exposure:
5556
_exposed_name: str
@@ -61,7 +62,7 @@ class BasicGameMapping(Generic[_T]):
6162
_required: bool
6263

6364
# Callable returning a default value (if not required):
64-
_default: Callable[["BasicGame"], _T]
65+
_default: Callable[[BasicGame], _T]
6566

6667
# Function to apply to the value:
6768
_apply_fn: Callable[[_T | str], _T] | None
@@ -256,7 +257,7 @@ def __init__(self, game: BasicGame):
256257
game,
257258
"Description",
258259
"description",
259-
lambda g: "Adds basic support for game {}.".format(g.gameName()),
260+
lambda g: f"Adds basic support for game {g.gameName()}.",
260261
)
261262
self.gameName = BasicGameMapping(game, "GameName", "gameName")
262263
self.gameShortName = BasicGameMapping(game, "GameShortName", "gameShortName")
@@ -416,7 +417,7 @@ def setup():
416417
_gamePath: str
417418

418419
def __init__(self):
419-
super(BasicGame, self).__init__()
420+
super().__init__()
420421

421422
if not hasattr(self, "_fromName"):
422423
self._fromName = self.__class__.__name__

‎basic_game_ini.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- encoding: utf-8 -*-
2-
31
import configparser
42
import os
53

‎eadesktop_utils.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
# -*- encoding: utf-8 -*-
2-
31
import configparser
42
import os
53
import sys
64
import xml.etree.ElementTree as et
75
from configparser import NoOptionError
86
from pathlib import Path
9-
from typing import Dict
107

118

12-
def find_games(errors: list[tuple[str, Exception]] | None = None) -> Dict[str, Path]:
9+
def find_games(errors: list[tuple[str, Exception]] | None = None) -> dict[str, Path]:
1310
"""
1411
Find the list of EA Desktop games installed.
1512
1613
Returns:
1714
A mapping from EA Desktop content IDs to install locations for available
1815
EA Desktop games.
1916
"""
20-
games: Dict[str, Path] = {}
17+
games: dict[str, Path] = {}
2118

2219
local_app_data_path = os.path.expandvars("%LocalAppData%")
2320
ea_desktop_settings_path = Path(local_app_data_path).joinpath(
@@ -82,4 +79,4 @@ def find_games(errors: list[tuple[str, Exception]] | None = None) -> Dict[str, P
8279
if __name__ == "__main__":
8380
games = find_games()
8481
for k, v in games.items():
85-
print("Found game with id {} at {}.".format(k, v))
82+
print(f"Found game with id {k} at {v}.")

‎epic_utils.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- encoding: utf-8 -*-
21
from __future__ import annotations
32

43
import itertools
@@ -98,4 +97,4 @@ def find_games(errors: ErrorList | None = None) -> dict[str, Path]:
9897
if __name__ == "__main__":
9998
games = find_games()
10099
for k, v in games.items():
101-
print("Found game with id {} at {}.".format(k, v))
100+
print(f"Found game with id {k} at {v}.")

‎games/baldursgate3/bg3_file_mapper.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import functools
22
import os
3+
from collections.abc import Callable
34
from pathlib import Path
4-
from typing import Callable, Optional
55

66
from PyQt6.QtCore import QDir, QLoggingCategory, qDebug, qInfo, qWarning
77
from PyQt6.QtWidgets import QApplication
@@ -75,7 +75,7 @@ def mappings(self) -> list[mobase.Mapping]:
7575
def map_files(
7676
self,
7777
path: Path,
78-
dest: Optional[Path] = None,
78+
dest: Path | None = None,
7979
pattern: str = "*",
8080
rel: bool = True,
8181
only_convert: bool = False,

0 commit comments

Comments
 (0)