Skip to content

Commit 7455fa0

Browse files
committed
Type annotations for plain-code
1 parent 154d4c4 commit 7455fa0

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

plain-code/plain/code/biome.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def install(self, version: str = "") -> str:
153153
self.set_version_in_config(v)
154154
return v
155155

156-
def invoke(self, *args, cwd=None) -> subprocess.CompletedProcess:
156+
def invoke(self, *args: str, cwd: str | None = None) -> subprocess.CompletedProcess:
157157
# Run the standalone biome binary with given args
158158
config_path = os.path.abspath(
159159
os.path.join(os.path.dirname(__file__), "biome_defaults.json")

plain-code/plain/code/cli.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from __future__ import annotations
2+
13
import subprocess
24
import sys
35
import tomllib
46
from pathlib import Path
7+
from typing import Any
58

69
import click
710

@@ -15,15 +18,15 @@
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 {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def setup():
1+
def setup() -> None:
22
# This package isn't an installed app,
33
# so we need to trigger our own import and cli registration.
44
from .cli import cli # noqa

scripts/type-validate

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ FULLY_TYPED_DIRS = [
1818
"plain-api/plain/api",
1919
"plain-auth/plain/auth",
2020
"plain-cache/plain/cache",
21+
"plain-code/plain/code",
2122
"plain-sessions/plain/sessions",
2223
]
2324

0 commit comments

Comments
 (0)