1
1
import inspect
2
2
from os import environ
3
3
from pathlib import Path
4
- from typing import Any , Callable , Optional
4
+ from typing import Any , Callable , NoReturn , Optional
5
5
6
6
import click
7
7
from xdg import BaseDirectory
23
23
help = "directory in which profiles are stored" ,
24
24
)
25
25
@click .pass_context
26
- def main (ctx , profile_dir : Path ) -> None :
26
+ def main (ctx : click . Context , profile_dir : Path ) -> None :
27
27
# TODO version
28
28
ctx .obj = profile_dir
29
29
@@ -36,7 +36,7 @@ def main(ctx, profile_dir: Path) -> None:
36
36
@click .option ("-l" , "--launch" , is_flag = True )
37
37
@click .option ("-f" , "--foreground" , is_flag = True )
38
38
@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 :
40
40
"""Create a new profile."""
41
41
profile = Profile (profile_name , profile_dir )
42
42
then_launch (profiles .new_profile , profile , ** kwargs )
@@ -54,8 +54,8 @@ def from_session(
54
54
profile_dir : Path ,
55
55
session : str ,
56
56
profile_name : Optional [str ],
57
- ** kwargs ,
58
- ):
57
+ ** kwargs : Any ,
58
+ ) -> None :
59
59
"""Create a new profile from a saved qutebrowser session.
60
60
SESSION may be the name of a session in the global qutebrowser profile
61
61
or a path to a session yaml file.
@@ -70,7 +70,7 @@ def from_session(
70
70
def desktop (
71
71
profile_dir : Path ,
72
72
profile_name : str ,
73
- ):
73
+ ) -> None :
74
74
"""Create a desktop file for an existing profile."""
75
75
profile = Profile (profile_name , profile_dir )
76
76
exit_with (operations .desktop (profile ))
@@ -81,7 +81,7 @@ def desktop(
81
81
@click .option ("-c" , "--create" , is_flag = True )
82
82
@click .option ("-f" , "--foreground" , is_flag = True )
83
83
@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 :
85
85
"""Launch qutebrowser with a specific profile."""
86
86
profile = Profile (profile_name , profile_dir )
87
87
# TODO qb args
@@ -97,7 +97,7 @@ def launch(profile_dir: Path, profile_name: str, **kwargs):
97
97
)
98
98
@click .option ("-f" , "--foreground" , is_flag = True )
99
99
@click .pass_obj
100
- def choose (profile_dir : Path , ** kwargs ) :
100
+ def choose (profile_dir : Path , ** kwargs : Any ) -> None :
101
101
"""Choose a profile to launch.
102
102
Support is built in for many X and Wayland launchers, as well as applescript dialogs.
103
103
"""
@@ -108,18 +108,18 @@ def choose(profile_dir: Path, **kwargs):
108
108
@main .command ()
109
109
@click .argument ("profile_name" )
110
110
@click .pass_obj
111
- def edit (profile_dir : Path , profile_name ) :
111
+ def edit (profile_dir : Path , profile_name : str ) -> None :
112
112
"""Edit a profile's config.py."""
113
113
profile = Profile (profile_name , profile_dir )
114
114
if not profile .exists ():
115
115
error (f"profile { profile .name } not found at { profile .root } " )
116
116
exit (1 )
117
- click .edit (filename = profile .root / "config" / "config.py" )
117
+ click .edit (filename = str ( profile .root / "config" / "config.py" ) )
118
118
119
119
120
120
@main .command (name = "list" )
121
121
@click .pass_obj
122
- def list_ (profile_dir : Path ):
122
+ def list_ (profile_dir : Path ) -> None :
123
123
"""List existing profiles."""
124
124
for profile in sorted (profile_dir .iterdir ()):
125
125
print (profile .name )
@@ -131,7 +131,7 @@ def then_launch(
131
131
launch : bool ,
132
132
foreground : bool ,
133
133
qb_args : list [str ] = [],
134
- ** kwargs ,
134
+ ** kwargs : Any ,
135
135
) -> None :
136
136
exit_with (
137
137
operation (profile , ** kwargs )
@@ -157,5 +157,5 @@ def session_info(
157
157
return (Profile (profile_name or session_path .stem , profile_dir ), session_path )
158
158
159
159
160
- def exit_with (result : bool ):
160
+ def exit_with (result : bool ) -> NoReturn :
161
161
exit (0 if result else 1 )
0 commit comments