Skip to content

Commit 0931e3c

Browse files
committed
Refactoring. html_parsing/. Adding the None annotation to the return value
1 parent f134874 commit 0931e3c

33 files changed

Lines changed: 58 additions & 58 deletions

File tree

‎html_parsing/Time_magazine_covers/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def dump_covers(
9292
out_dir="out",
9393
need_zip=False,
9494
remove_out_covers=False,
95-
):
95+
) -> None:
9696
covers = get_covers(year)
9797
out_dir = normpath(abspath(out_dir + f"/{year}"))
9898

‎html_parsing/encyclopedia_perumov_club__category__dose/db.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
DB_FILE_NAME = str(pathlib.Path(__file__).resolve().parent / "database.sqlite")
2121

2222

23-
def db_create_backup(backup_dir="backup"):
23+
def db_create_backup(backup_dir="backup") -> None:
2424
os.makedirs(backup_dir, exist_ok=True)
2525

2626
file_name = str(dt.datetime.today().date()) + ".sqlite"
@@ -43,7 +43,7 @@ class Dossier(BaseModel):
4343
url = TextField(unique=True)
4444
date = DateField(default=dt.date.today)
4545

46-
def __str__(self):
46+
def __str__(self) -> str:
4747
return (
4848
f"{self.__class__.__name__}(id={self.id}, title={self.title!r}, date={self.date}, "
4949
f"url={self.url!r}, total_items={len(self.items)})"
@@ -55,7 +55,7 @@ class QuestionAnswer(BaseModel):
5555
question_text = TextField()
5656
answer_text = TextField()
5757

58-
def __str__(self):
58+
def __str__(self) -> str:
5959
return (
6060
f"{self.__class__.__name__}(id={self.id}, dossier_id={self.dossier.id}, "
6161
f"question_text={shorten(self.question_text)!r}), answer_text={shorten(self.answer_text)!r})"

‎html_parsing/encyclopedia_perumov_club__category__dose/gui.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_table_widget(header_labels: list) -> QTableWidget:
6767

6868

6969
class MainWindow(QMainWindow):
70-
def __init__(self):
70+
def __init__(self) -> None:
7171
super().__init__()
7272

7373
self.filter_le = QLineEdit()
@@ -123,7 +123,7 @@ def _get_search_pattern(self):
123123
except:
124124
pass
125125

126-
def fill(self):
126+
def fill(self) -> None:
127127
# Удаление строк таблицы
128128
while self.table_dossier.rowCount():
129129
self.table_dossier.removeRow(0)
@@ -155,7 +155,7 @@ def fill(self):
155155
self.table_dossier.setCurrentCell(0, 0)
156156
self._on_table_dossier_item_clicked()
157157

158-
def _on_table_dossier_item_clicked(self):
158+
def _on_table_dossier_item_clicked(self) -> None:
159159
# Удаление строк таблицы
160160
while self.table_items.rowCount():
161161
self.table_items.removeRow(0)
@@ -199,7 +199,7 @@ def _on_table_dossier_item_clicked(self):
199199
self.table_items.setCurrentCell(0, 0)
200200
self._on_table_items_item_clicked()
201201

202-
def _on_table_items_item_clicked(self):
202+
def _on_table_items_item_clicked(self) -> None:
203203
item = self.table_items.currentItem()
204204
if not item:
205205
return

‎html_parsing/foxtrot_com_ua__ru__search/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def save_goods(
7878
file_name: str | Path,
7979
items: list[tuple[str, str, str]],
8080
encoding="utf-8",
81-
):
81+
) -> None:
8282
df = pd.DataFrame(items, columns=["Name", "Price", "Nal"])
8383
df.to_csv(file_name, encoding=encoding)
8484

‎html_parsing/get_price_game/from_gama-gama.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Основа взята из http://stackoverflow.com/a/37755811/5909792
1717
def get_html(url):
1818
class ExtractorHtml:
19-
def __init__(self, url):
19+
def __init__(self, url) -> None:
2020
_app = QApplication([])
2121
self._page = QWebEnginePage()
2222
self._page.loadFinished.connect(self._load_finished_handler)
@@ -40,10 +40,10 @@ def __init__(self, url):
4040
# Чтобы избежать падений скрипта
4141
self._page = None
4242

43-
def _callable(self, data):
43+
def _callable(self, data) -> None:
4444
self.html = data
4545

46-
def _load_finished_handler(self, _):
46+
def _load_finished_handler(self, _) -> None:
4747
self._counter_finished += 1
4848

4949
if self._counter_finished == 2:

‎html_parsing/get_price_game/from_origin.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Основа взята из http://stackoverflow.com/a/37755811/5909792
1515
def get_html(url):
1616
class ExtractorHtml:
17-
def __init__(self, url):
17+
def __init__(self, url) -> None:
1818
_app = QApplication([])
1919
self._page = QWebEnginePage()
2020

@@ -43,10 +43,10 @@ def __init__(self, url):
4343

4444
self._page = None
4545

46-
def _callable(self, data):
46+
def _callable(self, data) -> None:
4747
self.html = data
4848

49-
def _load_finished_handler(self):
49+
def _load_finished_handler(self) -> None:
5050
self._page.toHtml(self._callable)
5151

5252
return ExtractorHtml(url).html

‎html_parsing/get_video_list__xcadr.com.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_video_list(url) -> list[dict]:
5454
items = get_video_list("http://xcadr.com/collection/luchshie-sceny-v-bane/")
5555
print("Total:", len(items))
5656

57-
def print_items(items):
57+
def print_items(items) -> None:
5858
for i, item in enumerate(items, 1):
5959
print(
6060
'{0:2}. "{title}" ({duration} secs, rating: {rating}): {url} [{url_thumb}]'.format(

‎html_parsing/gitmanga_com__get_chapters.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_chapters(url: str) -> list[Chapter]:
3939

4040
if __name__ == "__main__":
4141

42-
def print_chapter(items: list[Chapter]):
42+
def print_chapter(items: list[Chapter]) -> None:
4343
print(f"Chapters ({len(items)}):")
4444
print(f" {items[0]}")
4545
print(" ...")

‎html_parsing/howlongtobeat_com/common.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Game:
4343

4444
profile_genres: list[str] = field(default_factory=list)
4545

46-
def __post_init__(self):
46+
def __post_init__(self) -> None:
4747
self.duration_main_title = seconds_to_str(self.duration_main_seconds)
4848
self.duration_plus_title = seconds_to_str(self.duration_plus_seconds)
4949
self.duration_100_title = seconds_to_str(self.duration_100_seconds)

‎html_parsing/https___lavkagsm_ru__example/gui.py‎

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

1212

1313
class MainWindow(QMainWindow):
14-
def __init__(self):
14+
def __init__(self) -> None:
1515
super().__init__()
1616

1717
headers = ["NAME", "PRICE", "ARTICLE", "URL", "PHOTO_URL"]
@@ -26,7 +26,7 @@ def __init__(self):
2626

2727
self.setCentralWidget(self.table_widget)
2828

29-
def fill(self):
29+
def fill(self) -> None:
3030
url = "https://lavkagsm.ru/catalog/mikroskhemy/?view=blocks&page_count=48&sort=name&by=asc"
3131
html_content = get_html_by_url__from_cache(url)
3232
root = BeautifulSoup(html_content, "html.parser")
@@ -44,7 +44,7 @@ def fill(self):
4444
self.table_widget.resizeColumnToContents(0)
4545
self.table_widget.resizeColumnToContents(1)
4646

47-
def _on_item_double_click(self, item):
47+
def _on_item_double_click(self, item) -> None:
4848
row = item.row()
4949

5050
item_url = self.table_widget.item(row, 3)

0 commit comments

Comments
 (0)