Skip to content

Commit 81d5de7

Browse files
committed
Refactoring. Adding the None annotation to the return value
1 parent e7e68a1 commit 81d5de7

21 files changed

Lines changed: 46 additions & 46 deletions

File tree

‎kivy_examples/generate_form_with_cycle.py‎

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

1111

1212
class MyWidget(GridLayout):
13-
def __init__(self, **kwargs):
13+
def __init__(self, **kwargs) -> None:
1414
super().__init__(**kwargs)
1515

1616
self.cols = 1

‎kivy_examples/kivymd__example.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Test(MDApp):
2222
def build(self):
2323
return Builder.load_string(KV)
2424

25-
def on_start(self):
25+
def on_start(self) -> None:
2626
for i in os.listdir(path="."):
2727
self.root.ids.container.add_widget(
2828
OneLineListItem(text=i, on_release=lambda item, i=i: print(i))

‎kivy_examples/login_screen.py‎

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

1414

1515
class LoginScreen(GridLayout):
16-
def __init__(self, **kwargs):
16+
def __init__(self, **kwargs) -> None:
1717
super().__init__(**kwargs)
1818

1919
self.cols = 2
@@ -32,7 +32,7 @@ def __init__(self, **kwargs):
3232

3333
self.add_widget(Button(text="Ok", on_press=self.check))
3434

35-
def check(self, button):
35+
def check(self, button) -> None:
3636
print("auth called")
3737

3838
message = "Success!" if self.username.text == "admin" else "Need admin!"

‎kivy_examples/switch_between_widgets.py‎

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

1212

1313
class ScreenMain(Screen):
14-
def __init__(self, **kwargs):
14+
def __init__(self, **kwargs) -> None:
1515
super().__init__(**kwargs)
1616

1717
box_layout = BoxLayout(orientation="vertical", spacing=5, padding=[10])
@@ -26,13 +26,13 @@ def __init__(self, **kwargs):
2626
box_layout.add_widget(button_new_pasword)
2727
self.add_widget(box_layout)
2828

29-
def _on_press_button_new_pasword(self, *args):
29+
def _on_press_button_new_pasword(self, *args) -> None:
3030
self.manager.transition.direction = "left"
3131
self.manager.current = "len_password"
3232

3333

3434
class ScreenLenPassword(Screen):
35-
def __init__(self, **kwargs):
35+
def __init__(self, **kwargs) -> None:
3636
super().__init__(**kwargs)
3737

3838
box_layout = BoxLayout(orientation="vertical", spacing=5, padding=[10])
@@ -47,7 +47,7 @@ def __init__(self, **kwargs):
4747
box_layout.add_widget(button_new_pasword)
4848
self.add_widget(box_layout)
4949

50-
def _on_press_button_new_pasword(self, *args):
50+
def _on_press_button_new_pasword(self, *args) -> None:
5151
self.manager.transition.direction = "right"
5252
self.manager.current = "main_screen"
5353

‎lex_yacc__examples/sly__examples/added_string_and_print.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ def TEXT(self, t):
5050
ignore_newline = r"\n+"
5151

5252
# Extra action for newlines
53-
def ignore_newline(self, t):
53+
def ignore_newline(self, t) -> None:
5454
self.lineno += t.value.count("\n")
5555

56-
def error(self, t):
56+
def error(self, t) -> None:
5757
print(f"Illegal character '{t.value[0]}'")
5858
self.index += 1
5959

@@ -67,19 +67,19 @@ class MyParser(Parser):
6767
("right", UMINUS),
6868
)
6969

70-
def __init__(self):
70+
def __init__(self) -> None:
7171
self.names = dict()
7272

7373
@_("NAME ASSIGN expr")
74-
def statement(self, p):
74+
def statement(self, p) -> None:
7575
self.names[p.NAME] = p.expr
7676

7777
@_("expr")
7878
def statement(self, p) -> int | str:
7979
return p.expr
8080

8181
@_("PRINT expr")
82-
def statement(self, p):
82+
def statement(self, p) -> None:
8383
print(p.expr)
8484

8585
@_("expr PLUS expr")

‎lex_yacc__examples/sly__examples/added_ternary_operator.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ def FALSE(self, t):
7979
ignore_newline = r"\n+"
8080

8181
# Extra action for newlines
82-
def ignore_newline(self, t):
82+
def ignore_newline(self, t) -> None:
8383
self.lineno += t.value.count("\n")
8484

