mypy fixes

This commit is contained in:
Seaswimmer 2024-11-29 06:35:15 -05:00
parent 6838797fdf
commit 64259596ff
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087
2 changed files with 13 additions and 9 deletions

View file

@ -8,7 +8,7 @@ import tempfile
from pathlib import Path from pathlib import Path
from shutil import which from shutil import which
from common.common import notify from common.common import notify # type: ignore
def spectacle_screenshot( def spectacle_screenshot(
@ -27,7 +27,7 @@ def spectacle_screenshot(
use_temp_file = True use_temp_file = True
suffix = ".webm" if record else ".png" suffix = ".webm" if record else ".png"
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix) temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
file_path = temp_file.name file_path = Path(temp_file.name)
temp_file.close() temp_file.close()
else: else:
use_temp_file = False use_temp_file = False
@ -48,7 +48,7 @@ def spectacle_screenshot(
command.append("--region") command.append("--region")
try: try:
subprocess.run(command, check=True) subprocess.run(command, check=True) # type: ignore
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
if Path(file_path).exists() and use_temp_file: if Path(file_path).exists() and use_temp_file:
os.remove(file_path) os.remove(file_path)
@ -69,7 +69,7 @@ def spectacle_screenshot(
] ]
if url: if url:
opts.extend(["--url", url]) opts.extend(["--url", url])
subprocess.run(opts) subprocess.run(opts) # type: ignore
finally: finally:
if Path(file_path).exists() and use_temp_file: if Path(file_path).exists() and use_temp_file:
os.remove(file_path) os.remove(file_path)
@ -78,7 +78,7 @@ def spectacle_screenshot(
application_name="Spectacle", application_name="Spectacle",
title="An error occurred", title="An error occurred",
message=str(e), message=str(e),
urgency="critical", urgency="normal",
category="transfer.error", category="transfer.error",
desktop_entry="org.kde.spectacle", desktop_entry="org.kde.spectacle",
) )

View file

@ -9,15 +9,19 @@ from shutil import which
from typing import Any from typing import Any
import requests # type: ignore import requests # type: ignore
from common.common import does_desktop_entry_exist, notify, read_secret_file from common.common import ( # type: ignore
does_desktop_entry_exist,
notify,
read_secret_file,
)
from pyperclip import copy # type: ignore from pyperclip import copy # type: ignore
def zipline( def zipline(
file_path: Path, file_path: Path,
instance_url: str, instance_url: str,
application_name: str = None, application_name: str | None = None,
desktop_entry: str = None, desktop_entry: str | None = None,
) -> Any: ) -> Any:
token = read_secret_file("zipline") token = read_secret_file("zipline")
@ -72,7 +76,7 @@ def zipline(
application_name=application_name, application_name=application_name,
title="Upload Failed", title="Upload Failed",
message=f"An error occurred: {e}", message=f"An error occurred: {e}",
urgency="critical", urgency="normal",
category="transfer.error", category="transfer.error",
icon=file_path, icon=file_path,
) )