Skip to content

Commit 2739333

Browse files
committed
Refactoring. Adding the None annotation to the return value
1 parent 7250503 commit 2739333

6 files changed

Lines changed: 14 additions & 15 deletions

File tree

‎function_example/function_example.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ def my_sum(*args):
88
return s
99

1010

11-
def my_print(**kwargs):
11+
def my_print(**kwargs) -> None:
1212
for name, value in kwargs.items():
1313
print("%s=%s(%s)" % (name, value, type(value)))
1414

1515

16-
def sql_insert(table, **kwargs):
16+
def sql_insert(table, **kwargs) -> str:
1717
# Example: INSERT INTO users (login, pass) values('TestUser', '123456')
1818
columns = kwargs.keys()
1919
values = ["'%s'" % x for x in kwargs.values()]
@@ -24,7 +24,7 @@ def sql_insert(table, **kwargs):
2424
)
2525

2626

27-
def say_hello(word="World", spl="!"):
27+
def say_hello(word="World", spl="!") -> None:
2828
print("Hello, " + word + spl)
2929

3030

‎get_actual_news_from_rss_ya/webserver/common.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def create_connect():
2424
return sqlite3.connect(DB_FILE_NAME)
2525

2626

27-
def init_db():
27+
def init_db() -> None:
2828
# Создание базы и таблицы
2929
connect = create_connect()
3030
try:
@@ -71,10 +71,10 @@ def init_db():
7171
connect.close()
7272

7373

74-
def append_list_news(list_news: [str, str], interest: str):
74+
def append_list_news(list_news: [str, str], interest: str) -> None:
7575
connect = create_connect()
7676

77-
def insert_news(title, url, interest):
77+
def insert_news(title, url, interest) -> None:
7878
# Для отсеивания дубликатов
7979
has = connect.execute("SELECT 1 FROM News WHERE url = ?", (url,)).fetchone()
8080
if has:
@@ -161,7 +161,7 @@ def get_news_list_and_mark_as_read(
161161
connect.close()
162162

163163

164-
def reset_all_is_read():
164+
def reset_all_is_read() -> None:
165165
connect = create_connect()
166166

167167
try:

‎get_cpu_process/get_cpu_process.py‎

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

1515

1616
class ProcessNotFound(Exception):
17-
def __init__(self, name: str):
17+
def __init__(self, name: str) -> None:
1818
super().__init__(f"Process {name!r} not found")
1919

2020

‎get_md5_file/get_md5_file_gui.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from get_md5_file import md5sum
4646

4747

48-
def log_uncaught_exceptions(ex_cls, ex, tb):
48+
def log_uncaught_exceptions(ex_cls, ex, tb) -> None:
4949
text = f"{ex_cls.__name__}: {ex}:\n"
5050
text += "".join(traceback.format_tb(tb))
5151

@@ -61,7 +61,7 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
6161

6262

6363
class MainWindow(QMainWindow):
64-
def __init__(self):
64+
def __init__(self) -> None:
6565
super().__init__()
6666

6767
self.setWindowTitle("get_md5_file_gui")
@@ -97,7 +97,7 @@ def __init__(self):
9797

9898
self.setCentralWidget(central_widget)
9999

100-
def dragEnterEvent(self, event):
100+
def dragEnterEvent(self, event) -> None:
101101
mime = event.mimeData()
102102
if mime.hasUrls() and len(mime.urls()) == 1:
103103
event.acceptProposedAction()

‎gitpython_examples/common.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
def get_repo():
3232
try:
3333
return git.Repo(REPO_PATH)
34-
3534
except:
3635
return git.Repo.clone_from(URL_GIT, REPO_PATH)
3736

@@ -46,7 +45,7 @@ def return_log(reverse=False):
4645
return logs
4746

4847

49-
def print_log(reverse=False):
48+
def print_log(reverse=False) -> None:
5049
logs = return_log(reverse)
5150
print(f"Logs[{len(logs)}]:")
5251

‎gitpython_examples/pull_all_repos.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from common import get_total_commits
1313

1414

15-
def process_repository(repo_path: Path):
15+
def process_repository(repo_path: Path) -> None:
1616
print(repo_path)
1717

1818
repo = git.Repo(repo_path)
@@ -31,7 +31,7 @@ def process_repository(repo_path: Path):
3131
print(f"Repository is actual")
3232

3333

34-
def process_all(path: Path, pattern: str = '.git'):
34+
def process_all(path: Path, pattern: str = '.git') -> None:
3535
paths: list[Path] = [
3636
p.parent
3737
for p in path.rglob(pattern)

0 commit comments

Comments
 (0)