Skip to content

Commit 40db43a

Browse files
committed
Add ty to plain code
1 parent 581b406 commit 40db43a

File tree

4 files changed

+62
-14
lines changed

4 files changed

+62
-14
lines changed

plain-code/plain/code/README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
## Overview
1010

11-
The `plain code` command lints and formats Python files using [Ruff](https://astral.sh/ruff), and JavaScript, JSON, and CSS files using [Biome](https://biomejs.dev/). Ruff is installed as a Python dependency, and Biome is managed automatically as a standalone binary (npm is not required).
11+
The `plain code` command provides comprehensive code quality tools:
12+
13+
- **[Ruff](https://astral.sh/ruff)** - Python linting and formatting
14+
- **[ty](https://astral.sh/ty)** - Python type checking
15+
- **[Biome](https://biomejs.dev/)** - JavaScript, JSON, and CSS formatting
16+
17+
Ruff and ty are installed as Python dependencies. Biome is managed automatically as a standalone binary (npm is not required).
1218

1319
The most used command is `plain code fix`, which can be run using the alias `plain fix`:
1420

@@ -20,6 +26,25 @@ This will automatically fix linting issues and format your code according to the
2026

2127
![](https://assets.plainframework.com/docs/plain-fix.png)
2228

29+
To check your code without making changes (including type checking):
30+
31+
```bash
32+
plain code check
33+
```
34+
35+
You can skip specific tools if needed:
36+
37+
```bash
38+
# Skip type checking during rapid development
39+
plain code check --skip-ty
40+
41+
# Only run type checks
42+
plain code check --skip-ruff --skip-biome
43+
44+
# Skip Biome checks
45+
plain code check --skip-biome
46+
```
47+
2348
If [`plain.dev`](/plain-dev/README.md) is installed then `plain code check` will be run automatically as a part of `plain precommit` to help catch issues before they are committed.
2449

2550
## Configuration
@@ -32,6 +57,9 @@ You can customize the behavior in your `pyproject.toml`:
3257
[tool.plain.code]
3358
exclude = ["path/to/exclude"]
3459

60+
[tool.plain.code.ty]
61+
enabled = true # Set to false to disable ty
62+
3563
[tool.plain.code.biome]
3664
enabled = true # Set to false to disable Biome
3765
version = "1.5.3" # Pin to a specific version

plain-code/plain/code/cli.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ def update() -> None:
7575
@cli.command()
7676
@click.pass_context
7777
@click.argument("path", default=".")
78-
def check(ctx: click.Context, path: str) -> None:
78+
@click.option("--skip-ruff", is_flag=True, help="Skip Ruff checks")
79+
@click.option("--skip-ty", is_flag=True, help="Skip ty type checks")
80+
@click.option("--skip-biome", is_flag=True, help="Skip Biome checks")
81+
def check(
82+
ctx: click.Context,
83+
path: str,
84+
skip_ruff: bool,
85+
skip_ty: bool,
86+
skip_biome: bool,
87+
) -> None:
7988
"""Check for formatting and linting issues"""
8089
ruff_args = ["--config", str(DEFAULT_RUFF_CONFIG)]
8190
config = get_code_config()
@@ -92,20 +101,28 @@ def maybe_exit(return_code: int) -> None:
92101
)
93102
sys.exit(return_code)
94103

95-
print_event(
96-
click.style("Ruff lint:", bold=True) + click.style(" ruff check", dim=True)
97-
)
98-
result = subprocess.run(["ruff", "check", path, *ruff_args])
99-
maybe_exit(result.returncode)
104+
if not skip_ruff:
105+
print_event(
106+
click.style("Ruff lint:", bold=True) + click.style(" ruff check", dim=True)
107+
)
108+
result = subprocess.run(["ruff", "check", path, *ruff_args])
109+
maybe_exit(result.returncode)
100110

101-
print_event(
102-
click.style("Ruff format:", bold=True)
103-
+ click.style(" ruff format --check", dim=True)
104-
)
105-
result = subprocess.run(["ruff", "format", path, "--check", *ruff_args])
106-
maybe_exit(result.returncode)
111+
print_event(
112+
click.style("Ruff format:", bold=True)
113+
+ click.style(" ruff format --check", dim=True)
114+
)
115+
result = subprocess.run(["ruff", "format", path, "--check", *ruff_args])
116+
maybe_exit(result.returncode)
107117

108-
if config.get("biome", {}).get("enabled", True):
118+
if not skip_ty and config.get("ty", {}).get("enabled", True):
119+
print_event(
120+
click.style("Ty:", bold=True) + click.style(" ty check", dim=True)
121+
)
122+
result = subprocess.run(["ty", "check", path])
123+
maybe_exit(result.returncode)
124+
125+
if not skip_biome and config.get("biome", {}).get("enabled", True):
109126
biome = Biome()
110127

111128
if biome.needs_update():

plain-code/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ requires-python = ">=3.13"
99
dependencies = [
1010
"plain<1.0.0",
1111
"ruff>=0.1.0",
12+
"ty>=0.0.1a27",
1213
"requests>=2.0.0",
1314
"tomlkit>=0.11.0",
1415
]

uv.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)