Skip to content

Commit f134874

Browse files
committed
Refactoring. Adding the None annotation to the return value
1 parent 887b22a commit f134874

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎HelloPython/HelloPython.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from datetime import datetime, time
66

77

8-
def main(namespace):
8+
def main(namespace) -> None:
99
args = namespace.parse_args()
1010
args.user = "Илья"
1111
if args.user:
@@ -29,7 +29,7 @@ def main(namespace):
2929
print("Привет, Python!")
3030

3131

32-
def create_parser():
32+
def create_parser() -> argparse.ArgumentParser:
3333
parser = argparse.ArgumentParser(description="Hello World Example!")
3434
parser.add_argument("--user", type=str, help=" user name.")
3535
return parser

‎hex2str/gui.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from hex2str import hex2str, str2hex
2626

2727

28-
def log_uncaught_exceptions(ex_cls, ex, tb):
28+
def log_uncaught_exceptions(ex_cls, ex, tb) -> None:
2929
text = f"{ex_cls.__name__}: {ex}:\n"
3030
text += "".join(traceback.format_tb(tb))
3131

@@ -38,7 +38,7 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
3838

3939

4040
class Widget(QWidget):
41-
def __init__(self):
41+
def __init__(self) -> None:
4242
super().__init__()
4343

4444
self.setWindowTitle("hex2str")
@@ -124,7 +124,7 @@ def __init__(self):
124124

125125
self.setLayout(layout)
126126

127-
def _on_input_selection_changed(self):
127+
def _on_input_selection_changed(self) -> None:
128128
try:
129129
# Нехорошо будет если второй будет вызывать сигналы, например о выделении текста
130130
self.text_edit_output.blockSignals(True)
@@ -155,7 +155,7 @@ def _on_input_selection_changed(self):
155155
finally:
156156
self.text_edit_output.blockSignals(False)
157157

158-
def _on_output_selection_changed(self):
158+
def _on_output_selection_changed(self) -> None:
159159
try:
160160
# Нехорошо будет если второй будет вызывать сигналы, например о выделении текста
161161
self.text_edit_input.blockSignals(True)
@@ -186,7 +186,7 @@ def _on_output_selection_changed(self):
186186
finally:
187187
self.text_edit_input.blockSignals(False)
188188

189-
def show_detail_error_massage(self):
189+
def show_detail_error_massage(self) -> None:
190190
message = self.last_error_message + "\n\n" + self.last_detail_error_message
191191

192192
mb = QErrorMessage()
@@ -198,7 +198,7 @@ def show_detail_error_massage(self):
198198

199199
mb.exec_()
200200

201-
def _convert(self):
201+
def _convert(self) -> None:
202202
self.label_error.clear()
203203
self.button_detail_error.hide()
204204

‎https_гибдд_рф__crash_statistics/common.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def create_connect(fields_as_dict=False, trace_sql=False) -> sqlite3.Connection:
8080
return connect
8181

8282

83-
def init_db():
83+
def init_db() -> None:
8484
# Создание базы и таблицы
8585
with create_connect() as connect:
8686
connect.execute(
@@ -102,7 +102,7 @@ def init_db():
102102
connect.commit()
103103

104104

105-
def db_create_backup(backup_dir="backup"):
105+
def db_create_backup(backup_dir="backup") -> None:
106106
os.makedirs(backup_dir, exist_ok=True)
107107

108108
file_name = str(dt.datetime.today().date()) + ".sqlite"
@@ -111,7 +111,7 @@ def db_create_backup(backup_dir="backup"):
111111
shutil.copy(DB_FILE_NAME, file_name)
112112

113113

114-
def append_crash_statistics_db(crash_statistics: CrashStatistics = None):
114+
def append_crash_statistics_db(crash_statistics: CrashStatistics = None) -> None:
115115
db_create_backup()
116116

117117
if not crash_statistics:

‎https_гибдд_рф_request_main__auto_fill_fields__web_gui/main.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
1515

1616

17-
def log_uncaught_exceptions(ex_cls, ex, tb):
17+
def log_uncaught_exceptions(ex_cls, ex, tb) -> None:
1818
text = f"{ex_cls.__name__}: {ex}:\n"
1919
text += "".join(traceback.format_tb(tb))
2020

@@ -69,7 +69,7 @@ def run_js_code(page: QWebEnginePage, code: str) -> object:
6969

7070
result_value = {"value": None}
7171

72-
def _on_callback(result: object):
72+
def _on_callback(result: object) -> None:
7373
result_value["value"] = result
7474

7575
loop.quit()
@@ -88,7 +88,7 @@ def javaScriptConsoleMessage(
8888
message: str,
8989
line_number: int,
9090
source_id: str,
91-
):
91+
) -> None:
9292
print(
9393
f"javascript_console_message: {level}, {message}, {line_number}, {source_id}",
9494
file=sys.stderr,
@@ -120,7 +120,7 @@ def javaScriptConsoleMessage(
120120
# page.urlChanged.connect(_on_url_changed)
121121

122122

123-
def _on_load_finished(ok: bool):
123+
def _on_load_finished(ok: bool) -> None:
124124
print(page.url().toString())
125125

126126
page.runJavaScript(jquery_text)

‎img_to_base64_html/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from PIL import Image
1212

1313

14-
def img_to_base64_html(file_name__or__bytes__or__file_object: str | bytes | io.IOBase):
14+
def img_to_base64_html(file_name__or__bytes__or__file_object: str | bytes | io.IOBase) -> str:
1515
arg = file_name__or__bytes__or__file_object
1616

1717
if isinstance(arg, str):

0 commit comments

Comments
 (0)