fast-dev-cli 0.7.0__tar.gz → 0.7.2__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.
- {fast_dev_cli-0.7.0 → fast_dev_cli-0.7.2}/PKG-INFO +15 -6
- {fast_dev_cli-0.7.0 → fast_dev_cli-0.7.2}/README.md +6 -0
- fast_dev_cli-0.7.2/fast_dev_cli/__init__.py +31 -0
- {fast_dev_cli-0.7.0 → fast_dev_cli-0.7.2}/fast_dev_cli/cli.py +60 -10
- fast_dev_cli-0.7.2/pyproject.toml +50 -0
- fast_dev_cli-0.7.0/fast_dev_cli/__init__.py +0 -2
- fast_dev_cli-0.7.0/pyproject.toml +0 -53
- {fast_dev_cli-0.7.0 → fast_dev_cli-0.7.2}/LICENSE +0 -0
- {fast_dev_cli-0.7.0 → fast_dev_cli-0.7.2}/fast_dev_cli/__main__.py +0 -0
- {fast_dev_cli-0.7.0 → fast_dev_cli-0.7.2}/fast_dev_cli/py.typed +0 -0
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fast-dev-cli
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Waket Zheng
|
|
6
6
|
Author-email: waketzheng@gmail.com
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.10,<4.0
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
10
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
12
|
Provides-Extra: all
|
|
12
13
|
Requires-Dist: bumpversion (>=0.6.0,<0.7.0) ; extra == "all"
|
|
13
14
|
Requires-Dist: click (>=7.1.1)
|
|
14
15
|
Requires-Dist: coverage (>=6.5.0) ; extra == "all"
|
|
15
|
-
Requires-Dist: mypy (>=1.
|
|
16
|
-
Requires-Dist: pytest (>=8.
|
|
17
|
-
Requires-Dist: ruff (>=0.
|
|
18
|
-
Requires-Dist:
|
|
16
|
+
Requires-Dist: mypy (>=1.10.0,<2.0.0) ; extra == "all"
|
|
17
|
+
Requires-Dist: pytest (>=8.2.0,<9.0.0) ; extra == "all"
|
|
18
|
+
Requires-Dist: ruff (>=0.4.2,<0.5.0) ; extra == "all"
|
|
19
|
+
Requires-Dist: strenum (>=0.4.15) ; python_version < "3.11"
|
|
20
|
+
Requires-Dist: type-extensions (>=0.1.2) ; python_version < "3.11"
|
|
21
|
+
Requires-Dist: typer (>=0.12.3,<0.13.0) ; extra == "all"
|
|
19
22
|
Description-Content-Type: text/markdown
|
|
20
23
|
|
|
21
24
|
<p align="center">
|
|
@@ -37,6 +40,12 @@ Description-Content-Type: text/markdown
|
|
|
37
40
|
<a href="https://coveralls.io/github/waketzheng/fast-dev-cli?branch=main" target="_blank">
|
|
38
41
|
<img src="https://coveralls.io/repos/github/waketzheng/fast-dev-cli/badge.svg?branch=main" alt="Coverage Status">
|
|
39
42
|
</a>
|
|
43
|
+
<a href="https://github.com/astral-sh/ruff" target="_blank">
|
|
44
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
45
|
+
</a>
|
|
46
|
+
<a href="https://github.com/python/mypy" target="_blank">
|
|
47
|
+
<img src="https://img.shields.io/badge/mypy-100%25-green.svg" alt="Mypy Coverage">
|
|
48
|
+
</a>
|
|
40
49
|
</p>
|
|
41
50
|
|
|
42
51
|
---
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
<a href="https://coveralls.io/github/waketzheng/fast-dev-cli?branch=main" target="_blank">
|
|
18
18
|
<img src="https://coveralls.io/repos/github/waketzheng/fast-dev-cli/badge.svg?branch=main" alt="Coverage Status">
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://github.com/astral-sh/ruff" target="_blank">
|
|
21
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://github.com/python/mypy" target="_blank">
|
|
24
|
+
<img src="https://img.shields.io/badge/mypy-100%25-green.svg" alt="Mypy Coverage">
|
|
25
|
+
</a>
|
|
20
26
|
</p>
|
|
21
27
|
|
|
22
28
|
---
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from .cli import (
|
|
2
|
+
__version__,
|
|
3
|
+
bump,
|
|
4
|
+
bump_version,
|
|
5
|
+
check,
|
|
6
|
+
lint,
|
|
7
|
+
make_style,
|
|
8
|
+
only_check,
|
|
9
|
+
sync,
|
|
10
|
+
tag,
|
|
11
|
+
test,
|
|
12
|
+
upgrade,
|
|
13
|
+
upload,
|
|
14
|
+
version,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__ = (
|
|
18
|
+
"__version__",
|
|
19
|
+
"version",
|
|
20
|
+
"bump_version",
|
|
21
|
+
"bump",
|
|
22
|
+
"lint",
|
|
23
|
+
"check",
|
|
24
|
+
"upload",
|
|
25
|
+
"test",
|
|
26
|
+
"sync",
|
|
27
|
+
"tag",
|
|
28
|
+
"upgrade",
|
|
29
|
+
"make_style",
|
|
30
|
+
"only_check",
|
|
31
|
+
)
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import importlib.metadata
|
|
2
4
|
import os
|
|
3
5
|
import re
|
|
4
6
|
import subprocess
|
|
5
7
|
import sys
|
|
6
|
-
from enum import StrEnum
|
|
7
8
|
from functools import cached_property
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
from subprocess import CompletedProcess
|
|
10
|
-
from typing import
|
|
11
|
+
from typing import TYPE_CHECKING, Optional, Type
|
|
12
|
+
|
|
13
|
+
if sys.version_info >= (3, 11):
|
|
14
|
+
from enum import StrEnum
|
|
15
|
+
from typing import Self
|
|
16
|
+
else: # pragma: no cover
|
|
17
|
+
from strenum import StrEnum # type:ignore[no-redef,assignment]
|
|
18
|
+
from typing_extensions import Self
|
|
19
|
+
|
|
20
|
+
if TYPE_CHECKING:
|
|
21
|
+
from typer.models import OptionInfo
|
|
22
|
+
|
|
11
23
|
|
|
12
24
|
__version__ = importlib.metadata.version(Path(__file__).parent.name)
|
|
13
25
|
|
|
@@ -113,11 +125,17 @@ def get_current_version(verbose=False) -> str:
|
|
|
113
125
|
return capture_cmd_output(cmd)
|
|
114
126
|
|
|
115
127
|
|
|
128
|
+
def _ensure_bool(value: bool | "OptionInfo") -> bool:
|
|
129
|
+
if not isinstance(value, bool):
|
|
130
|
+
value = getattr(value, "default", False)
|
|
131
|
+
return value
|
|
132
|
+
|
|
133
|
+
|
|
116
134
|
def exit_if_run_failed(
|
|
117
135
|
cmd: str, env=None, _exit=False, dry=False, **kw
|
|
118
136
|
) -> CompletedProcess:
|
|
119
137
|
run_and_echo(cmd, dry=True)
|
|
120
|
-
if dry:
|
|
138
|
+
if _ensure_bool(dry):
|
|
121
139
|
return CompletedProcess("", 0)
|
|
122
140
|
if env is not None:
|
|
123
141
|
env = {**os.environ, **env}
|
|
@@ -213,7 +231,7 @@ def bump_version(
|
|
|
213
231
|
dry: bool = Option(False, "--dry", help="Only print, not really run shell command"),
|
|
214
232
|
) -> None:
|
|
215
233
|
"""Bump up version string in pyproject.toml"""
|
|
216
|
-
return BumpUp(commit, part.value, dry=dry).run()
|
|
234
|
+
return BumpUp(_ensure_bool(commit), part.value, dry=dry).run()
|
|
217
235
|
|
|
218
236
|
|
|
219
237
|
def bump() -> None:
|
|
@@ -380,8 +398,9 @@ class UpgradeDependencies(Project, DryRun):
|
|
|
380
398
|
main_title = "[tool.poetry.dependencies]"
|
|
381
399
|
text = toml_text.split(main_title)[-1]
|
|
382
400
|
dev_flag = "--group dev"
|
|
383
|
-
|
|
384
|
-
|
|
401
|
+
new_flag, old_flag = cls.DevFlag.new, cls.DevFlag.old
|
|
402
|
+
if (dev_title := getattr(new_flag, "value", new_flag)) not in text:
|
|
403
|
+
dev_title = getattr(old_flag, "value", old_flag) # For poetry<=1.2
|
|
385
404
|
dev_flag = "--dev"
|
|
386
405
|
others: list[list[str]] = []
|
|
387
406
|
try:
|
|
@@ -522,6 +541,8 @@ class LintCode(DryRun):
|
|
|
522
541
|
def lint(files=None, dry=False) -> None:
|
|
523
542
|
if files is None:
|
|
524
543
|
files = parse_files(sys.argv[1:])
|
|
544
|
+
if files and files[0] == "lint":
|
|
545
|
+
files = files[1:]
|
|
525
546
|
LintCode(files, dry=dry).run()
|
|
526
547
|
|
|
527
548
|
|
|
@@ -538,7 +559,7 @@ def make_style(
|
|
|
538
559
|
"""Run: ruff check/format to reformat code and then mypy to check"""
|
|
539
560
|
if isinstance(files, str):
|
|
540
561
|
files = [files]
|
|
541
|
-
if check_only:
|
|
562
|
+
if _ensure_bool(check_only):
|
|
542
563
|
check(files, dry=dry)
|
|
543
564
|
else:
|
|
544
565
|
lint(files, dry=dry)
|
|
@@ -593,15 +614,20 @@ def _should_run_test_script(path: Path) -> bool:
|
|
|
593
614
|
return path.exists()
|
|
594
615
|
|
|
595
616
|
|
|
596
|
-
@cli.command()
|
|
597
|
-
def
|
|
617
|
+
@cli.command(name="test")
|
|
618
|
+
def coverage_test(
|
|
598
619
|
dry: bool = Option(False, "--dry", help="Only print, not really run shell command"),
|
|
620
|
+
ignore_script: bool = Option(False, "--ignore-script", "-i"),
|
|
599
621
|
) -> None:
|
|
600
622
|
"""Run unittest by pytest and report coverage"""
|
|
623
|
+
return test(dry, ignore_script)
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
def test(dry: bool, ignore_script=False) -> None:
|
|
601
627
|
cwd = Path.cwd()
|
|
602
628
|
root = Project.get_work_dir(cwd=cwd, allow_cwd=True)
|
|
603
629
|
test_script = root / "scripts" / "test.sh"
|
|
604
|
-
if _should_run_test_script(test_script):
|
|
630
|
+
if not _ensure_bool(ignore_script) and _should_run_test_script(test_script):
|
|
605
631
|
cmd = f"sh {test_script.relative_to(root)}"
|
|
606
632
|
if cwd != root:
|
|
607
633
|
cmd = f"cd {root} && " + cmd
|
|
@@ -622,5 +648,29 @@ def upload(
|
|
|
622
648
|
exit_if_run_failed(cmd, dry=dry)
|
|
623
649
|
|
|
624
650
|
|
|
651
|
+
def dev(
|
|
652
|
+
port: int | None | "OptionInfo", host: str | None | "OptionInfo", dry=False
|
|
653
|
+
) -> None:
|
|
654
|
+
cmd = "fastapi dev"
|
|
655
|
+
if (port := getattr(port, "default", port)) and port != 8000:
|
|
656
|
+
cmd += f" --port={port}"
|
|
657
|
+
if (host := getattr(host, "default", host)) and host not in (
|
|
658
|
+
"localhost",
|
|
659
|
+
"127.0.0.1",
|
|
660
|
+
):
|
|
661
|
+
cmd += f" --host={host}"
|
|
662
|
+
exit_if_run_failed(cmd, dry=dry)
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
@cli.command(name="dev")
|
|
666
|
+
def runserver(
|
|
667
|
+
port: Optional[int] = Option(None, "-p", "--port"),
|
|
668
|
+
host: Optional[str] = Option(None, "-h", "--host"),
|
|
669
|
+
dry: bool = Option(False, "--dry", help="Only print, not really run shell command"),
|
|
670
|
+
) -> None:
|
|
671
|
+
"""Check code style without reformat"""
|
|
672
|
+
dev(port, host, dry=dry)
|
|
673
|
+
|
|
674
|
+
|
|
625
675
|
if __name__ == "__main__":
|
|
626
676
|
cli() # pragma: no cover
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "fast-dev-cli"
|
|
3
|
+
version = "0.7.2"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = ["Waket Zheng <waketzheng@gmail.com>"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
packages = [{include = "fast_dev_cli"}]
|
|
8
|
+
|
|
9
|
+
[tool.poetry.dependencies]
|
|
10
|
+
python = "^3.10"
|
|
11
|
+
click = ">=7.1.1" # Many package depends on click, so only limit min version
|
|
12
|
+
strenum = {version = ">=0.4.15", python = "<3.11"}
|
|
13
|
+
type-extensions = {version = ">=0.1.2", python = "<3.11"}
|
|
14
|
+
coverage = {version = ">=6.5.0", optional = true}
|
|
15
|
+
ruff = {version = "^0.4.2", optional = true}
|
|
16
|
+
mypy = {version = "^1.10.0", optional = true}
|
|
17
|
+
bumpversion = {version = "^0.6.0", optional = true}
|
|
18
|
+
pytest = {version = "^8.2.0", optional = true}
|
|
19
|
+
typer = {version = "^0.12.3", optional = true}
|
|
20
|
+
|
|
21
|
+
[tool.poetry.extras]
|
|
22
|
+
all = ["ruff", "typer", "mypy", "bumpversion", "pytest", "coverage"]
|
|
23
|
+
|
|
24
|
+
[tool.poetry.group.dev.dependencies]
|
|
25
|
+
coveralls = {version = ">=4.0.0", python = ">=3.10,<3.13"}
|
|
26
|
+
coverage = ">=6.5.0" # use >= to compare with coveralls
|
|
27
|
+
typer = "^0.12.3"
|
|
28
|
+
ruff = "^0.4.2"
|
|
29
|
+
mypy = "^1.10.0"
|
|
30
|
+
pytest = "^8.2.0"
|
|
31
|
+
ipython = "^8.24.0"
|
|
32
|
+
bumpversion = "^0.6.0"
|
|
33
|
+
pytest-mock = "^3.14.0"
|
|
34
|
+
type-extensions = "^0.1.2"
|
|
35
|
+
strenum = "^0.4.15"
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["poetry-core"]
|
|
39
|
+
build-backend = "poetry.core.masonry.api"
|
|
40
|
+
|
|
41
|
+
[tool.poetry.scripts]
|
|
42
|
+
fast = "fast_dev_cli:cli.cli"
|
|
43
|
+
|
|
44
|
+
[tool.mypy]
|
|
45
|
+
pretty = true
|
|
46
|
+
ignore_missing_imports = true
|
|
47
|
+
check_untyped_defs = true
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint.per-file-ignores]
|
|
50
|
+
"test_*.py" = ["E501"]
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
[tool.poetry]
|
|
2
|
-
name = "fast-dev-cli"
|
|
3
|
-
version = "0.7.0"
|
|
4
|
-
description = ""
|
|
5
|
-
authors = ["Waket Zheng <waketzheng@gmail.com>"]
|
|
6
|
-
readme = "README.md"
|
|
7
|
-
packages = [{include = "fast_dev_cli"}]
|
|
8
|
-
|
|
9
|
-
[tool.poetry.dependencies]
|
|
10
|
-
python = "^3.11"
|
|
11
|
-
click = ">=7.1.1"
|
|
12
|
-
ruff = {version = ">=0.3", optional = true}
|
|
13
|
-
mypy = {version = ">=1.5.0", optional = true}
|
|
14
|
-
coverage = {version = ">=6.5.0", optional = true}
|
|
15
|
-
bumpversion = {version = "^0.6.0", optional = true}
|
|
16
|
-
pytest = {version = "^8.1.1", optional = true}
|
|
17
|
-
typer = {version = ">=0.12.0", optional = true}
|
|
18
|
-
|
|
19
|
-
[tool.poetry.extras]
|
|
20
|
-
all = ["ruff", "typer", "mypy", "bumpversion", "pytest", "coverage"]
|
|
21
|
-
|
|
22
|
-
[tool.poetry.group.dev.dependencies]
|
|
23
|
-
ruff = ">=0.3"
|
|
24
|
-
mypy = "*"
|
|
25
|
-
pytest = "*"
|
|
26
|
-
coverage = "*"
|
|
27
|
-
bumpversion = "*"
|
|
28
|
-
typer = {extras = ["all"], version = "*"}
|
|
29
|
-
ipython = "^8.23.0"
|
|
30
|
-
coveralls = "^3.3.1"
|
|
31
|
-
pytest-mock = "^3.14.0"
|
|
32
|
-
|
|
33
|
-
[build-system]
|
|
34
|
-
requires = ["poetry-core"]
|
|
35
|
-
build-backend = "poetry.core.masonry.api"
|
|
36
|
-
|
|
37
|
-
[tool.poetry.scripts]
|
|
38
|
-
fast = "fast_dev_cli:cli"
|
|
39
|
-
|
|
40
|
-
[tool.ruff]
|
|
41
|
-
target-version = "py311"
|
|
42
|
-
|
|
43
|
-
[tool.mypy]
|
|
44
|
-
pretty = true
|
|
45
|
-
ignore_missing_imports = true
|
|
46
|
-
check_untyped_defs = true
|
|
47
|
-
|
|
48
|
-
[[tool.mypy.overrides]]
|
|
49
|
-
module = ["tests.*"]
|
|
50
|
-
check_untyped_defs = false
|
|
51
|
-
|
|
52
|
-
[tool.ruff.lint.per-file-ignores]
|
|
53
|
-
"test_*.py" = ["E501"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|