Skip to content

Commit 5510d8a

Browse files
committed
require python 3.11, replace Optional with unions
1 parent 952055e commit 5510d8a

File tree

7 files changed

+16
-25
lines changed

7 files changed

+16
-25
lines changed

pyproject.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ classifiers = [
1313
"Operating System :: MacOS",
1414
"Operating System :: POSIX :: Linux",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.9",
17-
"Programming Language :: Python :: 3.10",
1816
"Typing :: Typed",
1917
]
20-
requires-python = ">= 3.9"
18+
requires-python = ">= 3.11"
2119
dependencies = ["click", "xdg-base-dirs"]
2220

2321
[project.urls]
@@ -45,10 +43,6 @@ warn_unused_ignores = true
4543
module = "tests.*"
4644
disallow_untyped_defs = false
4745

48-
[tool.ruff]
49-
src = ["src", "test"]
50-
target-version = "py39"
51-
5246
[tool.ruff.lint]
5347
select = [
5448
"E",

src/qbpm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Profile:
1616
profile_dir: Path
1717
root: Path
1818

19-
def __init__(self, name: str, profile_dir: Optional[Path]) -> None:
19+
def __init__(self, name: str, profile_dir: Path | None) -> None:
2020
self.name = name
2121
self.profile_dir = profile_dir or (xdg_data_home() / "qutebrowser-profiles")
2222
self.root = self.profile_dir / name

src/qbpm/desktop.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import textwrap
22
from pathlib import Path
3-
from typing import Optional
43

54
from xdg_base_dirs import xdg_data_home
65

@@ -23,7 +22,7 @@
2322

2423
# TODO expose application_dir through config
2524
def create_desktop_file(
26-
profile: Profile, application_dir: Optional[Path] = None
25+
profile: Profile, application_dir: Path | None = None
2726
) -> None:
2827
text = textwrap.dedent(f"""\
2928
[Desktop Entry]

src/qbpm/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import logging
22
import sys
3+
from collections.abc import Callable
34
from dataclasses import dataclass
45
from pathlib import Path
5-
from typing import Any, Callable, NoReturn, Optional
6+
from typing import Any, NoReturn
67

78
import click
89

@@ -105,7 +106,7 @@ def new(context: Context, profile_name: str, **kwargs: Any) -> None:
105106
def from_session(
106107
context: Context,
107108
session: str,
108-
profile_name: Optional[str],
109+
profile_name: str | None,
109110
**kwargs: Any,
110111
) -> None:
111112
"""Create a new profile from a saved qutebrowser session.
@@ -196,7 +197,7 @@ def then_launch(
196197

197198

198199
def session_info(
199-
session: str, profile_name: Optional[str], context: Context
200+
session: str, profile_name: str | None, context: Context
200201
) -> tuple[Profile, Path]:
201202
user_session_dir = user_data_dir() / "sessions"
202203
session_paths = []

src/qbpm/operations.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from collections.abc import Iterable
44
from pathlib import Path
55
from sys import platform
6-
from typing import Optional
76

87
from . import Profile, profiles
98
from .desktop import create_desktop_file
@@ -13,7 +12,7 @@
1312
def from_session(
1413
profile: Profile,
1514
session_path: Path,
16-
qb_config_dir: Optional[Path],
15+
qb_config_dir: Path | None,
1716
desktop_file: bool = True,
1817
overwrite: bool = False,
1918
) -> bool:
@@ -68,7 +67,7 @@ def desktop(profile: Profile) -> bool:
6867

6968

7069
def choose(
71-
profile_dir: Path, menu: Optional[str], foreground: bool, qb_args: tuple[str, ...]
70+
profile_dir: Path, menu: str | None, foreground: bool, qb_args: tuple[str, ...]
7271
) -> bool:
7372
menu = menu or next(installed_menus(), None)
7473
if not menu:
@@ -112,7 +111,7 @@ def choose(
112111

113112
def menu_command(
114113
menu: str, profiles: Iterable[str], qb_args: tuple[str, ...]
115-
) -> Optional[str]:
114+
) -> str | None:
116115
profiles = sorted(profiles)
117116
arg_string = " ".join(qb_args)
118117
if menu == "applescript":

src/qbpm/profiles.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from functools import partial
22
from pathlib import Path
33
from sys import platform
4-
from typing import Optional
54

65
from . import Profile
76
from .desktop import create_desktop_file
@@ -39,7 +38,7 @@ def create_profile(profile: Profile, overwrite: bool = False) -> bool:
3938
def create_config(
4039
profile: Profile,
4140
qb_config_dir: Path,
42-
home_page: Optional[str] = None,
41+
home_page: str | None = None,
4342
overwrite: bool = False,
4443
) -> None:
4544
user_config = profile.root / "config" / "config.py"
@@ -67,9 +66,9 @@ def exists(profile: Profile) -> bool:
6766

6867
def new_profile(
6968
profile: Profile,
70-
qb_config_dir: Optional[Path],
71-
home_page: Optional[str] = None,
72-
desktop_file: Optional[bool] = None,
69+
qb_config_dir: Path | None,
70+
home_page: str | None = None,
71+
desktop_file: bool | None = None,
7372
overwrite: bool = False,
7473
) -> bool:
7574
qb_config_dir = resolve_qb_config_dir(qb_config_dir)
@@ -83,7 +82,7 @@ def new_profile(
8382
return False
8483

8584

86-
def resolve_qb_config_dir(qb_config_dir: Optional[Path]) -> Optional[Path]:
85+
def resolve_qb_config_dir(qb_config_dir: Path | None) -> Path | None:
8786
config_file = "config.py"
8887
dirs = (
8988
[qb_config_dir, qb_config_dir / "config"]

tests/test_profiles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from pathlib import Path
2-
from typing import Optional
32

43
from qbpm import profiles
54
from qbpm.profiles import Profile
@@ -9,7 +8,7 @@ def check_is_empty(path: Path):
98
assert len(list(path.iterdir())) == 0
109

1110

12-
def check_empty_profile(profile: Optional[Profile]):
11+
def check_empty_profile(profile: Profile | None):
1312
assert profile
1413
config_dir = profile.root / "config"
1514
assert list(profile.root.iterdir()) == [config_dir]

0 commit comments

Comments
 (0)