diff --git a/pyproject.toml b/pyproject.toml index 4b7e3b6..de221c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,11 +13,9 @@ classifiers = [ "Operating System :: MacOS", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Typing :: Typed", ] -requires-python = ">= 3.9" +requires-python = ">= 3.11" dependencies = ["click", "xdg-base-dirs"] [project.urls] @@ -45,10 +43,6 @@ warn_unused_ignores = true module = "tests.*" disallow_untyped_defs = false -[tool.ruff] -src = ["src", "test"] -target-version = "py39" - [tool.ruff.lint] select = [ "E", diff --git a/src/qbpm/__init__.py b/src/qbpm/__init__.py index 34b2b32..cd0b417 100644 --- a/src/qbpm/__init__.py +++ b/src/qbpm/__init__.py @@ -16,7 +16,7 @@ class Profile: profile_dir: Path root: Path - def __init__(self, name: str, profile_dir: Optional[Path]) -> None: + def __init__(self, name: str, profile_dir: Path | None) -> None: self.name = name self.profile_dir = profile_dir or (xdg_data_home() / "qutebrowser-profiles") self.root = self.profile_dir / name diff --git a/src/qbpm/desktop.py b/src/qbpm/desktop.py index 08aadcc..c6f2038 100644 --- a/src/qbpm/desktop.py +++ b/src/qbpm/desktop.py @@ -1,6 +1,5 @@ import textwrap from pathlib import Path -from typing import Optional from xdg_base_dirs import xdg_data_home @@ -23,7 +22,7 @@ MIME_TYPES = [ # TODO expose application_dir through config def create_desktop_file( - profile: Profile, application_dir: Optional[Path] = None + profile: Profile, application_dir: Path | None = None ) -> None: text = textwrap.dedent(f"""\ [Desktop Entry] diff --git a/src/qbpm/main.py b/src/qbpm/main.py index a6a52d1..ea9a4d2 100644 --- a/src/qbpm/main.py +++ b/src/qbpm/main.py @@ -1,8 +1,9 @@ import logging import sys +from collections.abc import Callable from dataclasses import dataclass from pathlib import Path -from typing import Any, Callable, NoReturn, Optional +from typing import Any, NoReturn import click @@ -105,7 +106,7 @@ def new(context: Context, profile_name: str, **kwargs: Any) -> None: def from_session( context: Context, session: str, - profile_name: Optional[str], + profile_name: str | None, **kwargs: Any, ) -> None: """Create a new profile from a saved qutebrowser session. @@ -196,7 +197,7 @@ def then_launch( def session_info( - session: str, profile_name: Optional[str], context: Context + session: str, profile_name: str | None, context: Context ) -> tuple[Profile, Path]: user_session_dir = user_data_dir() / "sessions" session_paths = [] diff --git a/src/qbpm/operations.py b/src/qbpm/operations.py index 90eaa2a..0ea97f1 100644 --- a/src/qbpm/operations.py +++ b/src/qbpm/operations.py @@ -3,7 +3,6 @@ import subprocess from collections.abc import Iterable from pathlib import Path from sys import platform -from typing import Optional from . import Profile, profiles from .desktop import create_desktop_file @@ -13,7 +12,7 @@ from .utils import env_menus, error, installed_menus, or_phrase, qutebrowser_exe def from_session( profile: Profile, session_path: Path, - qb_config_dir: Optional[Path], + qb_config_dir: Path | None, desktop_file: bool = True, overwrite: bool = False, ) -> bool: @@ -68,7 +67,7 @@ def desktop(profile: Profile) -> bool: def choose( - profile_dir: Path, menu: Optional[str], foreground: bool, qb_args: tuple[str, ...] + profile_dir: Path, menu: str | None, foreground: bool, qb_args: tuple[str, ...] ) -> bool: menu = menu or next(installed_menus(), None) if not menu: @@ -112,7 +111,7 @@ def choose( def menu_command( menu: str, profiles: Iterable[str], qb_args: tuple[str, ...] -) -> Optional[str]: +) -> str | None: profiles = sorted(profiles) arg_string = " ".join(qb_args) if menu == "applescript": diff --git a/src/qbpm/profiles.py b/src/qbpm/profiles.py index 2d034a2..4a0978c 100644 --- a/src/qbpm/profiles.py +++ b/src/qbpm/profiles.py @@ -1,7 +1,6 @@ from functools import partial from pathlib import Path from sys import platform -from typing import Optional from . import Profile from .desktop import create_desktop_file @@ -39,7 +38,7 @@ def create_profile(profile: Profile, overwrite: bool = False) -> bool: def create_config( profile: Profile, qb_config_dir: Path, - home_page: Optional[str] = None, + home_page: str | None = None, overwrite: bool = False, ) -> None: user_config = profile.root / "config" / "config.py" @@ -67,9 +66,9 @@ def exists(profile: Profile) -> bool: def new_profile( profile: Profile, - qb_config_dir: Optional[Path], - home_page: Optional[str] = None, - desktop_file: Optional[bool] = None, + qb_config_dir: Path | None, + home_page: str | None = None, + desktop_file: bool | None = None, overwrite: bool = False, ) -> bool: qb_config_dir = resolve_qb_config_dir(qb_config_dir) @@ -83,7 +82,7 @@ def new_profile( return False -def resolve_qb_config_dir(qb_config_dir: Optional[Path]) -> Optional[Path]: +def resolve_qb_config_dir(qb_config_dir: Path | None) -> Path | None: config_file = "config.py" dirs = ( [qb_config_dir, qb_config_dir / "config"] diff --git a/tests/test_profiles.py b/tests/test_profiles.py index 7388050..98a4502 100644 --- a/tests/test_profiles.py +++ b/tests/test_profiles.py @@ -1,5 +1,4 @@ from pathlib import Path -from typing import Optional from qbpm import profiles from qbpm.profiles import Profile @@ -9,7 +8,7 @@ def check_is_empty(path: Path): assert len(list(path.iterdir())) == 0 -def check_empty_profile(profile: Optional[Profile]): +def check_empty_profile(profile: Profile | None): assert profile config_dir = profile.root / "config" assert list(profile.root.iterdir()) == [config_dir]