Skip to content

Commit 3c280b1

Browse files
author
Revenue Holdings
committed
fix: ruff lint - datetime.UTC, X|None, E501, B904, F821
1 parent feb718d commit 3c280b1

4 files changed

Lines changed: 26 additions & 24 deletions

File tree

pyproject.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
"rich>=13.0.0",
2626
]
2727

28-
# Optional groups install with: pip install revenueholdings[all]
28+
# Optional groups — install with: pip install revenueholdings[all]
2929
[project.optional-dependencies]
3030
guard = ["api-contract-guardian>=0.1.0"]
3131
sql = ["json2sql>=0.1.0"]
@@ -64,4 +64,14 @@ where = ["src"]
6464

6565
[tool.pytest.ini_options]
6666
testpaths = ["tests"]
67-
addopts = "-v --tb=short"
67+
addopts = "-v --tb=short"
68+
[tool.ruff]
69+
target-version = "py310"
70+
line-length = 120
71+
72+
[tool.ruff.lint]
73+
select = ["E", "F", "W", "I", "UP", "B", "SIM"]
74+
ignore = ["E501"]
75+
76+
[tool.ruff.lint.isort]
77+
known-first-party = ["*"]

src/revenueholdings/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@
8484
"status": "ready",
8585
"url": "https://github.com/Coding-Dev-Tools/deadcode",
8686
},
87-
}
87+
}

src/revenueholdings/cli.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
import builtins as _builtins
44
import subprocess
55
import sys
6-
from pathlib import Path
7-
from typing import Optional, List
8-
96
import typer
7+
from revenueholdings import TOOLS, __version__
108
from rich.console import Console
11-
from rich.table import Table
129
from rich.panel import Panel
13-
14-
from revenueholdings import __version__, TOOLS
10+
from rich.table import Table
1511

1612
app = typer.Typer(
1713
name="rh",
@@ -43,7 +39,7 @@ def main_callback(
4339

4440
@app.command(name="tools")
4541
def 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")
123119
def 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."

tests/test_cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""Tests for revenueholdings meta-package."""
22
from __future__ import annotations
33

4-
from typer.testing import CliRunner
5-
6-
from revenueholdings.cli import app
74
from revenueholdings import TOOLS, __version__
5+
from revenueholdings.cli import app
6+
from typer.testing import CliRunner
87

98
runner = CliRunner()
109

0 commit comments

Comments
 (0)