Skip to content

Commit a26afd1

Browse files
committed
Refactoring. Adding the None annotation to the return value
1 parent 604b7b5 commit a26afd1

18 files changed

Lines changed: 36 additions & 36 deletions

File tree

‎Timer/pyside_qtimer.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from PySide.QtCore import *
99

1010

11-
def say():
11+
def say() -> None:
1212
print("say!")
1313

1414

‎total_time_playlist_youtube/gui.py‎

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

4949

5050
class MainWindow(QMainWindow):
51-
def __init__(self):
51+
def __init__(self) -> None:
5252
super().__init__()
5353

5454
self.setWindowTitle("total_time_playlist_youtube")
@@ -73,7 +73,7 @@ def __init__(self):
7373
central_widget.setLayout(main_layout)
7474
self.setCentralWidget(central_widget)
7575

76-
def go(self):
76+
def go(self) -> None:
7777
try:
7878
url = self.url_line_edit.text()
7979
title, total_seconds, total_seconds_text, items = parse_playlist_time(url)

‎translate_text_screenshot_by_hotkey/main.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
3030

3131

32-
def error_sound():
32+
def error_sound() -> None:
3333
duration = 300 # milliseconds
3434
freq = 1000 # Hz
3535
winsound.Beep(freq, duration)
3636

3737

38-
def run():
38+
def run() -> None:
3939
try:
4040
file_name = f"screenshot_{dt.datetime.now():%Y-%m-%d_%H%M%S}.html"
4141
print(file_name)

‎unistream_examples/utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def hmac_sha256(key, msg):
2626
return base64.b64encode(signature).decode()
2727

2828

29-
def get_authorization_header(application_id, secret, today_date, url, headers):
29+
def get_authorization_header(application_id, secret, today_date, url, headers) -> str:
3030
logging.debug("Url:\n%s", url)
3131

3232
url_parts = urlsplit(url)

‎update_task_and_jobs_from_gist/ConEmu_start_task/3. modify_ConEmu_settings_tasks.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_current_datetime() -> str:
2424
return dt.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
2525

2626

27-
def update_tasks(tasks_el: ET.Element):
27+
def update_tasks(tasks_el: ET.Element) -> None:
2828
tasks_el.attrib["modified"] = get_current_datetime()
2929

3030
tasks = tasks_el.findall("key")
@@ -38,7 +38,7 @@ def update_tasks(tasks_el: ET.Element):
3838
task_el.attrib["build"] = tasks_el.attrib["build"]
3939

4040

41-
def create_task(tasks_el: ET.Element, name: str, commands: list[str]):
41+
def create_task(tasks_el: ET.Element, name: str, commands: list[str]) -> None:
4242
task_el = ET.SubElement(tasks_el, "key")
4343

4444
ET.SubElement(task_el, "value", name="Name", type="string", data="{%s}" % name)

‎update_task_and_jobs_from_gist/ConEmu_start_task/move ConEmu to second desktop.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
def get_hwnd_for_pid(pid: int):
24-
def callback(hwnd: int, hwnds: list):
24+
def callback(hwnd: int, hwnds: list) -> bool:
2525
if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
2626
_, found_pid = win32process.GetWindowThreadProcessId(hwnd)
2727
if found_pid == pid:

‎update_task_and_jobs_from_gist/Jenkins_jobs/run_jobs.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
from common import get_jobs_for_run, client
88

99

10-
def run_job(job):
10+
def run_job(job) -> None:
1111
print(f"Run {job.full_name!r}")
1212
job.build()
1313

1414

15-
def run_in_view(view_name: str):
15+
def run_in_view(view_name: str) -> None:
1616
for job in client.views.get(view_name):
1717
run_job(job)
1818

‎url2image/url2image.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
class WebPage(QWebPage):
25-
def userAgentForUrl(self, url):
25+
def userAgentForUrl(self, url) -> str:
2626
return (
2727
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"
2828
)

‎using_proxy/proxy_requests__upgraded.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class ProxyRequests:
2626
]
2727
EMPTY_WARN = "Proxy Pool has been emptied"
2828

29-
def __init__(self, url: str, timeout=5):
29+
def __init__(self, url: str, timeout=5) -> None:
3030
self.url = url
3131
self.proxies = []
3232
self.used_proxy = None
3333
self.timeout = timeout
3434
self._acquire_sockets()
3535

36-
def _acquire_sockets(self):
36+
def _acquire_sockets(self) -> None:
3737
rs = requests.get("https://www.sslproxies.org/")
3838
matches = findall(r"<td>\d+\.\d+\.\d+\.\d+</td><td>\d+</td>", rs.text)
3939
revised = [m.replace("<td>", "") for m in matches]

‎visual_diff_two_structures/main.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from utils import get_filling_in_missing, xml_to_flatten_dict, json_to_flatten_dict
1717

1818

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

@@ -106,7 +106,7 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
106106
# TODO: ... или еще и цветом?
107107
# TODO: Надо бы и поле заголовка выделить
108108
class MainWindow(QMainWindow):
109-
def __init__(self):
109+
def __init__(self) -> None:
110110
super().__init__()
111111

112112
self.ui = Ui_MainWindow()
@@ -117,7 +117,7 @@ def __init__(self):
117117
self.ui.push_button_diff.clicked.connect(self._do_diff)
118118
self.ui.cb_only_diff.clicked.connect(self._show_only_diff)
119119

120-
def _add_row_to_table(self, *values):
120+
def _add_row_to_table(self, *values) -> None:
121121
name1, value1, value2, name2 = values
122122
no_match = name1 != name2 or value1 != value2
123123

@@ -144,7 +144,7 @@ def _add_row_to_table(self, *values):
144144

145145
self.ui.table_widget.setItem(row, i, item)
146146

147-
def _do_diff(self):
147+
def _do_diff(self) -> None:
148148
source_1 = self.ui.edit_source_1.toPlainText()
149149
source_2 = self.ui.edit_source_2.toPlainText()
150150

@@ -178,7 +178,7 @@ def _do_diff(self):
178178

179179
self._show_only_diff(self.ui.cb_only_diff.isChecked())
180180

181-
def _show_only_diff(self, checked: bool):
181+
def _show_only_diff(self, checked: bool) -> None:
182182
for row in range(self.ui.table_widget.rowCount()):
183183
no_match = self.ui.table_widget.item(row, 0).data(Qt.ItemDataRole.UserRole)
184184

0 commit comments

Comments
 (0)