plain.code 0.10.0__tar.gz → 0.12.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plain_code-0.10.0 → plain_code-0.12.0}/PKG-INFO +32 -2
- plain_code-0.12.0/plain/code/CHANGELOG.md +137 -0
- {plain_code-0.10.0 → plain_code-0.12.0}/plain/code/README.md +29 -1
- {plain_code-0.10.0 → plain_code-0.12.0}/plain/code/biome.py +3 -3
- {plain_code-0.10.0 → plain_code-0.12.0}/plain/code/cli.py +85 -29
- {plain_code-0.10.0 → plain_code-0.12.0}/plain/code/entrypoints.py +1 -1
- {plain_code-0.10.0 → plain_code-0.12.0}/pyproject.toml +3 -1
- plain_code-0.10.0/plain/code/CHANGELOG.md +0 -54
- {plain_code-0.10.0 → plain_code-0.12.0}/.gitignore +0 -0
- {plain_code-0.10.0 → plain_code-0.12.0}/LICENSE +0 -0
- {plain_code-0.10.0 → plain_code-0.12.0}/README.md +0 -0
- {plain_code-0.10.0 → plain_code-0.12.0}/plain/code/__init__.py +0 -0
- {plain_code-0.10.0 → plain_code-0.12.0}/plain/code/biome_defaults.json +0 -0
- {plain_code-0.10.0 → plain_code-0.12.0}/plain/code/ruff_defaults.toml +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plain.code
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.12.0
|
|
4
4
|
Summary: Preconfigured code formatting and linting.
|
|
5
5
|
Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
6
7
|
License-File: LICENSE
|
|
7
8
|
Requires-Python: >=3.13
|
|
8
9
|
Requires-Dist: plain<1.0.0
|
|
9
10
|
Requires-Dist: requests>=2.0.0
|
|
10
11
|
Requires-Dist: ruff>=0.1.0
|
|
11
12
|
Requires-Dist: tomlkit>=0.11.0
|
|
13
|
+
Requires-Dist: ty>=0.0.1a27
|
|
12
14
|
Description-Content-Type: text/markdown
|
|
13
15
|
|
|
14
16
|
# plain.code
|
|
@@ -21,7 +23,13 @@ Description-Content-Type: text/markdown
|
|
|
21
23
|
|
|
22
24
|
## Overview
|
|
23
25
|
|
|
24
|
-
The `plain code` command
|
|
26
|
+
The `plain code` command provides comprehensive code quality tools:
|
|
27
|
+
|
|
28
|
+
- **[Ruff](https://astral.sh/ruff)** - Python linting and formatting
|
|
29
|
+
- **[ty](https://astral.sh/ty)** - Python type checking
|
|
30
|
+
- **[Biome](https://biomejs.dev/)** - JavaScript, JSON, and CSS formatting
|
|
31
|
+
|
|
32
|
+
Ruff and ty are installed as Python dependencies. Biome is managed automatically as a standalone binary (npm is not required).
|
|
25
33
|
|
|
26
34
|
The most used command is `plain code fix`, which can be run using the alias `plain fix`:
|
|
27
35
|
|
|
@@ -33,6 +41,25 @@ This will automatically fix linting issues and format your code according to the
|
|
|
33
41
|
|
|
34
42
|

|
|
35
43
|
|
|
44
|
+
To check your code without making changes (including type checking):
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
plain code check
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
You can skip specific tools if needed:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Skip type checking during rapid development
|
|
54
|
+
plain code check --skip-ty
|
|
55
|
+
|
|
56
|
+
# Only run type checks
|
|
57
|
+
plain code check --skip-ruff --skip-biome
|
|
58
|
+
|
|
59
|
+
# Skip Biome checks
|
|
60
|
+
plain code check --skip-biome
|
|
61
|
+
```
|
|
62
|
+
|
|
36
63
|
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.
|
|
37
64
|
|
|
38
65
|
## Configuration
|
|
@@ -45,6 +72,9 @@ You can customize the behavior in your `pyproject.toml`:
|
|
|
45
72
|
[tool.plain.code]
|
|
46
73
|
exclude = ["path/to/exclude"]
|
|
47
74
|
|
|
75
|
+
[tool.plain.code.ty]
|
|
76
|
+
enabled = true # Set to false to disable ty
|
|
77
|
+
|
|
48
78
|
[tool.plain.code.biome]
|
|
49
79
|
enabled = true # Set to false to disable Biome
|
|
50
80
|
version = "1.5.3" # Pin to a specific version
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# plain-code changelog
|
|
2
|
+
|
|
3
|
+
## [0.12.0](https://github.com/dropseed/plain/releases/plain-code@0.12.0) (2025-11-24)
|
|
4
|
+
|
|
5
|
+
### What's changed
|
|
6
|
+
|
|
7
|
+
- Added [ty](https://astral.sh/ty) type checker integration, running automatically as part of `plain code check` ([40db43a](https://github.com/dropseed/plain/commit/40db43a))
|
|
8
|
+
- Added `--skip-ruff`, `--skip-ty`, and `--skip-biome` flags to `plain code check` for selectively skipping tools ([40db43a](https://github.com/dropseed/plain/commit/40db43a))
|
|
9
|
+
- ty can be disabled in configuration via `[tool.plain.code.ty]` with `enabled = false` ([40db43a](https://github.com/dropseed/plain/commit/40db43a))
|
|
10
|
+
|
|
11
|
+
### Upgrade instructions
|
|
12
|
+
|
|
13
|
+
- No changes required
|
|
14
|
+
|
|
15
|
+
## [0.11.4](https://github.com/dropseed/plain/releases/plain-code@0.11.4) (2025-11-17)
|
|
16
|
+
|
|
17
|
+
### What's changed
|
|
18
|
+
|
|
19
|
+
- The `plain fix` command now displays styled output that matches the format of `plain code check`, showing the tool name in bold and the command being run in dim text ([cde9a8e](https://github.com/dropseed/plain/commit/cde9a8e))
|
|
20
|
+
|
|
21
|
+
### Upgrade instructions
|
|
22
|
+
|
|
23
|
+
- No changes required
|
|
24
|
+
|
|
25
|
+
## [0.11.3](https://github.com/dropseed/plain/releases/plain-code@0.11.3) (2025-11-03)
|
|
26
|
+
|
|
27
|
+
### What's changed
|
|
28
|
+
|
|
29
|
+
- Improved CLI command descriptions to be more concise and user-friendly ([fdb9e80](https://github.com/dropseed/plain/commit/fdb9e80))
|
|
30
|
+
- The `plain fix` command is now marked as a common command and registered as a shortcut for `plain code fix` ([73d3a48](https://github.com/dropseed/plain/commit/73d3a48), [7910a06](https://github.com/dropseed/plain/commit/7910a06))
|
|
31
|
+
|
|
32
|
+
### Upgrade instructions
|
|
33
|
+
|
|
34
|
+
- No changes required
|
|
35
|
+
|
|
36
|
+
## [0.11.2](https://github.com/dropseed/plain/releases/plain-code@0.11.2) (2025-10-31)
|
|
37
|
+
|
|
38
|
+
### What's changed
|
|
39
|
+
|
|
40
|
+
- Added BSD-3-Clause license identifier to package metadata ([8477355](https://github.com/dropseed/plain/commit/8477355))
|
|
41
|
+
|
|
42
|
+
### Upgrade instructions
|
|
43
|
+
|
|
44
|
+
- No changes required
|
|
45
|
+
|
|
46
|
+
## [0.11.1](https://github.com/dropseed/plain/releases/plain-code@0.11.1) (2025-10-27)
|
|
47
|
+
|
|
48
|
+
### What's changed
|
|
49
|
+
|
|
50
|
+
- Improved `plain code check` output with styled command labels and a clearer error message when checks fail ([5e75a0d](https://github.com/dropseed/plain/commit/5e75a0d))
|
|
51
|
+
|
|
52
|
+
### Upgrade instructions
|
|
53
|
+
|
|
54
|
+
- No changes required
|
|
55
|
+
|
|
56
|
+
## [0.11.0](https://github.com/dropseed/plain/releases/plain-code@0.11.0) (2025-10-22)
|
|
57
|
+
|
|
58
|
+
### What's changed
|
|
59
|
+
|
|
60
|
+
- All CLI commands now skip runtime setup for faster execution by using the `@without_runtime_setup` decorator ([b7358d7](https://github.com/dropseed/plain/commit/b7358d7))
|
|
61
|
+
|
|
62
|
+
### Upgrade instructions
|
|
63
|
+
|
|
64
|
+
- No changes required
|
|
65
|
+
|
|
66
|
+
## [0.10.2](https://github.com/dropseed/plain/releases/plain-code@0.10.2) (2025-10-06)
|
|
67
|
+
|
|
68
|
+
### What's changed
|
|
69
|
+
|
|
70
|
+
- Added comprehensive type annotations throughout the codebase for improved IDE support and type checking ([7455fa0](https://github.com/dropseed/plain/commit/7455fa0))
|
|
71
|
+
|
|
72
|
+
### Upgrade instructions
|
|
73
|
+
|
|
74
|
+
- No changes required
|
|
75
|
+
|
|
76
|
+
## [0.10.1](https://github.com/dropseed/plain/releases/plain-code@0.10.1) (2025-09-25)
|
|
77
|
+
|
|
78
|
+
### What's changed
|
|
79
|
+
|
|
80
|
+
- Improved Biome download performance by using larger chunk sizes (1MB instead of 8KB) for faster binary downloads ([9bf4eca](https://github.com/dropseed/plain/commit/9bf4eca))
|
|
81
|
+
|
|
82
|
+
### Upgrade instructions
|
|
83
|
+
|
|
84
|
+
- No changes required
|
|
85
|
+
|
|
86
|
+
## [0.10.0](https://github.com/dropseed/plain/releases/plain-code@0.10.0) (2025-09-19)
|
|
87
|
+
|
|
88
|
+
### What's changed
|
|
89
|
+
|
|
90
|
+
- Minimum Python version increased from 3.11 to 3.13 ([d86e307](https://github.com/dropseed/plain/commit/d86e307))
|
|
91
|
+
|
|
92
|
+
### Upgrade instructions
|
|
93
|
+
|
|
94
|
+
- Ensure your Python environment is running Python 3.13 or later before upgrading
|
|
95
|
+
|
|
96
|
+
## [0.9.2](https://github.com/dropseed/plain/releases/plain-code@0.9.2) (2025-07-30)
|
|
97
|
+
|
|
98
|
+
### What's changed
|
|
99
|
+
|
|
100
|
+
- Skip Biome installation and updates when Biome is disabled in configuration ([b8beb5c](https://github.com/dropseed/plain/commit/b8beb5c))
|
|
101
|
+
- Enhanced README with better structure, usage examples, and configuration documentation ([4ebecd1](https://github.com/dropseed/plain/commit/4ebecd1))
|
|
102
|
+
|
|
103
|
+
### Upgrade instructions
|
|
104
|
+
|
|
105
|
+
- No changes required
|
|
106
|
+
|
|
107
|
+
## [0.9.1](https://github.com/dropseed/plain/releases/plain-code@0.9.1) (2025-07-18)
|
|
108
|
+
|
|
109
|
+
### What's changed
|
|
110
|
+
|
|
111
|
+
- Improved error handling by using `click.UsageError` instead of `print` and `sys.exit` for better CLI error messages ([88f06c5](https://github.com/dropseed/plain/commit/88f06c5))
|
|
112
|
+
|
|
113
|
+
### Upgrade instructions
|
|
114
|
+
|
|
115
|
+
- No changes required
|
|
116
|
+
|
|
117
|
+
## [0.9.0](https://github.com/dropseed/plain/releases/plain-code@0.9.0) (2025-07-03)
|
|
118
|
+
|
|
119
|
+
### What's changed
|
|
120
|
+
|
|
121
|
+
- Updated Biome integration to support the new **Biome 2** release. The download logic now uses the new `@biomejs/biome@<version>` tag format and the built-in default configuration has been modernised (`root: true`, `files.includes`, etc.) ([83fa906](https://github.com/dropseed/plain/commit/83fa906)).
|
|
122
|
+
- A progress bar is now displayed while the Biome binary is being downloaded so you can see the download progress in real time ([ec637aa](https://github.com/dropseed/plain/commit/ec637aa)).
|
|
123
|
+
|
|
124
|
+
### Upgrade instructions
|
|
125
|
+
|
|
126
|
+
- If you have pinned a specific Biome version in your `pyproject.toml` under `[tool.plain.code.biome]`, make sure it is compatible with Biome 2 (for example, `version = "2.0.0"`). Otherwise, use `plain code update` to update to Biome 2.
|
|
127
|
+
|
|
128
|
+
## [0.8.3](https://github.com/dropseed/plain/releases/plain-code@0.8.3) (2025-06-26)
|
|
129
|
+
|
|
130
|
+
### What's changed
|
|
131
|
+
|
|
132
|
+
- Added this `CHANGELOG.md` file to start tracking changes for the `plain.code` package ([82710c3](https://github.com/dropseed/plain/commit/82710c3)).
|
|
133
|
+
- No functional changes were introduced in this release.
|
|
134
|
+
|
|
135
|
+
### Upgrade instructions
|
|
136
|
+
|
|
137
|
+
- No changes required
|
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
## Overview
|
|
10
10
|
|
|
11
|
-
The `plain code` command
|
|
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).
|
|
12
18
|
|
|
13
19
|
The most used command is `plain code fix`, which can be run using the alias `plain fix`:
|
|
14
20
|
|
|
@@ -20,6 +26,25 @@ This will automatically fix linting issues and format your code according to the
|
|
|
20
26
|
|
|
21
27
|

|
|
22
28
|
|
|
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
|
+
|
|
23
48
|
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.
|
|
24
49
|
|
|
25
50
|
## Configuration
|
|
@@ -32,6 +57,9 @@ You can customize the behavior in your `pyproject.toml`:
|
|
|
32
57
|
[tool.plain.code]
|
|
33
58
|
exclude = ["path/to/exclude"]
|
|
34
59
|
|
|
60
|
+
[tool.plain.code.ty]
|
|
61
|
+
enabled = true # Set to false to disable ty
|
|
62
|
+
|
|
35
63
|
[tool.plain.code.biome]
|
|
36
64
|
enabled = true # Set to false to disable Biome
|
|
37
65
|
version = "1.5.3" # Pin to a specific version
|
|
@@ -121,11 +121,11 @@ class Biome:
|
|
|
121
121
|
label="Downloading Biome",
|
|
122
122
|
width=0,
|
|
123
123
|
) as bar:
|
|
124
|
-
for chunk in resp.iter_content(chunk_size=
|
|
124
|
+
for chunk in resp.iter_content(chunk_size=1024 * 1024):
|
|
125
125
|
f.write(chunk)
|
|
126
126
|
bar.update(len(chunk))
|
|
127
127
|
else:
|
|
128
|
-
for chunk in resp.iter_content(chunk_size=
|
|
128
|
+
for chunk in resp.iter_content(chunk_size=1024 * 1024):
|
|
129
129
|
f.write(chunk)
|
|
130
130
|
os.chmod(self.standalone_path, 0o755)
|
|
131
131
|
|
|
@@ -153,7 +153,7 @@ class Biome:
|
|
|
153
153
|
self.set_version_in_config(v)
|
|
154
154
|
return v
|
|
155
155
|
|
|
156
|
-
def invoke(self, *args, cwd=None) -> subprocess.CompletedProcess:
|
|
156
|
+
def invoke(self, *args: str, cwd: str | None = None) -> subprocess.CompletedProcess:
|
|
157
157
|
# Run the standalone biome binary with given args
|
|
158
158
|
config_path = os.path.abspath(
|
|
159
159
|
os.path.join(os.path.dirname(__file__), "biome_defaults.json")
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import subprocess
|
|
2
4
|
import sys
|
|
3
5
|
import tomllib
|
|
4
6
|
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
5
8
|
|
|
6
9
|
import click
|
|
7
10
|
|
|
8
11
|
from plain.cli import register_cli
|
|
9
12
|
from plain.cli.print import print_event
|
|
13
|
+
from plain.cli.runtime import common_command, without_runtime_setup
|
|
10
14
|
|
|
11
15
|
from .biome import Biome
|
|
12
16
|
|
|
13
17
|
DEFAULT_RUFF_CONFIG = Path(__file__).parent / "ruff_defaults.toml"
|
|
14
18
|
|
|
15
19
|
|
|
20
|
+
@without_runtime_setup
|
|
16
21
|
@register_cli("code")
|
|
17
22
|
@click.group()
|
|
18
|
-
def cli():
|
|
23
|
+
def cli() -> None:
|
|
19
24
|
"""Code formatting and linting"""
|
|
20
25
|
pass
|
|
21
26
|
|
|
22
27
|
|
|
28
|
+
@without_runtime_setup
|
|
23
29
|
@cli.command()
|
|
24
30
|
@click.option("--force", is_flag=True, help="Reinstall even if up to date")
|
|
25
31
|
@click.pass_context
|
|
26
|
-
def install(ctx, force):
|
|
27
|
-
"""Install or update
|
|
32
|
+
def install(ctx: click.Context, force: bool) -> None:
|
|
33
|
+
"""Install or update Biome binary"""
|
|
28
34
|
config = get_code_config()
|
|
29
35
|
|
|
30
36
|
if not config.get("biome", {}).get("enabled", True):
|
|
@@ -49,9 +55,10 @@ def install(ctx, force):
|
|
|
49
55
|
click.secho("Biome already installed", fg="green")
|
|
50
56
|
|
|
51
57
|
|
|
58
|
+
@without_runtime_setup
|
|
52
59
|
@cli.command()
|
|
53
|
-
def update():
|
|
54
|
-
"""Update
|
|
60
|
+
def update() -> None:
|
|
61
|
+
"""Update Biome to latest version"""
|
|
55
62
|
config = get_code_config()
|
|
56
63
|
|
|
57
64
|
if not config.get("biome", {}).get("enabled", True):
|
|
@@ -64,47 +71,78 @@ def update():
|
|
|
64
71
|
click.secho(f"Biome {version} installed", fg="green")
|
|
65
72
|
|
|
66
73
|
|
|
74
|
+
@without_runtime_setup
|
|
67
75
|
@cli.command()
|
|
68
76
|
@click.pass_context
|
|
69
77
|
@click.argument("path", default=".")
|
|
70
|
-
|
|
71
|
-
|
|
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:
|
|
88
|
+
"""Check for formatting and linting issues"""
|
|
72
89
|
ruff_args = ["--config", str(DEFAULT_RUFF_CONFIG)]
|
|
73
90
|
config = get_code_config()
|
|
74
91
|
|
|
75
92
|
for e in config.get("exclude", []):
|
|
76
93
|
ruff_args.extend(["--exclude", e])
|
|
77
94
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
def maybe_exit(return_code: int) -> None:
|
|
96
|
+
if return_code != 0:
|
|
97
|
+
click.secho(
|
|
98
|
+
"\nCode check failed. Run `plain fix` and/or fix issues manually.",
|
|
99
|
+
fg="red",
|
|
100
|
+
err=True,
|
|
101
|
+
)
|
|
102
|
+
sys.exit(return_code)
|
|
82
103
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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)
|
|
87
110
|
|
|
88
|
-
|
|
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)
|
|
117
|
+
|
|
118
|
+
if not skip_ty and config.get("ty", {}).get("enabled", True):
|
|
119
|
+
print_event(click.style("Ty:", bold=True) + click.style(" ty check", dim=True))
|
|
120
|
+
result = subprocess.run(["ty", "check", path])
|
|
121
|
+
maybe_exit(result.returncode)
|
|
122
|
+
|
|
123
|
+
if not skip_biome and config.get("biome", {}).get("enabled", True):
|
|
89
124
|
biome = Biome()
|
|
90
125
|
|
|
91
126
|
if biome.needs_update():
|
|
92
127
|
ctx.invoke(install)
|
|
93
128
|
|
|
94
|
-
print_event(
|
|
129
|
+
print_event(
|
|
130
|
+
click.style("Biome:", bold=True) + click.style(" biome check", dim=True)
|
|
131
|
+
)
|
|
95
132
|
result = biome.invoke("check", path)
|
|
96
|
-
|
|
97
|
-
sys.exit(result.returncode)
|
|
133
|
+
maybe_exit(result.returncode)
|
|
98
134
|
|
|
99
135
|
|
|
100
|
-
@
|
|
136
|
+
@common_command
|
|
137
|
+
@without_runtime_setup
|
|
138
|
+
@register_cli("fix", shortcut_for="code fix")
|
|
101
139
|
@cli.command()
|
|
102
140
|
@click.pass_context
|
|
103
141
|
@click.argument("path", default=".")
|
|
104
142
|
@click.option("--unsafe-fixes", is_flag=True, help="Apply ruff unsafe fixes")
|
|
105
143
|
@click.option("--add-noqa", is_flag=True, help="Add noqa comments to suppress errors")
|
|
106
|
-
def fix(ctx, path, unsafe_fixes, add_noqa):
|
|
107
|
-
"""
|
|
144
|
+
def fix(ctx: click.Context, path: str, unsafe_fixes: bool, add_noqa: bool) -> None:
|
|
145
|
+
"""Fix formatting and linting issues"""
|
|
108
146
|
ruff_args = ["--config", str(DEFAULT_RUFF_CONFIG)]
|
|
109
147
|
config = get_code_config()
|
|
110
148
|
|
|
@@ -115,21 +153,32 @@ def fix(ctx, path, unsafe_fixes, add_noqa):
|
|
|
115
153
|
raise click.UsageError("Cannot use both --unsafe-fixes and --add-noqa")
|
|
116
154
|
|
|
117
155
|
if unsafe_fixes:
|
|
118
|
-
print_event(
|
|
156
|
+
print_event(
|
|
157
|
+
click.style("Ruff lint:", bold=True)
|
|
158
|
+
+ click.style(" ruff check --fix --unsafe-fixes", dim=True)
|
|
159
|
+
)
|
|
119
160
|
result = subprocess.run(
|
|
120
161
|
["ruff", "check", path, "--fix", "--unsafe-fixes", *ruff_args]
|
|
121
162
|
)
|
|
122
163
|
elif add_noqa:
|
|
123
|
-
print_event(
|
|
164
|
+
print_event(
|
|
165
|
+
click.style("Ruff lint:", bold=True)
|
|
166
|
+
+ click.style(" ruff check --add-noqa", dim=True)
|
|
167
|
+
)
|
|
124
168
|
result = subprocess.run(["ruff", "check", path, "--add-noqa", *ruff_args])
|
|
125
169
|
else:
|
|
126
|
-
print_event(
|
|
170
|
+
print_event(
|
|
171
|
+
click.style("Ruff lint:", bold=True)
|
|
172
|
+
+ click.style(" ruff check --fix", dim=True)
|
|
173
|
+
)
|
|
127
174
|
result = subprocess.run(["ruff", "check", path, "--fix", *ruff_args])
|
|
128
175
|
|
|
129
176
|
if result.returncode != 0:
|
|
130
177
|
sys.exit(result.returncode)
|
|
131
178
|
|
|
132
|
-
print_event(
|
|
179
|
+
print_event(
|
|
180
|
+
click.style("Ruff format:", bold=True) + click.style(" ruff format", dim=True)
|
|
181
|
+
)
|
|
133
182
|
result = subprocess.run(["ruff", "format", path, *ruff_args])
|
|
134
183
|
if result.returncode != 0:
|
|
135
184
|
sys.exit(result.returncode)
|
|
@@ -140,12 +189,19 @@ def fix(ctx, path, unsafe_fixes, add_noqa):
|
|
|
140
189
|
if biome.needs_update():
|
|
141
190
|
ctx.invoke(install)
|
|
142
191
|
|
|
143
|
-
print_event("Biome format")
|
|
144
|
-
|
|
145
192
|
args = ["check", path, "--write"]
|
|
146
193
|
|
|
147
194
|
if unsafe_fixes:
|
|
148
195
|
args.append("--unsafe")
|
|
196
|
+
print_event(
|
|
197
|
+
click.style("Biome:", bold=True)
|
|
198
|
+
+ click.style(" biome check --write --unsafe", dim=True)
|
|
199
|
+
)
|
|
200
|
+
else:
|
|
201
|
+
print_event(
|
|
202
|
+
click.style("Biome:", bold=True)
|
|
203
|
+
+ click.style(" biome check --write", dim=True)
|
|
204
|
+
)
|
|
149
205
|
|
|
150
206
|
result = biome.invoke(*args)
|
|
151
207
|
|
|
@@ -153,7 +209,7 @@ def fix(ctx, path, unsafe_fixes, add_noqa):
|
|
|
153
209
|
sys.exit(result.returncode)
|
|
154
210
|
|
|
155
211
|
|
|
156
|
-
def get_code_config():
|
|
212
|
+
def get_code_config() -> dict[str, Any]:
|
|
157
213
|
pyproject = Path("pyproject.toml")
|
|
158
214
|
if not pyproject.exists():
|
|
159
215
|
return {}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "plain.code"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.12.0"
|
|
4
4
|
description = "Preconfigured code formatting and linting."
|
|
5
5
|
authors = [{name = "Dave Gaeddert", email = "dave.gaeddert@dropseed.dev"}]
|
|
6
6
|
readme = "README.md"
|
|
7
|
+
license = "BSD-3-Clause"
|
|
7
8
|
requires-python = ">=3.13"
|
|
8
9
|
dependencies = [
|
|
9
10
|
"plain<1.0.0",
|
|
10
11
|
"ruff>=0.1.0",
|
|
12
|
+
"ty>=0.0.1a27",
|
|
11
13
|
"requests>=2.0.0",
|
|
12
14
|
"tomlkit>=0.11.0",
|
|
13
15
|
]
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# plain-code changelog
|
|
2
|
-
|
|
3
|
-
## [0.10.0](https://github.com/dropseed/plain/releases/plain-code@0.10.0) (2025-09-19)
|
|
4
|
-
|
|
5
|
-
### What's changed
|
|
6
|
-
|
|
7
|
-
- Minimum Python version increased from 3.11 to 3.13 ([d86e307](https://github.com/dropseed/plain/commit/d86e307))
|
|
8
|
-
|
|
9
|
-
### Upgrade instructions
|
|
10
|
-
|
|
11
|
-
- Ensure your Python environment is running Python 3.13 or later before upgrading
|
|
12
|
-
|
|
13
|
-
## [0.9.2](https://github.com/dropseed/plain/releases/plain-code@0.9.2) (2025-07-30)
|
|
14
|
-
|
|
15
|
-
### What's changed
|
|
16
|
-
|
|
17
|
-
- Skip Biome installation and updates when Biome is disabled in configuration ([b8beb5c](https://github.com/dropseed/plain/commit/b8beb5c))
|
|
18
|
-
- Enhanced README with better structure, usage examples, and configuration documentation ([4ebecd1](https://github.com/dropseed/plain/commit/4ebecd1))
|
|
19
|
-
|
|
20
|
-
### Upgrade instructions
|
|
21
|
-
|
|
22
|
-
- No changes required
|
|
23
|
-
|
|
24
|
-
## [0.9.1](https://github.com/dropseed/plain/releases/plain-code@0.9.1) (2025-07-18)
|
|
25
|
-
|
|
26
|
-
### What's changed
|
|
27
|
-
|
|
28
|
-
- Improved error handling by using `click.UsageError` instead of `print` and `sys.exit` for better CLI error messages ([88f06c5](https://github.com/dropseed/plain/commit/88f06c5))
|
|
29
|
-
|
|
30
|
-
### Upgrade instructions
|
|
31
|
-
|
|
32
|
-
- No changes required
|
|
33
|
-
|
|
34
|
-
## [0.9.0](https://github.com/dropseed/plain/releases/plain-code@0.9.0) (2025-07-03)
|
|
35
|
-
|
|
36
|
-
### What's changed
|
|
37
|
-
|
|
38
|
-
- Updated Biome integration to support the new **Biome 2** release. The download logic now uses the new `@biomejs/biome@<version>` tag format and the built-in default configuration has been modernised (`root: true`, `files.includes`, etc.) ([83fa906](https://github.com/dropseed/plain/commit/83fa906)).
|
|
39
|
-
- A progress bar is now displayed while the Biome binary is being downloaded so you can see the download progress in real time ([ec637aa](https://github.com/dropseed/plain/commit/ec637aa)).
|
|
40
|
-
|
|
41
|
-
### Upgrade instructions
|
|
42
|
-
|
|
43
|
-
- If you have pinned a specific Biome version in your `pyproject.toml` under `[tool.plain.code.biome]`, make sure it is compatible with Biome 2 (for example, `version = "2.0.0"`). Otherwise, use `plain code update` to update to Biome 2.
|
|
44
|
-
|
|
45
|
-
## [0.8.3](https://github.com/dropseed/plain/releases/plain-code@0.8.3) (2025-06-26)
|
|
46
|
-
|
|
47
|
-
### What's changed
|
|
48
|
-
|
|
49
|
-
- Added this `CHANGELOG.md` file to start tracking changes for the `plain.code` package ([82710c3](https://github.com/dropseed/plain/commit/82710c3)).
|
|
50
|
-
- No functional changes were introduced in this release.
|
|
51
|
-
|
|
52
|
-
### Upgrade instructions
|
|
53
|
-
|
|
54
|
-
- No changes required
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|