Skip to content

Commit 7250503

Browse files
committed
Refactoring. for_games/. Adding the None annotation to the return value
1 parent 4a777d8 commit 7250503

27 files changed

Lines changed: 51 additions & 51 deletions

File tree

‎for_games/Bloodborne/bloodborne_fandom_com__ru__wiki__Боссы/main.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_bosses() -> dict[str, list[Boss]]:
5454
return bosses_by_category
5555

5656

57-
def print_bosses(bosses: dict[str, list[Boss]]):
57+
def print_bosses(bosses: dict[str, list[Boss]]) -> None:
5858
total = sum(len(i) for i in bosses.values())
5959
print(f"Боссы ({total}):")
6060

@@ -75,7 +75,7 @@ def convert_bosses_to_only_name(bosses: dict[str, list[Boss]]) -> dict[str, list
7575
return bosses_only_name
7676

7777

78-
def export_to_json(file_name: Path, bosses: dict[str, list[Boss | str]]):
78+
def export_to_json(file_name: Path, bosses: dict[str, list[Boss | str]]) -> None:
7979
file_name.parent.mkdir(parents=True, exist_ok=True)
8080

8181
json.dump(
@@ -87,7 +87,7 @@ def export_to_json(file_name: Path, bosses: dict[str, list[Boss | str]]):
8787
)
8888

8989

90-
def export_to_simple_text(file_name, bosses: dict[str, list[Boss]]):
90+
def export_to_simple_text(file_name, bosses: dict[str, list[Boss]]) -> None:
9191
file_name.parent.mkdir(parents=True, exist_ok=True)
9292

9393
with open(file_name, "w", encoding="utf-8") as f:

‎for_games/Bot Buff Knight Advanced/__foo_test.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from common import get_current_datetime_str
2121

2222

23-
def draw_rects(img, contours_rects, color=(0, 255, 0)):
23+
def draw_rects(img, contours_rects, color=(0, 255, 0)) -> None:
2424
for x, y, w, h in contours_rects:
2525
cv2.rectangle(img, (x, y), (x + w, y + h), color, thickness=5)
2626
# cv2.rectangle(img, (x, y), (x + w, y + h), color, thickness=-1)

‎for_games/Bot Buff Knight Advanced/main.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def filter_fairy_and_button(rect_fairy, rect_button):
6161
os.mkdir(DIR)
6262

6363

64-
def save_screenshot(prefix, img_hsv):
64+
def save_screenshot(prefix, img_hsv) -> None:
6565
file_name = f"{DIR}/{prefix}__{get_current_datetime_str()}.png"
6666
log.debug(file_name)
6767
cv2.imwrite(file_name, cv2.cvtColor(np.array(img_hsv), cv2.COLOR_HSV2BGR))
@@ -90,12 +90,12 @@ def save_screenshot(prefix, img_hsv):
9090
}
9191

9292

93-
def change_start():
93+
def change_start() -> None:
9494
BOT_DATA["START"] = not BOT_DATA["START"]
9595
log.debug("START: %s", BOT_DATA["START"])
9696

9797

98-
def change_auto_attack():
98+
def change_auto_attack() -> None:
9999
BOT_DATA["AUTO_ATTACK"] = not BOT_DATA["AUTO_ATTACK"]
100100
log.debug("AUTO_ATTACK: %s", BOT_DATA["AUTO_ATTACK"])
101101

@@ -105,7 +105,7 @@ def change_auto_attack():
105105
log.debug('Press "%s" for AUTO_ATTACK', AUTO_ATTACK_COMBINATION)
106106

107107

108-
def process_auto_attack():
108+
def process_auto_attack() -> None:
109109
while True:
110110
if not BOT_DATA["START"]:
111111
time.sleep(0.01)
@@ -118,7 +118,7 @@ def process_auto_attack():
118118
time.sleep(0.01)
119119

120120

121-
def process_find_fairy(img_hsv):
121+
def process_find_fairy(img_hsv) -> None:
122122
rects_blue = find_rect_contours(img_hsv, BLUE_HSV_MIN, BLUE_HSV_MAX)
123123
rects_orange = find_rect_contours(img_hsv, ORANGE_HSV_MIN, ORANGE_HSV_MAX)
124124
rects_fairy = find_rect_contours(img_hsv, FAIRY_HSV_MIN, FAIRY_HSV_MAX)

‎for_games/Dark Souls/backup__save_files/by_autosave/common.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
log = get_logger(__file__)
2222

2323

