Skip to content

Commit 3d0aabb

Browse files
committed
Add types
1 parent 3f364ac commit 3d0aabb

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

app/login.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"""
3232

3333

34-
def vault_login():
34+
def vault_login() -> hvac.Client | None:
3535
client = hvac.Client(verify=False)
3636

3737
auth_url_response = client.auth.oidc.oidc_authorization_url_request(
@@ -64,7 +64,7 @@ def vault_login():
6464

6565

6666
# handles the callback
67-
def login_oidc_get_token():
67+
def login_oidc_get_token() -> str:
6868
from http.server import BaseHTTPRequestHandler, HTTPServer
6969

7070
class HttpServ(HTTPServer):

app/utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import dmenu
77

88

9-
def copy_to_clipboard(text):
9+
def copy_to_clipboard(text: bytes):
1010
p = Popen(["xsel", "-i"], stdin=PIPE)
1111
p.communicate(input=text)
1212

1313

14-
def which(program):
15-
def is_exe(fpath):
16-
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
14+
def which(program: str) -> str | None:
15+
def is_exe(_fpath):
16+
return os.path.isfile(_fpath) and os.access(_fpath, os.X_OK)
1717

1818
fpath, _ = os.path.split(program)
1919
if fpath:
@@ -28,7 +28,7 @@ def is_exe(fpath):
2828
return None
2929

3030

31-
def call_rofi_dmenu(options, abort=True, prompt=None):
31+
def call_rofi_dmenu(options: list, abort: bool = True, prompt: str = None) -> str:
3232
if which("rofi"):
3333
_rofi = Rofi()
3434
index, key = _rofi.select(prompt or "Select:", options)
@@ -43,7 +43,7 @@ def call_rofi_dmenu(options, abort=True, prompt=None):
4343
return user_select
4444

4545

46-
def parse_user_config():
46+
def parse_user_config() -> tuple:
4747
config_file = os.path.join(os.path.expanduser("~"), ".config", "vaultrun", "config")
4848
_config_parser = ConfigParser()
4949
# Open the file with the correct encoding
@@ -52,7 +52,7 @@ def parse_user_config():
5252
if len(sections_from_config) == 1:
5353
config_section = sections_from_config[0]
5454
else:
55-
config_section = call_rofi_dmenu(options=sections_from_config, abort=True, prompt=None)
55+
config_section = call_rofi_dmenu(options=sections_from_config)
5656

5757
_mount_point = _config_parser[config_section]["mount_point"]
5858
_secret_path = _config_parser[config_section]["secret_path"]

app/vaultrun.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import hvac
2+
13
from app.login import vault_login
24
from app.utils import call_rofi_dmenu, parse_user_config, which, copy_to_clipboard
35
from rich import print, pretty
46

57

6-
def parse_vault_path(client, mount_point, secret_path):
8+
def parse_vault_path(client: hvac.Client, mount_point: str, secret_path: str) -> str:
79
all_secrets = client.secrets.kv.v2.list_secrets(mount_point=mount_point, path=secret_path)
810
_selected = call_rofi_dmenu(options=all_secrets.get("data", {}).get("keys"), abort=True, prompt=None)
911
if _selected.endswith("/"):

0 commit comments

Comments
 (0)