1+ from __future__ import annotations
2+
13import subprocess
24import sys
35import tomllib
46from pathlib import Path
7+ from typing import Any
58
69import click
710
1518
1619@register_cli ("code" )
1720@click .group ()
18- def cli ():
21+ def cli () -> None :
1922 """Code formatting and linting"""
2023 pass
2124
2225
2326@cli .command ()
2427@click .option ("--force" , is_flag = True , help = "Reinstall even if up to date" )
2528@click .pass_context
26- def install (ctx , force ) :
29+ def install (ctx : click . Context , force : bool ) -> None :
2730 """Install or update the Biome standalone per configuration."""
2831 config = get_code_config ()
2932
@@ -50,7 +53,7 @@ def install(ctx, force):
5053
5154
5255@cli .command ()
53- def update ():
56+ def update () -> None :
5457 """Update the Biome standalone binary to the latest release."""
5558 config = get_code_config ()
5659
@@ -67,7 +70,7 @@ def update():
6770@cli .command ()
6871@click .pass_context
6972@click .argument ("path" , default = "." )
70- def check (ctx , path ) :
73+ def check (ctx : click . Context , path : str ) -> None :
7174 """Check the given path for formatting or linting issues."""
7275 ruff_args = ["--config" , str (DEFAULT_RUFF_CONFIG )]
7376 config = get_code_config ()
@@ -103,7 +106,7 @@ def check(ctx, path):
103106@click .argument ("path" , default = "." )
104107@click .option ("--unsafe-fixes" , is_flag = True , help = "Apply ruff unsafe fixes" )
105108@click .option ("--add-noqa" , is_flag = True , help = "Add noqa comments to suppress errors" )
106- def fix (ctx , path , unsafe_fixes , add_noqa ) :
109+ def fix (ctx : click . Context , path : str , unsafe_fixes : bool , add_noqa : bool ) -> None :
107110 """Lint and format the given path."""
108111 ruff_args = ["--config" , str (DEFAULT_RUFF_CONFIG )]
109112 config = get_code_config ()
@@ -153,7 +156,7 @@ def fix(ctx, path, unsafe_fixes, add_noqa):
153156 sys .exit (result .returncode )
154157
155158
156- def get_code_config ():
159+ def get_code_config () -> dict [ str , Any ] :
157160 pyproject = Path ("pyproject.toml" )
158161 if not pyproject .exists ():
159162 return {}
0 commit comments