fast-dev-cli 0.9.4__tar.gz → 0.9.5__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.9.4 → fast_dev_cli-0.9.5}/PKG-INFO +1 -1
- fast_dev_cli-0.9.5/fast_dev_cli/__init__.py +1 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/fast_dev_cli/cli.py +21 -14
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/pdm_build.py +7 -7
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/pyproject.toml +1 -1
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/scripts/format.sh +1 -1
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_fast_test.py +2 -2
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_lint.py +3 -2
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_runserver.py +14 -14
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_tag.py +2 -3
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_upgrade.py +20 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_upload.py +1 -1
- fast_dev_cli-0.9.4/fast_dev_cli/__init__.py +0 -1
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/LICENSE +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/README.md +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/fast_dev_cli/__main__.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/fast_dev_cli/py.typed +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/scripts/check.sh +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/scripts/test.sh +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/__init__.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/conftest.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_bump.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_functions.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_poetry_version_plugin.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_sync.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/test_version.py +0 -0
- {fast_dev_cli-0.9.4 → fast_dev_cli-0.9.5}/tests/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.9.5"
|
|
@@ -172,9 +172,10 @@ class BumpUp(DryRun):
|
|
|
172
172
|
pattern = re.compile(r"__version__\s*=\s*['\"]")
|
|
173
173
|
ds = [cwd / i for i in packages] + [cwd / cwd.name.replace("-", "_"), cwd]
|
|
174
174
|
for d in ds:
|
|
175
|
-
if (init_file := d / "__init__.py").exists()
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
if (init_file := d / "__init__.py").exists() and pattern.search(
|
|
176
|
+
init_file.read_text()
|
|
177
|
+
):
|
|
178
|
+
break
|
|
178
179
|
else:
|
|
179
180
|
raise ParseError("Version file not found! Where are you now?")
|
|
180
181
|
return os.path.relpath(init_file, cwd)
|
|
@@ -199,11 +200,9 @@ class BumpUp(DryRun):
|
|
|
199
200
|
if self.part:
|
|
200
201
|
part = self.get_part(self.part)
|
|
201
202
|
else:
|
|
202
|
-
|
|
203
|
-
if a := input(
|
|
203
|
+
part = "patch"
|
|
204
|
+
if a := input("Which one?").strip():
|
|
204
205
|
part = self.get_part(a)
|
|
205
|
-
else:
|
|
206
|
-
part = "patch"
|
|
207
206
|
self.part = part
|
|
208
207
|
parse = r'--parse "(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)"'
|
|
209
208
|
cmd = f'bumpversion {parse} --current-version="{_version}" {part} {filename}'
|
|
@@ -365,6 +364,9 @@ class UpgradeDependencies(Project, DryRun):
|
|
|
365
364
|
if v == "*":
|
|
366
365
|
echo(f"Skip wildcard line: {line}")
|
|
367
366
|
return True
|
|
367
|
+
elif v == "[":
|
|
368
|
+
echo(f"Skip complex dependence: {line}")
|
|
369
|
+
return True
|
|
368
370
|
elif v.startswith(">") or v.startswith("<") or v[0].isdigit():
|
|
369
371
|
echo(f"Ignore bigger/smaller/equal: {line}")
|
|
370
372
|
return True
|
|
@@ -376,13 +378,18 @@ class UpgradeDependencies(Project, DryRun):
|
|
|
376
378
|
) -> tuple[list[str], dict[str, list[str]]]:
|
|
377
379
|
args: list[str] = [] # ['typer[all]', 'fastapi']
|
|
378
380
|
specials: dict[str, list[str]] = {} # {'--platform linux': ['gunicorn']}
|
|
379
|
-
for line in package_lines:
|
|
380
|
-
if
|
|
381
|
+
for no, line in enumerate(package_lines, 1):
|
|
382
|
+
if (
|
|
383
|
+
not (m := line.strip())
|
|
384
|
+
or m.startswith("#")
|
|
385
|
+
or m == "]"
|
|
386
|
+
or (m.startswith("{") and m.strip(",").endswith("}"))
|
|
387
|
+
):
|
|
381
388
|
continue
|
|
382
389
|
try:
|
|
383
390
|
package, version_info = m.split("=", 1)
|
|
384
391
|
except ValueError as e:
|
|
385
|
-
raise ParseError(f"
|
|
392
|
+
raise ParseError(f"Failed to separate by '='@line {no}: {m}") from e
|
|
386
393
|
if (package := package.strip()).lower() == "python":
|
|
387
394
|
continue
|
|
388
395
|
if cls.no_need_upgrade(version_info := version_info.strip(' "'), line):
|
|
@@ -549,7 +556,7 @@ class LintCode(DryRun):
|
|
|
549
556
|
@classmethod
|
|
550
557
|
def to_cmd(cls: Type[Self], paths=".", check_only=False) -> str:
|
|
551
558
|
cmd = ""
|
|
552
|
-
tools = ["ruff format", "ruff check --extend-select=I --fix", "mypy"]
|
|
559
|
+
tools = ["ruff format", "ruff check --extend-select=I,B,SIM --fix", "mypy"]
|
|
553
560
|
if check_only:
|
|
554
561
|
tools[0] += " --check"
|
|
555
562
|
if check_only or load_bool("NO_FIX"):
|
|
@@ -567,8 +574,8 @@ class LintCode(DryRun):
|
|
|
567
574
|
should_run_by_tool = True
|
|
568
575
|
if check_call("python -c 'import fast_dev_cli'"):
|
|
569
576
|
command = 'python -m pip install -U "fast_dev_cli"'
|
|
570
|
-
tip = "You may need to run following command to install lint tools"
|
|
571
|
-
secho(f"{tip}
|
|
577
|
+
tip = "You may need to run following command to install lint tools:"
|
|
578
|
+
secho(f"{tip}\n\n {command}\n", fg="yellow")
|
|
572
579
|
else:
|
|
573
580
|
should_run_by_tool = True
|
|
574
581
|
if should_run_by_tool:
|
|
@@ -713,7 +720,7 @@ def dev(
|
|
|
713
720
|
cmd += f" {file}"
|
|
714
721
|
else:
|
|
715
722
|
if port != 8000:
|
|
716
|
-
cmd += f" --{port
|
|
723
|
+
cmd += f" --port={port}"
|
|
717
724
|
no_port_yet = False
|
|
718
725
|
if no_port_yet and (port := getattr(port, "default", port)) and str(port) != "8000":
|
|
719
726
|
cmd += f" --port={port}"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
from pdm.backend.hooks import Context
|
|
5
5
|
|
|
@@ -9,30 +9,30 @@ BUILD_PACKAGE = os.getenv("BUILD_PACKAGE", "fast-dev-cli")
|
|
|
9
9
|
def pdm_build_initialize(context: Context) -> None:
|
|
10
10
|
metadata = context.config.metadata
|
|
11
11
|
# Get custom config for the current package, from the env var
|
|
12
|
-
config:
|
|
12
|
+
config: dict[str, Any] = context.config.data["tool"]["waketzheng"][
|
|
13
13
|
"_internal-slim-build"
|
|
14
14
|
]["packages"][BUILD_PACKAGE]
|
|
15
|
-
project_config:
|
|
15
|
+
project_config: dict[str, Any] = config["project"]
|
|
16
16
|
# Get main optional dependencies, extras
|
|
17
|
-
optional_dependencies:
|
|
17
|
+
optional_dependencies: dict[str, list[str]] = metadata.get(
|
|
18
18
|
"optional-dependencies", {}
|
|
19
19
|
)
|
|
20
20
|
# Get custom optional dependencies name to always include in this (non-slim) package
|
|
21
|
-
include_optional_dependencies:
|
|
21
|
+
include_optional_dependencies: list[str] = config.get(
|
|
22
22
|
"include-optional-dependencies", []
|
|
23
23
|
)
|
|
24
24
|
# Override main [project] configs with custom configs for this package
|
|
25
25
|
for key, value in project_config.items():
|
|
26
26
|
metadata[key] = value
|
|
27
27
|
# Get custom build config for the current package
|
|
28
|
-
build_config:
|
|
28
|
+
build_config: dict[str, Any] = (
|
|
29
29
|
config.get("tool", {}).get("pdm", {}).get("build", {})
|
|
30
30
|
)
|
|
31
31
|
# Override PDM build config with custom build config for this package
|
|
32
32
|
for key, value in build_config.items():
|
|
33
33
|
context.config.build_config[key] = value
|
|
34
34
|
# Get main dependencies
|
|
35
|
-
dependencies:
|
|
35
|
+
dependencies: list[str] = metadata.get("dependencies", [])
|
|
36
36
|
# Add optional dependencies to the default dependencies for this (non-slim) package
|
|
37
37
|
for include_optional in include_optional_dependencies:
|
|
38
38
|
optional_dependencies_group = optional_dependencies.get(include_optional, [])
|
|
@@ -41,7 +41,7 @@ def test_test_with_poetry_or_pdm_run(mocker: MockerFixture, capsys):
|
|
|
41
41
|
if tool := Project.get_manage_tool():
|
|
42
42
|
command = tool + " run " + command
|
|
43
43
|
assert (
|
|
44
|
-
'--> {
|
|
44
|
+
f'--> {command} run -m pytest -s && {command} report --omit="tests/*" -m'
|
|
45
45
|
in capsys.readouterr().out
|
|
46
46
|
)
|
|
47
47
|
|
|
@@ -54,7 +54,7 @@ def test_test_not_in_venv(mocker: MockerFixture, capsys):
|
|
|
54
54
|
if tool := Project.get_manage_tool():
|
|
55
55
|
command = tool + " run " + command
|
|
56
56
|
assert (
|
|
57
|
-
'--> {
|
|
57
|
+
f'--> {command} run -m pytest -s && {command} report --omit="tests/*" -m'
|
|
58
58
|
in capsys.readouterr().out
|
|
59
59
|
)
|
|
60
60
|
|
|
@@ -41,8 +41,9 @@ def mock_ignore_missing_imports_0(monkeypatch):
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
SEP = " && "
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
_CMD = "ruff format{} . && ruff check --extend-select=I,B,SIM{} . && mypy ."
|
|
45
|
+
LINT_CMD = _CMD.format("", " --fix")
|
|
46
|
+
CHECK_CMD = _CMD.format(" --check", "")
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
def test_check():
|
|
@@ -4,49 +4,49 @@ from fast_dev_cli.cli import dev, run_and_echo, runserver
|
|
|
4
4
|
def test_runserver(capsys):
|
|
5
5
|
runserver(dry=True)
|
|
6
6
|
out = capsys.readouterr().out.strip()
|
|
7
|
-
assert
|
|
7
|
+
assert out.replace("--> ", "") == "fastapi dev"
|
|
8
8
|
runserver(port=8000, dry=True)
|
|
9
9
|
out = capsys.readouterr().out.strip()
|
|
10
|
-
assert
|
|
10
|
+
assert out.replace("--> ", "") == "fastapi dev"
|
|
11
11
|
runserver(port=9000, dry=True)
|
|
12
12
|
out = capsys.readouterr().out.strip()
|
|
13
|
-
assert
|
|
13
|
+
assert out.replace("--> ", "") == "fastapi dev --port=9000"
|
|
14
14
|
runserver(host="0.0.0.0", dry=True)
|
|
15
15
|
out = capsys.readouterr().out.strip()
|
|
16
|
-
assert "fastapi dev --host=0.0.0.0"
|
|
16
|
+
assert out.replace("--> ", "") == "fastapi dev --host=0.0.0.0"
|
|
17
17
|
runserver(port=9000, host="0.0.0.0", dry=True)
|
|
18
18
|
out = capsys.readouterr().out.strip()
|
|
19
|
-
assert "fastapi dev --port=9000 --host=0.0.0.0"
|
|
19
|
+
assert out.replace("--> ", "") == "fastapi dev --port=9000 --host=0.0.0.0"
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def test_dev(capsys):
|
|
23
23
|
dev(None, None, dry=True)
|
|
24
24
|
out = capsys.readouterr().out.strip()
|
|
25
|
-
assert
|
|
25
|
+
assert out.replace("--> ", "") == "fastapi dev"
|
|
26
26
|
dev(port=8000, host="", dry=True)
|
|
27
27
|
out = capsys.readouterr().out.strip()
|
|
28
|
-
assert
|
|
28
|
+
assert out.replace("--> ", "") == "fastapi dev"
|
|
29
29
|
dev(port=9000, host=None, dry=True)
|
|
30
30
|
out = capsys.readouterr().out.strip()
|
|
31
|
-
assert
|
|
31
|
+
assert out.replace("--> ", "") == "fastapi dev --port=9000"
|
|
32
32
|
dev(8000, host="0.0.0.0", dry=True)
|
|
33
33
|
out = capsys.readouterr().out.strip()
|
|
34
|
-
assert "fastapi dev --host=0.0.0.0"
|
|
34
|
+
assert out.replace("--> ", "") == "fastapi dev --host=0.0.0.0"
|
|
35
35
|
dev(port=9000, host="0.0.0.0", dry=True)
|
|
36
36
|
out = capsys.readouterr().out.strip()
|
|
37
|
-
assert "fastapi dev --port=9000 --host=0.0.0.0"
|
|
37
|
+
assert out.replace("--> ", "") == "fastapi dev --port=9000 --host=0.0.0.0"
|
|
38
38
|
dev(8001, host="0.0.0.0", dry=True)
|
|
39
39
|
out = capsys.readouterr().out.strip()
|
|
40
|
-
assert "fastapi dev --port=8001 --host=0.0.0.0"
|
|
40
|
+
assert out.replace("--> ", "") == "fastapi dev --port=8001 --host=0.0.0.0"
|
|
41
41
|
dev(None, file="8001", host="0.0.0.0", dry=True)
|
|
42
42
|
out = capsys.readouterr().out.strip()
|
|
43
|
-
assert "fastapi dev --port=8001 --host=0.0.0.0"
|
|
43
|
+
assert out.replace("--> ", "") == "fastapi dev --port=8001 --host=0.0.0.0"
|
|
44
44
|
dev(None, file="main.py", host="0.0.0.0", dry=True)
|
|
45
45
|
out = capsys.readouterr().out.strip()
|
|
46
|
-
assert "fastapi dev main.py --host=0.0.0.0"
|
|
46
|
+
assert out.replace("--> ", "") == "fastapi dev main.py --host=0.0.0.0"
|
|
47
47
|
dev(8001, file="main.py", host="0.0.0.0", dry=True)
|
|
48
48
|
out = capsys.readouterr().out.strip()
|
|
49
|
-
assert "fastapi dev main.py --port=8001 --host=0.0.0.0"
|
|
49
|
+
assert out.replace("--> ", "") == "fastapi dev main.py --port=8001 --host=0.0.0.0"
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def test_fast_dev(tmp_path):
|
|
@@ -16,9 +16,8 @@ def test_tag():
|
|
|
16
16
|
GitTag(message="", dry=True).run()
|
|
17
17
|
assert "git tag -a" in stream.getvalue()
|
|
18
18
|
|
|
19
|
-
with temp_file("foo.txt"):
|
|
20
|
-
|
|
21
|
-
GitTag(message="", dry=True).run()
|
|
19
|
+
with temp_file("foo.txt"), capture_stdout() as stream:
|
|
20
|
+
GitTag(message="", dry=True).run()
|
|
22
21
|
|
|
23
22
|
assert "git status" in stream.getvalue()
|
|
24
23
|
assert "ERROR" in stream.getvalue()
|
|
@@ -258,3 +258,23 @@ def test_get_dir(mocker, tmp_path):
|
|
|
258
258
|
assert UpgradeDependencies.get_root_dir() == parent
|
|
259
259
|
mocker.patch.object(UpgradeDependencies, "python_exec_dir", return_value=me)
|
|
260
260
|
assert UpgradeDependencies.get_root_dir() == root
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def test_parse_complex_segment():
|
|
264
|
+
segment = """
|
|
265
|
+
[tool.poetry.dependencies]
|
|
266
|
+
torch = [
|
|
267
|
+
{version="*",platform="linux"},
|
|
268
|
+
{version="^1.2.0",platform=""},
|
|
269
|
+
{version=">=1.2.0",platform=""},
|
|
270
|
+
]
|
|
271
|
+
fastapi = "^0.112.2"
|
|
272
|
+
|
|
273
|
+
[tool.isort]
|
|
274
|
+
""".strip()
|
|
275
|
+
assert UpgradeDependencies.get_args(segment) == (
|
|
276
|
+
['"fastapi@latest"'],
|
|
277
|
+
[],
|
|
278
|
+
[],
|
|
279
|
+
"--dev",
|
|
280
|
+
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.9.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|