Skip to content

Commit c8da2e4

Browse files
author
Arturo R Montesinos
committed
ci(mypy): install types stubs and add import-untyped ignores for optional runtime imports
1 parent 5e81a79 commit c8da2e4

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ ruff==0.6.9
33
mypy==1.11.2
44
build==1.2.2
55
pre-commit==4.0.1
6+
7+
# Stubs for optional third-party deps used in type checking
8+
types-PyYAML
9+
types-tabulate
10+
types-tqdm

src/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ def render(obj: Any, args: argparse.Namespace) -> None:
242242
if not _HAVE_YAML:
243243
print("YAML output requested but PyYAML is not installed.", file=sys.stderr)
244244
sys.exit(2)
245-
import yaml as _yaml
246-
245+
import yaml as _yaml # type: ignore[import-untyped]
247246
print(_yaml.safe_dump(_to_serializable(obj), sort_keys=False, allow_unicode=True))
248247
return
249248

@@ -270,7 +269,7 @@ def render(obj: Any, args: argparse.Namespace) -> None:
270269
return
271270
# Fallback to tabulate
272271
if _HAVE_TABULATE:
273-
from tabulate import tabulate as _tabulate
272+
from tabulate import tabulate as _tabulate # type: ignore[import-untyped]
274273

275274
print(
276275
_tabulate(

0 commit comments

Comments
 (0)