Core: Update Some Outdated Typing (#4986)

This commit is contained in:
Nicholas Saylor
2025-05-14 07:40:38 -04:00
committed by GitHub
parent a87fec0cbd
commit 02fd75c018
6 changed files with 77 additions and 79 deletions

View File

@@ -16,9 +16,10 @@ import subprocess
import sys
import urllib.parse
import webbrowser
from collections.abc import Callable, Sequence
from os.path import isfile
from shutil import which
from typing import Callable, Optional, Sequence, Tuple, Union, Any
from typing import Any
if __name__ == "__main__":
import ModuleUpdate
@@ -114,7 +115,7 @@ components.extend([
])
def handle_uri(path: str, launch_args: Tuple[str, ...]) -> None:
def handle_uri(path: str, launch_args: tuple[str, ...]) -> None:
url = urllib.parse.urlparse(path)
queries = urllib.parse.parse_qs(url.query)
launch_args = (path, *launch_args)
@@ -162,7 +163,7 @@ def handle_uri(path: str, launch_args: Tuple[str, ...]) -> None:
).open()
def identify(path: Union[None, str]) -> Tuple[Union[None, str], Union[None, Component]]:
def identify(path: None | str) -> tuple[None | str, None | Component]:
if path is None:
return None, None
for component in components:
@@ -173,7 +174,7 @@ def identify(path: Union[None, str]) -> Tuple[Union[None, str], Union[None, Comp
return None, None
def get_exe(component: Union[str, Component]) -> Optional[Sequence[str]]:
def get_exe(component: str | Component) -> Sequence[str] | None:
if isinstance(component, str):
name = component
component = None
@@ -226,7 +227,7 @@ def create_shortcut(button: Any, component: Component) -> None:
button.menu.dismiss()
refresh_components: Optional[Callable[[], None]] = None
refresh_components: Callable[[], None] | None = None
def run_gui(path: str, args: Any) -> None:
@@ -451,7 +452,7 @@ def run_component(component: Component, *args):
logging.warning(f"Component {component} does not appear to be executable.")
def main(args: Optional[Union[argparse.Namespace, dict]] = None):
def main(args: argparse.Namespace | dict | None = None):
if isinstance(args, argparse.Namespace):
args = {k: v for k, v in args._get_kwargs()}
elif not args: