Remove types in docstring to reduce clutter

This commit is contained in:
2022-07-15 16:20:33 +02:00
parent f92a5f838a
commit 6de97dad73
5 changed files with 19 additions and 20 deletions

View File

@ -24,14 +24,14 @@ def generate_html_for_videos(
"""Generate HTML for video files. """Generate HTML for video files.
Args: Args:
url (str): URL for the video. This is accessible from the browser. url: URL for the video. This is accessible from the browser.
width (int): This is the width of the video. width: This is the width of the video.
height (int): This is the height of the video. height: This is the height of the video.
screenshot (str): URL for screenshot. screenshot: URL for screenshot.
filename (str): Original video filename. filename: Original video filename.
Returns: Returns:
str: Returns HTML for video. Returns HTML for video.
""" """
video_html = f""" video_html = f"""
<!DOCTYPE html> <!DOCTYPE html>

View File

@ -1,5 +1,5 @@
"""Our site has one POST endpoint for uploading videos and one GET """Our site has one POST endpoint for uploading videos and one GET
endpoint for getting the HTML. Images are served from a webserver.""" endpoint for getting the HTML. Images are served from a web server."""
from typing import Dict from typing import Dict
from urllib.parse import urljoin from urllib.parse import urljoin
@ -40,11 +40,10 @@ async def upload_file(file: UploadFile = File(...)) -> Dict[str, str]:
If something goes wrong, we will send a message to Discord. If something goes wrong, we will send a message to Discord.
Args: Args:
file (UploadFile): Our uploaded file. file: Our uploaded file.
Returns: Returns:
Dict[str, str]: Returns a dict with the filename or a link to Returns a dict with the filename or a link to the .html if it was a video.
the .html if it was a video.
""" """
domain_url = "" domain_url = ""
if file.content_type.startswith("video/"): if file.content_type.startswith("video/"):

View File

@ -10,10 +10,10 @@ def video_resolution(path_to_video: str) -> tuple[int, int]:
"""Find video resolution. """Find video resolution.
Args: Args:
path_to_video (str): Path to video file. path_to_video: Path to video file.
Returns: Returns:
tuple[int, int]: Returns height and width. Returns height and width.
""" """
probe = ffmpeg.probe(path_to_video) probe = ffmpeg.probe(path_to_video)
video_stream = next((stream for stream in probe["streams"] if stream["codec_type"] == "video"), None) video_stream = next((stream for stream in probe["streams"] if stream["codec_type"] == "video"), None)
@ -31,11 +31,11 @@ def make_thumbnail(path_video: str, file_filename: str) -> str:
"""Make thumbnail for Discord. This is a screenshot of the video. """Make thumbnail for Discord. This is a screenshot of the video.
Args: Args:
path_video (str): Path where video file is stored. path_video: Path where video file is stored.
file_filename (str): File name for URL. file_filename: File name for URL.
Returns: Returns:
str: Returns thumbnail filename. Returns thumbnail filename.
""" """
( (
ffmpeg.input(path_video, ss="1") ffmpeg.input(path_video, ss="1")

View File

@ -17,10 +17,10 @@ def save_to_disk(file: UploadFile) -> tuple[str, str]:
If spaces in filename, replace with dots. If spaces in filename, replace with dots.
Args: Args:
file (UploadFile): Our file object. file: Our uploaded file.
Returns: Returns:
tuple[str, str]: Returns filename and file location. Returns filename and file location.
""" """
# Create folder if it doesn't exist. # Create folder if it doesn't exist.
folder_video = os.path.join(settings.upload_folder, "video") folder_video = os.path.join(settings.upload_folder, "video")
@ -41,10 +41,10 @@ async def do_things(file: UploadFile) -> Dict[str, str]:
"""Save video to disk, generate HTML, thumbnail, and return a .html URL. """Save video to disk, generate HTML, thumbnail, and return a .html URL.
Args: Args:
file (UploadFile): Our file object. file: Our uploaded file.
Returns: Returns:
Dict[str, str]: Returns URL for video. Returns URL for video.
""" """
filename, file_location = save_to_disk(file) filename, file_location = save_to_disk(file)

View File

@ -8,7 +8,7 @@ def send_webhook(message: str) -> None:
"""Send webhook to Discord. """Send webhook to Discord.
Args: Args:
message (str): The message to send. message: The message to send.
""" """
webhook = DiscordWebhook( webhook = DiscordWebhook(
url=settings.webhook_url, url=settings.webhook_url,