Skip to content

Commit 2dc5d7a

Browse files
Add --status flag to usethis init. Remove default for usethis status
1 parent af41da0 commit 2dc5d7a

7 files changed

Lines changed: 63 additions & 22 deletions

File tree

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ Supported options:
189189
- `numpy` for [NumPy docstring style](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard)
190190
- `google` for [Google docstring style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
191191
- `pep257` for [PEP 257 docstring style](https://www.python.org/dev/peps/pep-0257/)
192+
- `--status` to set the development status of the project. Defaults to `planning`.
193+
Possible values:
194+
- `planning` or `1` for "Development Status :: 1 - Planning"
195+
- `pre-alpha` or `2` for "Development Status :: 2 - Pre-Alpha"
196+
- `alpha` or `3` for "Development Status :: 3 - Alpha"
197+
- `beta` or `4` for "Development Status :: 4 - Beta"
198+
- `production` or `5` for "Development Status :: 5 - Production/Stable"
199+
- `mature` or `6` for "Development Status :: 6 - Mature"
200+
- `inactive` or `7` for "Development Status :: 7 - Inactive"
192201
- `--offline` to disable network access and rely on caches
193202
- `--quiet` to suppress output
194203
- `--frozen` to leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles)
@@ -416,9 +425,7 @@ Supported options:
416425

417426
Set the development status of the project via trove classifiers.
418427

419-
By default, the status is set to "Development Status :: 1 - Planning".
420-
421-
Possible values:
428+
Possible values (required):
422429

423430
- `usethis status planning` or `usethis status 1` for "Development Status :: 1 - Planning"
424431
- `usethis status pre-alpha` or `usethis status 2` for "Development Status :: 2 - Pre-Alpha"

src/usethis/_core/status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def use_development_status(
3333

3434
dispstatus = new_classifier.removeprefix("Development Status :: ")
3535

36-
tick_print(f"Setting development status to '{dispstatus}'.")
36+
tick_print(f"Setting the development status to '{dispstatus}'.")
3737

3838
mgr = PyprojectTOMLManager()
3939
try:

src/usethis/_interface/init.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import typer
24
from typing_extensions import assert_never
35

@@ -16,6 +18,7 @@
1618
)
1719
from usethis._core.docstyle import DocStyleEnum, use_docstyle
1820
from usethis._core.readme import add_readme
21+
from usethis._core.status import DevelopmentStatusEnum, use_development_status
1922
from usethis._core.tool import use_pre_commit
2023
from usethis._integrations.uv.init import opinionated_uv_init
2124
from usethis._toolset.format_ import use_formatters
@@ -25,7 +28,7 @@
2528
from usethis.errors import UsethisError
2629

2730

28-
def init( # noqa: PLR0913
31+
def init( # noqa: PLR0913, PLR0915
2932
format_: bool = typer.Option(
3033
True, "--format/--no-format", help="Add recommended formatters."
3134
),
@@ -57,6 +60,11 @@ def init( # noqa: PLR0913
5760
"--docstyle",
5861
help="Set a docstring style convention for the project.",
5962
),
63+
status: DevelopmentStatusEnum = typer.Option(
64+
"planning",
65+
"--status",
66+
help="Set the development status of the project.",
67+
),
6068
offline: bool = offline_opt,
6169
quiet: bool = quiet_opt,
6270
frozen: bool = frozen_opt,
@@ -81,6 +89,9 @@ def init( # noqa: PLR0913
8189
opinionated_uv_init()
8290
add_readme()
8391

92+
assert isinstance(status, DevelopmentStatusEnum)
93+
use_development_status(status)
94+
8495
if pre_commit:
8596
tick_print("Adding the pre-commit framework.")
8697
with usethis_config.set(alert_only=True):

src/usethis/_interface/status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
def status(
1616
status: DevelopmentStatusEnum = typer.Argument(
17-
default="planning", help="Docstring style to enforce."
17+
default=..., help="Docstring style to enforce."
1818
),
1919
quiet: bool = quiet_opt,
2020
) -> None:

tests/usethis/_core/test_status.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_planning(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
2727
)
2828
out, err = capfd.readouterr()
2929
assert not err
30-
assert out == "✔ Setting development status to '1 - Planning'.\n"
30+
assert out == "✔ Setting the development status to '1 - Planning'.\n"
3131

3232
def test_planning_code(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
3333
# Arrange
@@ -48,7 +48,7 @@ def test_planning_code(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str
4848
)
4949
out, err = capfd.readouterr()
5050
assert not err
51-
assert out == "✔ Setting development status to '1 - Planning'.\n"
51+
assert out == "✔ Setting the development status to '1 - Planning'.\n"
5252

5353
def test_prealpha(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
5454
# Arrange
@@ -69,7 +69,7 @@ def test_prealpha(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
6969
)
7070
out, err = capfd.readouterr()
7171
assert not err
72-
assert out == "✔ Setting development status to '2 - Pre-Alpha'.\n"
72+
assert out == "✔ Setting the development status to '2 - Pre-Alpha'.\n"
7373

7474
def test_alpha(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
7575
# Arrange
@@ -88,7 +88,7 @@ def test_alpha(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
8888
assert "Development Status :: 3 - Alpha" in mgr[["project", "classifiers"]]
8989
out, err = capfd.readouterr()
9090
assert not err
91-
assert out == "✔ Setting development status to '3 - Alpha'.\n"
91+
assert out == "✔ Setting the development status to '3 - Alpha'.\n"
9292

9393
def test_beta(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
9494
# Arrange
@@ -107,7 +107,7 @@ def test_beta(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
107107
assert "Development Status :: 4 - Beta" in mgr[["project", "classifiers"]]
108108
out, err = capfd.readouterr()
109109
assert not err
110-
assert out == "✔ Setting development status to '4 - Beta'.\n"
110+
assert out == "✔ Setting the development status to '4 - Beta'.\n"
111111

112112
def test_production(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
113113
# Arrange
@@ -129,7 +129,7 @@ def test_production(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
129129
)
130130
out, err = capfd.readouterr()
131131
assert not err
132-
assert out == "✔ Setting development status to '5 - Production/Stable'.\n"
132+
assert out == "✔ Setting the development status to '5 - Production/Stable'.\n"
133133

134134
def test_mature(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
135135
# Arrange
@@ -148,7 +148,7 @@ def test_mature(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
148148
assert "Development Status :: 6 - Mature" in mgr[["project", "classifiers"]]
149149
out, err = capfd.readouterr()
150150
assert not err
151-
assert out == "✔ Setting development status to '6 - Mature'.\n"
151+
assert out == "✔ Setting the development status to '6 - Mature'.\n"
152152

153153
def test_inactive(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
154154
# Arrange
@@ -169,7 +169,7 @@ def test_inactive(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
169169
)
170170
out, err = capfd.readouterr()
171171
assert not err
172-
assert out == "✔ Setting development status to '7 - Inactive'.\n"
172+
assert out == "✔ Setting the development status to '7 - Inactive'.\n"
173173

174174
def test_no_pyproject_toml(self, tmp_path: Path, capfd: pytest.CaptureFixture[str]):
175175
# Arrange
@@ -184,7 +184,7 @@ def test_no_pyproject_toml(self, tmp_path: Path, capfd: pytest.CaptureFixture[st
184184
assert not err
185185
assert out == (
186186
"✔ Writing 'pyproject.toml'.\n"
187-
"✔ Setting development status to '1 - Planning'.\n"
187+
"✔ Setting the development status to '1 - Planning'.\n"
188188
)
189189

190190
def test_replace_existing_classifier(
@@ -219,7 +219,7 @@ def test_replace_existing_classifier(
219219
)
220220
out, err = capfd.readouterr()
221221
assert not err
222-
assert out == "✔ Setting development status to '4 - Beta'.\n"
222+
assert out == "✔ Setting the development status to '4 - Beta'.\n"
223223

224224
def test_replace_multiple_existing_classifiers(
225225
self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]
@@ -259,4 +259,4 @@ def test_replace_multiple_existing_classifiers(
259259
)
260260
out, err = capfd.readouterr()
261261
assert not err
262-
assert out == "✔ Setting development status to '5 - Production/Stable'.\n"
262+
assert out == "✔ Setting the development status to '5 - Production/Stable'.\n"

tests/usethis/_interface/test_init.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ def test_pre_commit_included(self, tmp_path: Path):
1212
# Act
1313
runner = CliRunner()
1414
with change_cwd(tmp_path):
15-
result = runner.invoke(app, ["init", "--pre-commit"])
15+
result = runner.invoke(
16+
app, ["init", "--pre-commit"], catch_exceptions=False
17+
)
1618

1719
# Assert
1820
assert result.exit_code == 0, result.output
@@ -21,6 +23,7 @@ def test_pre_commit_included(self, tmp_path: Path):
2123
"✔ Writing 'pyproject.toml' and initializing project.\n"
2224
"✔ Writing 'README.md'.\n"
2325
"☐ Populate 'README.md' to help users understand the project.\n"
26+
"✔ Setting the development status to '1 - Planning'.\n"
2427
"✔ Adding the pre-commit framework.\n"
2528
"☐ Run 'uv run pre-commit run --all-files' to run the hooks manually.\n"
2629
"✔ Adding recommended linters.\n"
@@ -71,6 +74,7 @@ def test_readme_example(self, tmp_path: Path):
7174
✔ Writing 'pyproject.toml' and initializing project.
7275
✔ Writing 'README.md'.
7376
☐ Populate 'README.md' to help users understand the project.
77+
✔ Setting the development status to '1 - Planning'.
7478
✔ Adding recommended linters.
7579
☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.
7680
☐ Run 'uv run deptry src' to run deptry.
@@ -110,13 +114,22 @@ def test_no_err_when_pyproject_toml_exists(self, tmp_path: Path):
110114
# Assert
111115
assert result.exit_code == 0, result.output
112116

113-
def test_bitbucket_and_docstyle(self, tmp_path: Path):
117+
def test_bitbucket_docstyle_and_status(self, tmp_path: Path):
114118
# Act
115119
runner = CliRunner()
116120
with change_cwd(tmp_path):
117121
result = runner.invoke(
118122
app,
119-
["init", "--ci", "bitbucket", "--docstyle", "numpy", "--pre-commit"],
123+
[
124+
"init",
125+
"--ci",
126+
"bitbucket",
127+
"--docstyle",
128+
"numpy",
129+
"--pre-commit",
130+
"--status",
131+
"production",
132+
],
120133
)
121134

122135
# Assert
@@ -126,6 +139,7 @@ def test_bitbucket_and_docstyle(self, tmp_path: Path):
126139
"✔ Writing 'pyproject.toml' and initializing project.\n"
127140
"✔ Writing 'README.md'.\n"
128141
"☐ Populate 'README.md' to help users understand the project.\n"
142+
"✔ Setting the development status to '5 - Production/Stable'.\n"
129143
"✔ Adding the pre-commit framework.\n"
130144
"☐ Run 'uv run pre-commit run --all-files' to run the hooks manually.\n"
131145
"✔ Adding recommended linters.\n"

tests/usethis/_interface/test_status.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_successful(self, tmp_path: Path):
1616
# Assert
1717
assert result.exit_code == 0, result.output
1818
assert result.output == (
19-
"✔ Writing 'pyproject.toml'.\n✔ Setting development status to '4 - Beta'.\n"
19+
"✔ Writing 'pyproject.toml'.\n✔ Setting the development status to '4 - Beta'.\n"
2020
)
2121

2222
def test_numerical_code(self, tmp_path: Path):
@@ -28,5 +28,14 @@ def test_numerical_code(self, tmp_path: Path):
2828
# Assert
2929
assert result.exit_code == 0, result.output
3030
assert result.output == (
31-
"✔ Writing 'pyproject.toml'.\n✔ Setting development status to '5 - Production/Stable'.\n"
31+
"✔ Writing 'pyproject.toml'.\n✔ Setting the development status to '5 - Production/Stable'.\n"
3232
)
33+
34+
def test_no_args(self, tmp_path: Path):
35+
# Act
36+
runner = CliRunner()
37+
with change_cwd(tmp_path):
38+
result = runner.invoke(app, ["status"])
39+
40+
# Assert
41+
assert result.exit_code == 2, result.output

0 commit comments

Comments
 (0)