Skip to content

Commit 022fae4

Browse files
committed
Add obvious type hints to most functions
1 parent 762fdbf commit 022fae4

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

src/maps

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ def addCLI():
133133
return parser, parser_runtime, parser_remote, parser_pack
134134

135135

136-
def sanity_checks(parsers):
137-
"""Some simple sanity checks, before the program proceeds"""
136+
def sanity_checks(parsers: tuple[argparse.ArgumentParser, argparse.ArgumentParser,
137+
argparse.ArgumentParser, argparse.ArgumentParser]):
138+
"""Some simply sanity checks, before the program proceeds"""
138139
if len(sys.argv) == 1:
139140
parsers[0].print_help()
140141
sys.exit(1)
@@ -185,7 +186,7 @@ def create_config_file(config_path):
185186
return config
186187

187188

188-
def program_init(repopath):
189+
def program_init(repopath: str):
189190
"""Init function verifies requirements, sets up the repo. Returns the OSTree Repo."""
190191
opt1 = "-q"
191192
opt2 = "1>/dev/null"
@@ -326,7 +327,7 @@ def program_init(repopath):
326327
return repo
327328

328329

329-
def make_remote_ref_list(repo, remote):
330+
def make_remote_ref_list(repo: OSTree.Repo, remote: str):
330331
"""Given a repo and a remote, return a list of refs in the remote of that repo"""
331332
if remote is None:
332333
return []
@@ -347,7 +348,7 @@ def make_remote_ref_list(repo, remote):
347348
return remote_refs
348349

349350

350-
def mode_list(repo):
351+
def mode_list(repo: OSTree.Repo):
351352
"""Prints a list of available refs"""
352353
print("Available runtimes are :")
353354
refs = list(repo.list_refs()[1].keys())
@@ -372,7 +373,7 @@ def list_remotes(repo):
372373
return retval
373374

374375

375-
def mode_remotes(repo, args):
376+
def mode_remotes(repo: OSTree.Repo, args): # todo: type for args?
376377
"""Administrative mode for remotes of the repo"""
377378
if args.LIST is not False:
378379
remotes = list_remotes(repo)
@@ -581,7 +582,7 @@ def make_bwrap_command(location, command, nogui, gui):
581582
return bwrapstring, senv
582583

583584

584-
def mode_run(repo, args):
585+
def mode_run(repo, args): # TODO
585586
"""Function to execute a deployed environment"""
586587

587588
remote, runtime = disambiguate_runtime(repo, args.RUN, installed=True)
@@ -661,7 +662,7 @@ def download(repo, repopath, remote, target):
661662

662663

663664
# Uninstall
664-
def uninstall_runtime(repo, args):
665+
def uninstall_runtime(repo: OSTree.repo, args): # todo: type for args?
665666
"""Function to remove a runtime from both the local disk checkout, and the local repo"""
666667
# Check if runtime is checked out
667668
FLAG_DIREXISTS = False
@@ -723,7 +724,7 @@ def validate_runtime_name(runtime_id: str):
723724

724725

725726
# Update
726-
def mode_update(repo, repopath, args, remote=""):
727+
def mode_update(repo, repopath, args, remote=""): # TODO
727728
"""Function to update a runtime identifier to its recent version (if any)"""
728729
if not args.UPDATE:
729730
args.UPDATE = args.DEPLOY
@@ -808,7 +809,7 @@ def checkout(repo, remote, runtime):
808809

809810

810811
# Deploy Mode
811-
def mode_deploy(repo, repopath, args):
812+
def mode_deploy(repo: OSTree.Repo, repopath: str, args): # todo: type for args?
812813
"""Function to deploy from repo to local disk"""
813814

814815
remote, runtime = disambiguate_runtime(repo, args.DEPLOY, installed=False)
@@ -872,7 +873,7 @@ def blank_options():
872873

873874

874875
# Package Mode
875-
def mode_package(repo, repopath, args):
876+
def mode_package(repo, repopath, args): #TODO
876877
"""Function for package mode. Not intended to be used by "end users" """
877878
if args.DIR is not None:
878879
refhash = ''
@@ -936,7 +937,7 @@ def mode_package(repo, repopath, args):
936937
upload(repo, args.UPLOAD)
937938

938939

939-
def commit(zarglist):
940+
def commit(zarglist: list):
940941
"""
941942
Function commits a tree to a repo in branch asynchronously,
942943
so spinner can be animated in the main thread to show activity.
@@ -965,7 +966,7 @@ def commit(zarglist):
965966
repo.commit_transaction(None)
966967

967968

968-
def reset(repo, runtime):
969+
def reset(repo, runtime): #TODO
969970
"""
970971
Function resets a runtime, simply by deleting the contents of the "rwfs" dir.
971972
"""
@@ -1090,7 +1091,7 @@ def mode_url(repo, repopath, args):
10901091

10911092

10921093
# runtime mode: the default path for execution
1093-
def mode_runtime(repo, repopath, args):
1094+
def mode_runtime(repo: OSTree.Repo, repopath: str, args):
10941095
"""
10951096
Runtime mode, the default path for execution, and the "end user" mode.
10961097
"""

0 commit comments

Comments
 (0)