@@ -41,7 +41,7 @@ def format_number(value: float | int | str) -> str:
4141 return str (value )
4242 if isinstance (value , float ):
4343 # Remove trailing zeros after decimal point
44- formatted = f"{ value :,.4f} " .rstrip ('0' ).rstrip ('.' )
44+ formatted = f"{ value :,.4f} " .rstrip ("0" ).rstrip ("." )
4545 return formatted
4646 return f"{ value :,} "
4747
@@ -78,7 +78,9 @@ def print_portfolios(portfolios: list[dict[str, Any]], raw: bool = False) -> Non
7878 )
7979
8080 console .print (table )
81- console .print ("\n [dim]Tip: Use the index number (e.g., 'kubera show 1') instead of the full ID[/dim]" )
81+ console .print (
82+ "\n [dim]Tip: Use the index number (e.g., 'kubera show 1') instead of the full ID[/dim]"
83+ )
8284
8385
8486def print_portfolio (portfolio : dict [str , Any ], raw : bool = False ) -> None :
@@ -114,7 +116,9 @@ def print_portfolio(portfolio: dict[str, Any], raw: bool = False) -> None:
114116 assets = portfolio .get ("asset" , portfolio .get ("assets" , []))
115117 if assets :
116118 asset_total = portfolio .get ("assetTotal" )
117- total_str = f" - Total: { format_currency (asset_total , 'USD' )} " if asset_total is not None else ""
119+ total_str = (
120+ f" - Total: { format_currency (asset_total , 'USD' )} " if asset_total is not None else ""
121+ )
118122 console .print (f"\n [bold]Assets ({ len (assets )} items){ total_str } [/bold]" )
119123
120124 # Group by sheet
@@ -138,19 +142,17 @@ def print_portfolio(portfolio: dict[str, Any], raw: bool = False) -> None:
138142
139143 for sheet_name , (items , total ) in by_sheet .items ():
140144 currency = items [0 ].get ("value" , {}).get ("currency" , "USD" ) if items else "USD"
141- sheet_table .add_row (
142- sheet_name ,
143- str (len (items )),
144- format_currency (total , currency )
145- )
145+ sheet_table .add_row (sheet_name , str (len (items )), format_currency (total , currency ))
146146
147147 console .print (sheet_table )
148148
149149 # Debts - API uses 'debt' not 'debts'
150150 debts = portfolio .get ("debt" , portfolio .get ("debts" , []))
151151 if debts :
152152 debt_total = portfolio .get ("debtTotal" )
153- total_str = f" - Total: { format_currency (debt_total , 'USD' )} " if debt_total is not None else ""
153+ total_str = (
154+ f" - Total: { format_currency (debt_total , 'USD' )} " if debt_total is not None else ""
155+ )
154156 console .print (f"\n [bold]Debts ({ len (debts )} items){ total_str } [/bold]" )
155157
156158 # Group by sheet
@@ -174,11 +176,7 @@ def print_portfolio(portfolio: dict[str, Any], raw: bool = False) -> None:
174176
175177 for sheet_name , (items , total ) in by_sheet_debt .items ():
176178 currency = items [0 ].get ("value" , {}).get ("currency" , "USD" ) if items else "USD"
177- debt_sheet_table .add_row (
178- sheet_name ,
179- str (len (items )),
180- format_currency (total , currency )
181- )
179+ debt_sheet_table .add_row (sheet_name , str (len (items )), format_currency (total , currency ))
182180
183181 console .print (debt_sheet_table )
184182
@@ -212,9 +210,7 @@ def print_portfolio(portfolio: dict[str, Any], raw: bool = False) -> None:
212210 for sheet_name , (items , total ) in by_sheet_ins .items ():
213211 currency = items [0 ].get ("value" , {}).get ("currency" , "USD" ) if items else "USD"
214212 ins_sheet_table .add_row (
215- sheet_name ,
216- str (len (items )),
217- format_currency (total , currency )
213+ sheet_name , str (len (items )), format_currency (total , currency )
218214 )
219215
220216 console .print (ins_sheet_table )
@@ -357,7 +353,11 @@ def print_success(message: str) -> None:
357353
358354
359355def print_sheet_detail (
360- items : list [dict [str , Any ]], sheet_name : str , category : str , portfolio_name : str , raw : bool = False
356+ items : list [dict [str , Any ]],
357+ sheet_name : str ,
358+ category : str ,
359+ portfolio_name : str ,
360+ raw : bool = False ,
361361) -> None :
362362 """Print detailed information for items in a sheet.
363363
@@ -386,7 +386,9 @@ def print_sheet_detail(
386386
387387 # Calculate totals (excluding parent accounts)
388388 total_value = sum (item .get ("value" , {}).get ("amount" , 0 ) or 0 for item in items_for_totals )
389- total_cost = sum (item .get ("cost" , {}).get ("amount" , 0 ) or 0 for item in items_for_totals if "cost" in item )
389+ total_cost = sum (
390+ item .get ("cost" , {}).get ("amount" , 0 ) or 0 for item in items_for_totals if "cost" in item
391+ )
390392
391393 # Overall gains
392394 if total_cost > 0 :
@@ -397,7 +399,8 @@ def print_sheet_detail(
397399 console .print (
398400 f"\n [bold]Total Value:[/bold] { format_currency (total_value , 'USD' )} | "
399401 f"[bold]Cost Basis:[/bold] { format_currency (total_cost , 'USD' )} | "
400- f"[bold { gain_color } ]Gain:[/bold { gain_color } ] { gain_sign } { format_currency (total_gain , 'USD' )} "
402+ f"[bold { gain_color } ]Gain:[/bold { gain_color } ] "
403+ f"{ gain_sign } { format_currency (total_gain , 'USD' )} "
401404 f"({ gain_sign } { total_gain_pct :.2f} %)"
402405 )
403406 else :
@@ -412,13 +415,17 @@ def print_sheet_detail(
412415 by_section [section ] = []
413416 by_section [section ].append (item )
414417
415- console .print (f"\n [dim]Total Items: { len (items_for_totals )} across { len (by_section )} section(s)[/dim]" )
418+ console .print (
419+ f"\n [dim]Total Items: { len (items_for_totals )} across { len (by_section )} section(s)[/dim]"
420+ )
416421
417422 # Display each section
418423 for section_name , section_items in by_section .items ():
419424 # Section header with totals (items already filtered, no parents)
420425 section_value = sum (item .get ("value" , {}).get ("amount" , 0 ) or 0 for item in section_items )
421- section_cost = sum (item .get ("cost" , {}).get ("amount" , 0 ) or 0 for item in section_items if "cost" in item )
426+ section_cost = sum (
427+ item .get ("cost" , {}).get ("amount" , 0 ) or 0 for item in section_items if "cost" in item
428+ )
422429
423430 console .print (f"\n [bold yellow]{ section_name } [/bold yellow] ({ len (section_items )} items)" )
424431
@@ -439,7 +446,9 @@ def print_sheet_detail(
439446 # Detect which columns have data in this section
440447 has_ticker = any (item .get ("ticker" ) for item in section_items )
441448 has_quantity = any (item .get ("quantity" ) for item in section_items )
442- has_cost = any ("cost" in item and item .get ("cost" , {}).get ("amount" ) for item in section_items )
449+ has_cost = any (
450+ "cost" in item and item .get ("cost" , {}).get ("amount" ) for item in section_items
451+ )
443452
444453 # Create table for this section with only relevant columns
445454 table = Table (show_header = True , show_lines = False , box = None )
@@ -490,7 +499,10 @@ def print_sheet_detail(
490499 gain_color = "green" if gain >= 0 else "red"
491500 gain_sign = "+" if gain >= 0 else ""
492501
493- gain_str = f"[{ gain_color } ]{ gain_sign } { format_currency (gain , currency )} [/{ gain_color } ]"
502+ gain_str = (
503+ f"[{ gain_color } ]{ gain_sign } "
504+ f"{ format_currency (gain , currency )} [/{ gain_color } ]"
505+ )
494506 gain_pct_str = f"[{ gain_color } ]{ gain_sign } { gain_pct :.2f} %[/{ gain_color } ]"
495507
496508 row .extend ([cost_str , gain_str , gain_pct_str ])
0 commit comments