112112installed_packages : list [str ] = []
113113pinned_package_cache : dict [str , str ] = {}
114114
115+
115116# This walk function walks the metadata returned by nix, where inputs can either point to a final node in
116117# the root of the tree or an indirection/pointer path through the tree
117118def walk_path_nix_meta (nodes : dict , current_node_id : str , path : list [str ]) -> str :
@@ -190,9 +191,7 @@ def get_package_metadata(package: ConcretePackage | GithubPackage) -> PackageMet
190191
191192
192193# build a rich.Tree of inputs for the given package metadata
193- def package_metadata_tree (
194- p : PackageMetadata | Follows , lbl : str | None = None , show_status : bool = False
195- ) -> Tree :
194+ def package_metadata_tree (p : PackageMetadata | Follows , lbl : str | None = None , show_status : bool = False ) -> Tree :
196195 if lbl is None :
197196 tree = Tree ('Inputs:' )
198197 else :
@@ -342,9 +341,7 @@ def list_package(
342341 auth = (
343342 {'Authorization' : f'Bearer { listed_package .access_token } ' }
344343 if listed_package .access_token
345- else {'Authorization' : f'Bearer { os .getenv ("GH_TOKEN" )} ' }
346- if os .getenv ('GH_TOKEN' )
347- else {}
344+ else {'Authorization' : f'Bearer { os .getenv ("GH_TOKEN" )} ' } if os .getenv ('GH_TOKEN' ) else {}
348345 )
349346 tags = requests .get (
350347 f'https://api.github.com/repos/{ listed_package .org } /{ listed_package .repo } /tags' , headers = auth
@@ -387,14 +384,16 @@ def list_package(
387384 table = SingleTable (table_data )
388385 print (table .table )
389386 else :
390- table_data = [['Package name (alias)' , 'Installed version' , 'Status' ],] + [
387+ table_data = [
388+ ['Package name (alias)' , 'Installed version' , 'Status' ],
389+ ] + [
391390 [
392391 str (PackageName (alias , p .package_name .ext ).pretty_name ),
393- f' { p . commit [: 7 ] if TERMINAL_WIDTH < 80 else p . commit } { " (" + p . tag + ")" if p . tag else "" } '
394- if type ( p ) == ConcretePackage
395- else ' \033 [3mlocal checkout \033 [0m'
396- if type (p ) == LocalPackage
397- else '' ,
392+ (
393+ f' { p . commit [: 7 ] if TERMINAL_WIDTH < 80 else p . commit } { " (" + p . tag + ")" if p . tag else "" } '
394+ if type ( p ) == ConcretePackage
395+ else ' \033 [3mlocal checkout \033 [0m' if type (p ) == LocalPackage else ''
396+ ) ,
398397 p .status if type (p ) == ConcretePackage else INSTALLED if type (p ) == LocalPackage else AVAILABLE ,
399398 ]
400399 for alias , p in packages .items ()
@@ -413,9 +412,7 @@ def is_sha1(maybe_sha: str) -> bool:
413412 return True
414413
415414
416- def walk_package_metadata (
417- node : PackageMetadata | Follows , path : list [str ]
418- ) -> PackageMetadata | Follows | None :
415+ def walk_package_metadata (node : PackageMetadata | Follows , path : list [str ]) -> PackageMetadata | Follows | None :
419416 if len (path ) == 0 :
420417 return node
421418 else :
@@ -603,9 +600,7 @@ def check_github_api_accessible(org: str, repo: str, access_token: str | None) -
603600 auth = (
604601 {'Authorization' : f'Bearer { access_token } ' }
605602 if access_token
606- else {'Authorization' : f'Bearer { os .getenv ("GH_TOKEN" )} ' }
607- if os .getenv ('GH_TOKEN' )
608- else {}
603+ else {'Authorization' : f'Bearer { os .getenv ("GH_TOKEN" )} ' } if os .getenv ('GH_TOKEN' ) else {}
609604 )
610605 commits = requests .get (f'https://api.github.com/repos/{ org } /{ repo } /commits' , headers = auth )
611606 return commits .ok
@@ -697,7 +692,7 @@ def add_new_package(
697692 substituters_to_add = []
698693 trusted_public_keys_to_add = []
699694
700- for ( s , pub_key ) in zip (substituters , trusted_public_keys , strict = True ):
695+ for s , pub_key in zip (substituters , trusted_public_keys , strict = True ):
701696 if s in CURRENT_SUBSTITUTERS and pub_key in CURRENT_TRUSTED_PUBLIC_KEYS :
702697 pass
703698
@@ -873,13 +868,11 @@ def main() -> None:
873868 description = 'The K Framework installer' ,
874869 prog = 'kup' ,
875870 formatter_class = RawDescriptionHelpFormatter ,
876- epilog = textwrap .dedent (
877- """\
871+ epilog = textwrap .dedent ("""\
878872 additional information:
879873 For more detailed help for the different sub-commands, call
880874 kup {list,install,add,shell} --help
881- """
882- ),
875+ """ ),
883876 )
884877 verbose_arg = ArgumentParser (add_help = False )
885878 verbose_arg .add_argument ('-v' , '--verbose' , action = 'store_true' , help = 'verbose output from nix' )
0 commit comments