33import builtins as _builtins
44import subprocess
55import sys
6- from pathlib import Path
7- from typing import Optional , List
8-
96import typer
7+ from revenueholdings import TOOLS , __version__
108from rich .console import Console
11- from rich .table import Table
129from rich .panel import Panel
13-
14- from revenueholdings import __version__ , TOOLS
10+ from rich .table import Table
1511
1612app = typer .Typer (
1713 name = "rh" ,
@@ -43,7 +39,7 @@ def main_callback(
4339
4440@app .command (name = "tools" )
4541def list_tools (
46- name : Optional [ str ] = typer .Argument (None , help = "Show details for a specific tool." ),
42+ name : str | None = typer .Argument (None , help = "Show details for a specific tool." ),
4743):
4844 """List available Revenue Holdings CLI tools."""
4945 if name :
@@ -80,8 +76,8 @@ def list_tools(
8076 )
8177
8278 console .print (table )
83- console .print (f "\n [dim]Install individually:[/dim] [green]pip install revenueholdings[guard][/green]" )
84- console .print (f "[dim]Install all:[/dim] [green]pip install revenueholdings[all][/green]" )
79+ console .print ("\n [dim]Install individually:[/dim] [green]pip install revenueholdings[guard][/green]" )
80+ console .print ("[dim]Install all:[/dim] [green]pip install revenueholdings[all][/green]" )
8581
8682
8783@app .command ()
@@ -116,19 +112,16 @@ def install(
116112 raise typer .Exit (code = 1 )
117113 except Exception as e :
118114 console .print (f"[red]Error: { e } [/red]" )
119- raise typer .Exit (code = 1 )
115+ raise typer .Exit (code = 1 ) from e
120116
121117
122118@app .command (name = "versions" )
123119def show_versions (
124- tool : Optional [ str ] = typer .Argument (None , help = "Check version of a specific tool." ),
120+ tool : str | None = typer .Argument (None , help = "Check version of a specific tool." ),
125121):
126122 """Show installed tool versions."""
127- if tool :
128- targets = [tool ] if tool in TOOLS else []
129- else :
130- targets = _builtins .list (TOOLS .keys ())
131-
123+ targets = ([tool ] if tool in TOOLS else []) if tool else _builtins .list (TOOLS .keys ())
124+
132125 for t in targets :
133126 info = TOOLS [t ]
134127 try :
@@ -155,7 +148,7 @@ def _make_dispatch(tool_name: str):
155148
156149 def dispatch (
157150 ctx : typer .Context ,
158- args : List [str ] = typer .Argument (None , help = "Arguments to pass to the tool." ),
151+ args : list [str ] = typer .Argument (None , help = "Arguments to pass to the tool." ), # noqa: B008
159152 ):
160153 info = TOOLS .get (tool_name )
161154 if not info :
@@ -173,7 +166,7 @@ def dispatch(
173166 f"[red]Tool '{ tool_name } ' not installed.[/red]\n "
174167 f"Install with: [green]pip install revenueholdings[{ tool_name } ][/green]"
175168 )
176- raise typer .Exit (code = 1 )
169+ raise typer .Exit (code = 1 ) from None
177170
178171 dispatch .__name__ = tool_name
179172 dispatch .__doc__ = f"Run `{ pkg } ` commands via the { tool_name } subcommand."
0 commit comments