From 6de97dad730e8ab0750560304374b3cfd7629ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= <tlovinator@gmail.com> Date: Fri, 15 Jul 2022 16:20:33 +0200 Subject: [PATCH] Remove types in docstring to reduce clutter --- discord_embed/generate_html.py | 12 ++++++------ discord_embed/main.py | 7 +++---- discord_embed/video.py | 10 +++++----- discord_embed/video_file_upload.py | 8 ++++---- discord_embed/webhook.py | 2 +- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/discord_embed/generate_html.py b/discord_embed/generate_html.py index d1a392b..aa9901e 100644 --- a/discord_embed/generate_html.py +++ b/discord_embed/generate_html.py @@ -24,14 +24,14 @@ def generate_html_for_videos( """Generate HTML for video files. Args: - url (str): URL for the video. This is accessible from the browser. - width (int): This is the width of the video. - height (int): This is the height of the video. - screenshot (str): URL for screenshot. - filename (str): Original video filename. + url: URL for the video. This is accessible from the browser. + width: This is the width of the video. + height: This is the height of the video. + screenshot: URL for screenshot. + filename: Original video filename. Returns: - str: Returns HTML for video. + Returns HTML for video. """ video_html = f""" <!DOCTYPE html> diff --git a/discord_embed/main.py b/discord_embed/main.py index 55b755f..3464176 100644 --- a/discord_embed/main.py +++ b/discord_embed/main.py @@ -1,5 +1,5 @@ """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 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. Args: - file (UploadFile): Our uploaded file. + file: Our uploaded file. Returns: - Dict[str, str]: Returns a dict with the filename or a link to - the .html if it was a video. + Returns a dict with the filename or a link to the .html if it was a video. """ domain_url = "" if file.content_type.startswith("video/"): diff --git a/discord_embed/video.py b/discord_embed/video.py index 833fd45..41c0c31 100644 --- a/discord_embed/video.py +++ b/discord_embed/video.py @@ -10,10 +10,10 @@ def video_resolution(path_to_video: str) -> tuple[int, int]: """Find video resolution. Args: - path_to_video (str): Path to video file. + path_to_video: Path to video file. Returns: - tuple[int, int]: Returns height and width. + Returns height and width. """ probe = ffmpeg.probe(path_to_video) 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. Args: - path_video (str): Path where video file is stored. - file_filename (str): File name for URL. + path_video: Path where video file is stored. + file_filename: File name for URL. Returns: - str: Returns thumbnail filename. + Returns thumbnail filename. """ ( ffmpeg.input(path_video, ss="1") diff --git a/discord_embed/video_file_upload.py b/discord_embed/video_file_upload.py index 11e217e..fa89c27 100644 --- a/discord_embed/video_file_upload.py +++ b/discord_embed/video_file_upload.py @@ -17,10 +17,10 @@ def save_to_disk(file: UploadFile) -> tuple[str, str]: If spaces in filename, replace with dots. Args: - file (UploadFile): Our file object. + file: Our uploaded file. Returns: - tuple[str, str]: Returns filename and file location. + Returns filename and file location. """ # Create folder if it doesn't exist. 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. Args: - file (UploadFile): Our file object. + file: Our uploaded file. Returns: - Dict[str, str]: Returns URL for video. + Returns URL for video. """ filename, file_location = save_to_disk(file) diff --git a/discord_embed/webhook.py b/discord_embed/webhook.py index ae2647c..4bc4930 100644 --- a/discord_embed/webhook.py +++ b/discord_embed/webhook.py @@ -8,7 +8,7 @@ def send_webhook(message: str) -> None: """Send webhook to Discord. Args: - message (str): The message to send. + message: The message to send. """ webhook = DiscordWebhook( url=settings.webhook_url,