24-
def backup_saves(path_ds_save: str, forced: bool = False, modified_minutes: int = 5):
24+
def backup_saves(path_ds_save: str, forced: bool = False, modified_minutes: int = 5) -> None:
2525
try:
2626
for path_file_name in glob(path_ds_save):
2727
log.debug(f"Check: {path_file_name}")
@@ -50,7 +50,7 @@ def backup_saves(path_ds_save: str, forced: bool = False, modified_minutes: int
5050
time.sleep(5 * 60)
5151

5252

53-
def run(path_ds_save: str, timeout_minutes: int = 5):
53+
def run(path_ds_save: str, timeout_minutes: int = 5) -> None:
5454
# Example: r'~\Documents\NBGI\DarkSouls\*\DRAKS0005.sl2'
5555
path_ds_save: str = os.path.expanduser(path_ds_save)
5656

‎for_games/Dark Souls/backup__save_files/by_hotkey/common.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import keyboard
2222

2323

24-
def beep():
24+
def beep() -> None:
2525
try:
2626
winsound.Beep(1000, duration=50)
2727
except:
@@ -35,7 +35,7 @@ def beep():
3535
HOTKEY = "CTRL + F1"
3636

3737

38-
def backup_saves(path_ds_save: str):
38+
def backup_saves(path_ds_save: str) -> None:
3939
try:
4040
for path_file_name in glob(path_ds_save):
4141
file_name_backup = backup(path_file_name)
@@ -48,7 +48,7 @@ def backup_saves(path_ds_save: str):
4848
time.sleep(5 * 60)
4949

5050

51-
def run(path_ds_save: str, hotkey: str = HOTKEY):
51+
def run(path_ds_save: str, hotkey: str = HOTKEY) -> None:
5252
# Example: r'~\Documents\NBGI\DarkSouls\*\DRAKS0005.sl2'
5353
path_ds_save = os.path.expanduser(path_ds_save)
5454

‎for_games/Dark Souls/common.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
class Parser:
20-
def __init__(self, url_locations: str, log=True):
20+
def __init__(self, url_locations: str, log=True) -> None:
2121
self._url_locations = url_locations
2222
self._is_log = log
2323

@@ -43,7 +43,7 @@ def DS2(log=True) -> "Parser":
4343
def DS3(log=True) -> "Parser":
4444
return Parser(URL_DS3, log)
4545

46-
def _log(self, *args, **kwargs):
46+
def _log(self, *args, **kwargs) -> None:
4747
self._is_log and print(*args, **kwargs)
4848

4949
@staticmethod

‎for_games/Dark Souls/generate_HTML_location_graph__with_d3js/generate_graph_html.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def generate(
6464
links: list[tuple[str, str]],
6565
title: str = "Graph",
6666
file_name_template: str | Path = DIR / "template_graph.html",
67-
):
67+
) -> None:
6868
template_title = "{{title}}"
6969
template_dataset = "{{dataset}}"
7070

‎for_games/Dark Souls/ru_darksouls_wikia_com__fandom__bosses/print_stats_by_health_and_souls/_utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def print_stats(
228228
rows: List[Tuple[str, int, int]],
229229
headers=("NAME", "HEALTH", "SOULS"),
230230
sort_column=1,
231-
):
231+
) -> None:
232232
rows.sort(key=lambda x: x[sort_column], reverse=True)
233233

234234
rows.insert(0, headers)

‎for_games/Dark Souls/ru_darksouls_wikia_com__fandom__bosses/utils.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get_bosses(url: str) -> Dict[str, List[Boss]]:
8585
return bosses_by_category
8686

8787

88-
def print_bosses(url: str, bosses: Dict[str, List[Boss]]):
88+
def print_bosses(url: str, bosses: Dict[str, List[Boss]]) -> None:
8989
total = sum(len(i) for i in bosses.values())
9090
print(f"{url} ({total}):")
9191

@@ -108,7 +108,7 @@ def convert_bosses_to_only_name(bosses: Dict[str, List[Boss]]) -> Dict[str, List
108108
return bosses_only_name
109109

110110

111-
def export_to_json(file_name, bosses):
111+
def export_to_json(file_name, bosses) -> None:
112112
dir_name = os.path.dirname(file_name)
113113
os.makedirs(dir_name, exist_ok=True)
114114

@@ -120,7 +120,7 @@ def export_to_json(file_name, bosses):
120120
)
121121

122122

123-
def export_to_sqlite(file_name: str, bosses_ds123: Dict[str, Dict[str, List[Boss]]]):
123+
def export_to_sqlite(file_name: str, bosses_ds123: Dict[str, Dict[str, List[Boss]]]) -> None:
124124
dir_name = os.path.dirname(file_name)
125125
os.makedirs(dir_name, exist_ok=True)
126126

‎for_games/Demons Souls/demonssouls_fandom_com__ru__wiki__Боссы/main.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def get_bosses(url: str) -> dict[str, list[Boss]]:
5555
return bosses_by_category
5656

5757

58-
def print_bosses(url: str, bosses: dict[str, list[Boss]]):
58+
def print_bosses(url: str, bosses: dict[str, list[Boss]]) -> None:
5959
total = sum(len(i) for i in bosses.values())
6060
print(f"{url} ({total}):")
6161

@@ -78,7 +78,7 @@ def convert_bosses_to_only_name(bosses: dict[str, list[Boss]]) -> dict[str, list
7878
return bosses_only_name
7979

8080

81-
def export_to_json(file_name, bosses):
81+
def export_to_json(file_name, bosses) -> None:
8282
dir_name = os.path.dirname(file_name)
8383
os.makedirs(dir_name, exist_ok=True)
8484

@@ -90,7 +90,7 @@ def export_to_json(file_name, bosses):
9090
)
9191

9292

93-
def export_to_simple_text(file_name, bosses):
93+
def export_to_simple_text(file_name, bosses) -> None:
9494
dir_name = os.path.dirname(file_name)
9595
os.makedirs(dir_name, exist_ok=True)
9696

0 commit comments

Comments
 (0)