Skip to content

Commit

Permalink
style: add more type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
YisusChrist committed Sep 16, 2024
1 parent 3a1580a commit 436ccea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions p_pl_dl/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
from argparse import Namespace
from time import sleep

from rich import print
Expand All @@ -14,9 +15,9 @@
from p_pl_dl.utils import exit_session


def main():
def main() -> None:
install(show_locals=DEBUG)
args = get_parsed_args()
args: Namespace = get_parsed_args()
if args.dest:
try:
os.chdir(args.dest)
Expand All @@ -43,10 +44,10 @@ def main():
print(f"Video limit per URL = {nVideoLimit}")

# Load URLs from a file or command-line argument
sLines = load_urls(sSourceUrls, args.url)
sLines: list[str] = load_urls(sSourceUrls, args.url)

# Detect websites from URLs
detected_sites = detect_websites(sLines)
detected_sites: dict[str, str] = detect_websites(sLines)
print("Detected websites:")
print(json.dumps(detected_sites, indent=4))

Expand Down
2 changes: 1 addition & 1 deletion p_pl_dl/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_scrappers_list() -> list[str]:
return scrappers


def detect_websites(urls) -> dict:
def detect_websites(urls) -> dict[str, str]:
scrappers: list[str] = get_scrappers_list()
return {url: site for url in urls for site in scrappers if site in url}

Expand Down
3 changes: 2 additions & 1 deletion p_pl_dl/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import sys
from typing import NoReturn

from rich import print

from p_pl_dl.consts import EXIT_FAILURE, LOG_PATH
from p_pl_dl.logs import logger


def exit_session(exit_value: int) -> None:
def exit_session(exit_value: int) -> NoReturn:
"""
Exit the program with the given exit value.
Expand Down

0 comments on commit 436ccea

Please sign in to comment.