Skip to content

Commit 2882d5e

Browse files
committed
add types, mostly
1 parent cff13e7 commit 2882d5e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

qbpm/main.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import inspect
22
from os import environ
33
from pathlib import Path
4-
from typing import Any, Callable, Optional
4+
from typing import Any, Callable, NoReturn, Optional
55

66
import click
77
from xdg import BaseDirectory
@@ -23,7 +23,7 @@
2323
help="directory in which profiles are stored",
2424
)
2525
@click.pass_context
26-
def main(ctx, profile_dir: Path) -> None:
26+
def main(ctx: click.Context, profile_dir: Path) -> None:
2727
# TODO version
2828
ctx.obj = profile_dir
2929

@@ -36,7 +36,7 @@ def main(ctx, profile_dir: Path) -> None:
3636
@click.option("-l", "--launch", is_flag=True)
3737
@click.option("-f", "--foreground", is_flag=True)
3838
@click.pass_obj
39-
def new(profile_dir: Path, profile_name: str, **kwargs):
39+
def new(profile_dir: Path, profile_name: str, **kwargs: Any) -> None:
4040
"""Create a new profile."""
4141
profile = Profile(profile_name, profile_dir)
4242
then_launch(profiles.new_profile, profile, **kwargs)
@@ -54,8 +54,8 @@ def from_session(
5454
profile_dir: Path,
5555
session: str,
5656
profile_name: Optional[str],
57-
**kwargs,
58-
):
57+
**kwargs: Any,
58+
) -> None:
5959
"""Create a new profile from a saved qutebrowser session.
6060
SESSION may be the name of a session in the global qutebrowser profile
6161
or a path to a session yaml file.
@@ -70,7 +70,7 @@ def from_session(
7070
def desktop(
7171
profile_dir: Path,
7272
profile_name: str,
73-
):
73+
) -> None:
7474
"""Create a desktop file for an existing profile."""
7575
profile = Profile(profile_name, profile_dir)
7676
exit_with(operations.desktop(profile))
@@ -81,7 +81,7 @@ def desktop(
8181
@click.option("-c", "--create", is_flag=True)
8282
@click.option("-f", "--foreground", is_flag=True)
8383
@click.pass_obj
84-
def launch(profile_dir: Path, profile_name: str, **kwargs):
84+
def launch(profile_dir: Path, profile_name: str, **kwargs: Any) -> None:
8585
"""Launch qutebrowser with a specific profile."""
8686
profile = Profile(profile_name, profile_dir)
8787
# TODO qb args
@@ -97,7 +97,7 @@ def launch(profile_dir: Path, profile_name: str, **kwargs):
9797
)
9898
@click.option("-f", "--foreground", is_flag=True)
9999
@click.pass_obj
100-
def choose(profile_dir: Path, **kwargs):
100+
def choose(profile_dir: Path, **kwargs: Any) -> None:
101101
"""Choose a profile to launch.
102102
Support is built in for many X and Wayland launchers, as well as applescript dialogs.
103103
"""
@@ -108,18 +108,18 @@ def choose(profile_dir: Path, **kwargs):
108108
@main.command()
109109
@click.argument("profile_name")
110110
@click.pass_obj
111-
def edit(profile_dir: Path, profile_name):
111+
def edit(profile_dir: Path, profile_name: str) -> None:
112112
"""Edit a profile's config.py."""
113113
profile = Profile(profile_name, profile_dir)
114114
if not profile.exists():
115115
error(f"profile {profile.name} not found at {profile.root}")
116116
exit(1)
117-
click.edit(filename=profile.root / "config" / "config.py")
117+
click.edit(filename=str(profile.root / "config" / "config.py"))
118118

119119

120120
@main.command(name="list")
121121
@click.pass_obj
122-
def list_(profile_dir: Path):
122+
def list_(profile_dir: Path) -> None:
123123
"""List existing profiles."""
124124
for profile in sorted(profile_dir.iterdir()):
125125
print(profile.name)
@@ -131,7 +131,7 @@ def then_launch(
131131
launch: bool,
132132
foreground: bool,
133133
qb_args: list[str] = [],
134-
**kwargs,
134+
**kwargs: Any,
135135
) -> None:
136136
exit_with(
137137
operation(profile, **kwargs)
@@ -157,5 +157,5 @@ def session_info(
157157
return (Profile(profile_name or session_path.stem, profile_dir), session_path)
158158

159159

160-
def exit_with(result: bool):
160+
def exit_with(result: bool) -> NoReturn:
161161
exit(0 if result else 1)

qbpm/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def error(msg: str) -> None:
1818
print(f"error: {msg}", file=stderr)
1919

2020

21-
def default_profile_dir():
21+
def default_profile_dir() -> Path:
2222
return Path(BaseDirectory.save_data_path("qutebrowser-profiles"))
2323

2424

0 commit comments

Comments
 (0)