Improve types

This commit is contained in:
Ivan Habunek 2023-12-05 08:15:27 +01:00
parent b9d0c1f7c2
commit 24866bd4e4
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 5 additions and 5 deletions

View File

@ -7,7 +7,7 @@ import unicodedata
import warnings import warnings
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from typing import Dict from typing import Any, Dict
import click import click
@ -111,7 +111,7 @@ Everything below it will be ignored.
""" """
def editor_input(editor: str, initial_text: str): def editor_input(editor: str, initial_text: str) -> str:
"""Lets user input text using an editor.""" """Lets user input text using an editor."""
tmp_path = _tmp_status_path() tmp_path = _tmp_status_path()
initial_text = (initial_text or "") + EDITOR_INPUT_INSTRUCTIONS initial_text = (initial_text or "") + EDITOR_INPUT_INSTRUCTIONS
@ -127,7 +127,7 @@ def editor_input(editor: str, initial_text: str):
return f.read().split(EDITOR_DIVIDER)[0].strip() return f.read().split(EDITOR_DIVIDER)[0].strip()
def delete_tmp_status_file(): def delete_tmp_status_file() -> None:
try: try:
os.unlink(_tmp_status_path()) os.unlink(_tmp_status_path())
except FileNotFoundError: except FileNotFoundError:
@ -150,12 +150,12 @@ def _use_existing_tmp_file(tmp_path: str) -> bool:
return False return False
def drop_empty_values(data: Dict) -> Dict: def drop_empty_values(data: Dict[Any, Any]) -> Dict[Any, Any]:
"""Remove keys whose values are null""" """Remove keys whose values are null"""
return {k: v for k, v in data.items() if v is not None} return {k: v for k, v in data.items() if v is not None}
def urlencode_url(url): def urlencode_url(url: str) -> str:
parsed_url = urlparse(url) parsed_url = urlparse(url)
# unencode before encoding, to prevent double-urlencoding # unencode before encoding, to prevent double-urlencoding