85-
def error(self, t):
85+
def error(self, t) -> None:
8686
print(f"Illegal character '{t.value[0]}'")
8787
self.index += 1
8888

@@ -99,11 +99,11 @@ class MyParser(Parser):
9999
("right", UMINUS),
100100
)
101101

102-
def __init__(self):
102+
def __init__(self) -> None:
103103
self.names = dict()
104104

105105
@_("NAME ASSIGN expr")
106-
def statement(self, p):
106+
def statement(self, p) -> None:
107107
self.names[p.NAME] = p.expr
108108

109109
@_("expr")

‎lex_yacc__examples/sly__examples/calc.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class CalcLexer(Lexer):
3333
ignore_newline = r"\n+"
3434

3535
# Extra action for newlines
36-
def ignore_newline(self, t):
36+
def ignore_newline(self, t) -> None:
3737
self.lineno += t.value.count("\n")
3838

39-
def error(self, t):
39+
def error(self, t) -> None:
4040
print(f"Illegal character '{t.value[0]}'")
4141
self.index += 1
4242

@@ -50,11 +50,11 @@ class CalcParser(Parser):
5050
("right", UMINUS),
5151
)
5252

53-
def __init__(self):
53+
def __init__(self) -> None:
5454
self.names = dict()
5555

5656
@_("NAME ASSIGN expr")
57-
def statement(self, p):
57+
def statement(self, p) -> None:
5858
self.names[p.NAME] = p.expr
5959

6060
@_("expr")

‎lex_yacc__examples/sly__examples/key=value.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ class MyLexer(Lexer):
2121
ignore_newline = r"\n+"
2222

2323
# Extra action for newlines
24-
def ignore_newline(self, t):
24+
def ignore_newline(self, t) -> None:
2525
self.lineno += t.value.count("\n")
2626

27-
def error(self, t):
27+
def error(self, t) -> None:
2828
print(f"Illegal character {t.value[0]!r}")
2929
self.index += 1
3030

3131

3232
class MyParser(Parser):
3333
tokens = MyLexer.tokens
3434

35-
def __init__(self):
35+
def __init__(self) -> None:
3636
self.names = dict()
3737

3838
@_("NAME ASSIGN VALUE")
39-
def statement(self, p):
39+
def statement(self, p) -> None:
4040
self.names[p.NAME] = p.VALUE
4141

4242

‎magtu_ru/mgtu_get_students_gui.py‎

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

1919

2020
class Widget(QWidget):
21-
def __init__(self):
21+
def __init__(self) -> None:
2222
super().__init__()
2323

2424
self.lw_dep = QListWidget()
@@ -36,7 +36,7 @@ def __init__(self):
3636

3737
self.setLayout(layout)
3838

39-
def fill(self):
39+
def fill(self) -> None:
4040
self.lw_dep.clear()
4141
rs = requests.get(
4242
"http://magtu.ru/modules/mod_reiting/mobile.php?action=get_all_department"
@@ -51,7 +51,7 @@ def fill(self):
5151
item.setData(Qt.UserRole, id_dep)
5252
self.lw_dep.addItem(item)
5353

54-
def fill_kaf(self, item_dep):
54+
def fill_kaf(self, item_dep) -> None:
5555
self.lw_kaf.clear()
5656

5757
id_dep = item_dep.data(Qt.UserRole)
@@ -68,7 +68,7 @@ def fill_kaf(self, item_dep):
6868
item.setData(Qt.UserRole, id_kaf)
6969
self.lw_kaf.addItem(item)
7070

71-
def fill_stu(self, item_kaf):
71+
def fill_stu(self, item_kaf) -> None:
7272
self.lw_stu.clear()
7373

7474
id_kaf = item_kaf.data(Qt.UserRole)

‎markdown__examples/pyqt5_gui.py‎

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

2525

2626
class MainWindow(QWidget):
27-
def __init__(self):
27+
def __init__(self) -> None:
2828
super().__init__()
2929

3030
self.setWindowTitle(Path(__file__).stem)
@@ -58,7 +58,7 @@ def __init__(self):
5858

5959
self.setLayout(main_layout)
6060

61-
def _on_input_text_markdown(self):
61+
def _on_input_text_markdown(self) -> None:
6262
self.edit_result_qt.setMarkdown(self.edit_markdown.toPlainText())
6363

6464
html = markdown.markdown(self.edit_markdown.toPlainText())

0 commit comments

Comments
 (0)