Skip to content

Commit 3142233

Browse files
committed
ci: configure mypy to handle untyped typer decorators
- Add mypy overrides for meter_reader.main module - Disable untyped-decorator and import-not-found errors for main.py - This allows using typer without type stubs while maintaining strict typing elsewhere - All tests (82), linting (ruff), and type checking (mypy) pass successfully
1 parent fdf6dda commit 3142233

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ warn_return_any = true
7777
warn_unused_configs = true
7878
disallow_untyped_defs = true
7979

80+
[[tool.mypy.overrides]]
81+
module = "meter_reader.main"
82+
ignore_missing_imports = true
83+
disable_error_code = ["untyped-decorator", "import-not-found"]
84+
8085

8186
[tool.basedpyright]
8287
typeCheckingMode = "basic"

src/meter_reader/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import typer # type: ignore[import-not-found]
1+
import typer
22
import logging
33
from rich.console import Console
44
from rich.table import Table
@@ -25,7 +25,7 @@ def get_client(address: str, protocol: str, username: Optional[str] = None, pass
2525
console.print(f"[red]Invalid protocol: {protocol}[/red]")
2626
raise typer.Exit(code=1)
2727

28-
@app.command() # type: ignore[untyped-decorator]
28+
@app.command()
2929
def list( # noqa: A001
3030
address: str,
3131
protocol: str = typer.Option("socket", help="Protocol: socket or http"),
@@ -60,7 +60,7 @@ def list( # noqa: A001
6060
console.print(f"[red]Error: {e}[/red]")
6161
raise typer.Exit(code=1)
6262

63-
@app.command() # type: ignore[untyped-decorator]
63+
@app.command()
6464
def demand(
6565
address: str,
6666
protocol: str = typer.Option("socket", help="Protocol: socket or http"),
@@ -81,7 +81,7 @@ def demand(
8181
console.print(f"[red]Error: {e}[/red]")
8282
raise typer.Exit(code=1)
8383

84-
@app.command() # type: ignore[untyped-decorator]
84+
@app.command()
8585
def summation(
8686
address: str,
8787
protocol: str = typer.Option("socket", help="Protocol: socket or http"),
@@ -103,7 +103,7 @@ def summation(
103103
console.print(f"[red]Error: {e}[/red]")
104104
raise typer.Exit(code=1)
105105

106-
@app.command() # type: ignore[untyped-decorator]
106+
@app.command()
107107
def usage(
108108
address: str,
109109
protocol: str = typer.Option("socket", help="Protocol: socket or http"),
@@ -132,7 +132,7 @@ def usage(
132132
console.print(f"[red]Error: {e}[/red]")
133133
raise typer.Exit(code=1)
134134

135-
@app.command() # type: ignore[untyped-decorator]
135+
@app.command()
136136
def history(
137137
address: str,
138138
hours: int = typer.Option(1, help="Number of hours to look back"),
@@ -179,7 +179,7 @@ def history(
179179
console.print(f"[red]Error: {e}[/red]")
180180
raise typer.Exit(code=1)
181181

182-
@app.command() # type: ignore[untyped-decorator]
182+
@app.command()
183183
def watch(
184184
address: str,
185185
interval: int = typer.Option(5, help="Update interval in seconds"),

stubs/typer.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import Any, Optional, Callable
2+
3+
class Typer:
4+
def __init__(self, **kwargs: Any) -> None: ...
5+
def command(self) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...
6+
7+
def Option(
8+
default: Any = ...,
9+
*,
10+
help: Optional[str] = ...,
11+
**kwargs: Any,
12+
) -> Any: ...

0 commit comments

Comments
 (0)