Skip to content

Commit 84e2187

Browse files
committed
Refactoring. Adding the None annotation to the return value
1 parent 9b9a891 commit 84e2187

11 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎websocket__examples/echo_client__using_websockets.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import websockets
1414

1515

16-
async def hello(url: str):
16+
async def hello(url: str) -> None:
1717
async with websockets.connect(url) as websocket:
1818
await websocket.send("Hello World!")
1919

‎websocket__examples/using__websocket-client/echo_client__long_lived_connection.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
import websocket
1919

2020

21-
def on_open(ws: websocket.WebSocketApp):
21+
def on_open(ws: websocket.WebSocketApp) -> None:
2222
print(f"[on_open]")
2323

24-
def run(*args):
24+
def run(*args) -> None:
2525
for i in range(3):
2626
time.sleep(1)
2727
ws.send(f"Hello {i}")
@@ -34,19 +34,19 @@ def run(*args):
3434
thread.start_new_thread(run, ())
3535

3636

37-
def on_message(ws: websocket.WebSocketApp, message: str):
37+
def on_message(ws: websocket.WebSocketApp, message: str) -> None:
3838
print(f"[on_message] {message}")
3939

4040

41-
def on_error(ws: websocket.WebSocketApp, error: Exception):
41+
def on_error(ws: websocket.WebSocketApp, error: Exception) -> None:
4242
print(f"[on_error] {error}")
4343

4444

4545
def on_close(
4646
ws: websocket.WebSocketApp,
4747
close_status_code: int | None,
4848
close_msg: str | None,
49-
):
49+
) -> None:
5050
print(f"[on_close] close_status_code={close_status_code} close_msg={close_msg}")
5151

5252

‎winreg__examples/common.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_key(path: str) -> Optional[HKEYType]:
5656

5757

5858
class RegistryValue:
59-
def __init__(self, name: str, value_type: int, value: Any):
59+
def __init__(self, name: str, value_type: int, value: Any) -> None:
6060
self.name: str = name
6161

6262
self.value_type: int = value_type
@@ -72,7 +72,7 @@ def __repr__(self) -> str:
7272

7373

7474
class RegistryKey:
75-
def __init__(self, path: str):
75+
def __init__(self, path: str) -> None:
7676
path = expand_path(path)
7777

7878
self.hkey: HKEYType = get_key(path)

‎winreg__examples/exceptions.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class RegistryException(Exception):
99

1010

1111
class RegistryKeyNotFoundException(RegistryException):
12-
def __init__(self, path: str):
12+
def __init__(self, path: str) -> None:
1313
self.path = path
1414

1515
super().__init__(f"Registry key not found, path='{self.path}'")
1616

1717

1818
class RegistryValueNotFoundException(RegistryException):
19-
def __init__(self, path: str, name: str):
19+
def __init__(self, path: str, name: str) -> None:
2020
self.path = path
2121
self.name = name
2222

‎winreg__examples/get_active_setup_installed_components.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def get_active_setup_components(exists_stub_path=True) -> dict[str, list[Compone
7373

7474
if __name__ == "__main__":
7575

76-
def _print_this(path_by_components: dict[str, list[Component]]):
76+
def _print_this(path_by_components: dict[str, list[Component]]) -> None:
7777
for path, components in path_by_components.items():
7878
print(f"{path} ({len(components)}):")
7979
for component in components:

‎word_to_emoji/db.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class BaseModel(Model):
5454
class Meta:
5555
database = db
5656

57-
def __str__(self):
57+
def __str__(self) -> str:
5858
fields = []
5959
for k, field in self._meta.fields.items():
6060
v = getattr(self, k)
@@ -78,7 +78,7 @@ class Word2Emoji(BaseModel):
7878
emoji = TextField(null=True)
7979

8080
@classmethod
81-
def add(cls, word: str, emoji: str = None, convert_to_normal_form=True):
81+
def add(cls, word: str, emoji: str = None, convert_to_normal_form=True) -> None:
8282
word = word.strip()
8383
if convert_to_normal_form:
8484
word = get_normal_form(word)

‎xml_html__xpath__css_selector__gui/main.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def to_str(el: "Element") -> str:
3737
return str(el)
3838

3939

40-
def log_uncaught_exceptions(ex_cls, ex, tb):
40+
def log_uncaught_exceptions(ex_cls, ex, tb) -> None:
4141
text = f"{ex_cls.__name__}: {ex}:\n"
4242
text += "".join(traceback.format_tb(tb))
4343

@@ -50,7 +50,7 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
5050

5151

5252
class MainWindow(QWidget):
53-
def __init__(self):
53+
def __init__(self) -> None:
5454
super().__init__()
5555

5656
self.setWindowTitle("xml_html__xpath__css_selector__gui")
@@ -123,7 +123,7 @@ def __init__(self):
123123

124124
self.setLayout(layout)
125125

126-
def on_process(self):
126+
def on_process(self) -> None:
127127
self.text_edit_output.clear()
128128
self.label_error.clear()
129129
self.button_detail_error.hide()
@@ -170,7 +170,7 @@ def on_process(self):
170170

171171
self.label_error.setText("Error: " + self.last_error_message)
172172

173-
def show_detail_error_message(self):
173+
def show_detail_error_message(self) -> None:
174174
message = self.last_error_message + "\n\n" + self.last_detail_error_message
175175

176176
mb = QErrorMessage()

‎zip_file_example/append_directory/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import zipfile
99

1010

11-
def make_zipfile(source_dir, output_filename):
11+
def make_zipfile(source_dir, output_filename) -> None:
1212
relroot = os.path.abspath(os.path.join(source_dir, os.pardir))
1313
with zipfile.ZipFile(output_filename, "w", zipfile.ZIP_DEFLATED) as zip:
1414
for root, dirs, files in os.walk(source_dir):

‎zip_file_example/download_volume_readmanga.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_url_images(url):
4040
)
4141

4242

43-
def save_urls_to_zip(zip_file_name, urls):
43+
def save_urls_to_zip(zip_file_name, urls) -> None:
4444
if not urls:
4545
print("Cписок изображений пустой.")
4646
return

‎zip_file_example/remove_unnecessary_files_from_xpi_zip_file/remove_all_but_included_files_from_xpi_zip_file.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def create_parser():
3232
return parser.parse_args()
3333

3434

35-
def do(zip_file_name, include):
35+
def do(zip_file_name, include) -> None:
3636
print("zip_file_name:", zip_file_name)
3737
print("Include files:", include)
3838

0 commit comments

Comments
 (0)