fast-dev-cli 0.14.0__tar.gz → 0.14.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.14.0 → fast_dev_cli-0.14.2}/PKG-INFO +1 -1
- fast_dev_cli-0.14.2/fast_dev_cli/__init__.py +1 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/fast_dev_cli/cli.py +40 -25
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/pyproject.toml +9 -1
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/scripts/test.py +1 -1
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_bump.py +49 -36
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_functions.py +12 -6
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_lint.py +20 -2
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/utils.py +10 -0
- fast_dev_cli-0.14.0/fast_dev_cli/__init__.py +0 -1
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/LICENSE +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/README.md +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/fast_dev_cli/__main__.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/fast_dev_cli/py.typed +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/pdm_build.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/scripts/check.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/scripts/format.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/__init__.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/conftest.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_fast_test.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_poetry_version_plugin.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_runserver.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_sync.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_tag.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_upgrade.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_upload.py +0 -0
- {fast_dev_cli-0.14.0 → fast_dev_cli-0.14.2}/tests/test_version.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.14.2"
|
|
@@ -38,6 +38,7 @@ else: # pragma: no cover
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
cli = typer.Typer()
|
|
41
|
+
DryOption = Option(False, "--dry", help="Only print, not really run shell command")
|
|
41
42
|
TOML_FILE = "pyproject.toml"
|
|
42
43
|
ToolName = Literal["poetry", "pdm", "uv"]
|
|
43
44
|
|
|
@@ -258,7 +259,12 @@ class BumpUp(DryRun):
|
|
|
258
259
|
try:
|
|
259
260
|
package_item = context["tool"]["poetry"]["packages"]
|
|
260
261
|
except KeyError:
|
|
261
|
-
|
|
262
|
+
try:
|
|
263
|
+
project_name = context["project"]["name"]
|
|
264
|
+
except KeyError:
|
|
265
|
+
packages = []
|
|
266
|
+
else:
|
|
267
|
+
packages = [(poetry_module_name(project_name), "")]
|
|
262
268
|
else:
|
|
263
269
|
packages = [
|
|
264
270
|
(j, i.get("from", ""))
|
|
@@ -343,7 +349,7 @@ def bump_version(
|
|
|
343
349
|
commit: bool = Option(
|
|
344
350
|
False, "--commit", "-c", help="Whether run `git commit` after version changed"
|
|
345
351
|
),
|
|
346
|
-
dry: bool =
|
|
352
|
+
dry: bool = DryOption,
|
|
347
353
|
) -> None:
|
|
348
354
|
"""Bump up version string in pyproject.toml"""
|
|
349
355
|
return BumpUp(_ensure_bool(commit), getattr(part, "value", part), dry=dry).run()
|
|
@@ -607,7 +613,7 @@ class UpgradeDependencies(Project, DryRun):
|
|
|
607
613
|
|
|
608
614
|
@cli.command()
|
|
609
615
|
def upgrade(
|
|
610
|
-
dry: bool =
|
|
616
|
+
dry: bool = DryOption,
|
|
611
617
|
) -> None:
|
|
612
618
|
"""Upgrade dependencies in pyproject.toml to latest versions"""
|
|
613
619
|
if (tool := Project.get_manage_tool()) == "uv":
|
|
@@ -661,7 +667,7 @@ class GitTag(DryRun):
|
|
|
661
667
|
@cli.command()
|
|
662
668
|
def tag(
|
|
663
669
|
message: str = Option("", "-m", "--message"),
|
|
664
|
-
dry: bool =
|
|
670
|
+
dry: bool = DryOption,
|
|
665
671
|
) -> None:
|
|
666
672
|
"""Run shell command: git tag -a <current-version-in-pyproject.toml> -m {message}"""
|
|
667
673
|
GitTag(message, dry=dry).run()
|
|
@@ -709,19 +715,21 @@ class LintCode(DryRun):
|
|
|
709
715
|
@classmethod
|
|
710
716
|
def to_cmd(
|
|
711
717
|
cls: type[Self],
|
|
712
|
-
paths=".",
|
|
713
|
-
check_only=False,
|
|
714
|
-
bandit=False,
|
|
715
|
-
skip_mypy=False,
|
|
716
|
-
use_dmypy=False,
|
|
718
|
+
paths: str = ".",
|
|
719
|
+
check_only: bool = False,
|
|
720
|
+
bandit: bool = False,
|
|
721
|
+
skip_mypy: bool = False,
|
|
722
|
+
use_dmypy: bool = False,
|
|
717
723
|
) -> str:
|
|
724
|
+
if paths != "." and all(i.endswith(".html") for i in paths.split()):
|
|
725
|
+
return f"prettier -w {paths}"
|
|
718
726
|
cmd = ""
|
|
719
727
|
tools = ["ruff format", "ruff check --extend-select=I,B,SIM --fix", "mypy"]
|
|
720
728
|
if check_only:
|
|
721
729
|
tools[0] += " --check"
|
|
722
730
|
if check_only or load_bool("NO_FIX"):
|
|
723
731
|
tools[1] = tools[1].replace(" --fix", "")
|
|
724
|
-
if skip_mypy or load_bool("SKIP_MYPY"):
|
|
732
|
+
if skip_mypy or load_bool("SKIP_MYPY") or load_bool("FASTDEVCLI_NO_MYPY"):
|
|
725
733
|
# Sometimes mypy is too slow
|
|
726
734
|
tools = tools[:-1]
|
|
727
735
|
elif load_bool("IGNORE_MISSING_IMPORTS"):
|
|
@@ -731,11 +739,11 @@ class LintCode(DryRun):
|
|
|
731
739
|
)
|
|
732
740
|
prefix = ""
|
|
733
741
|
should_run_by_tool = False
|
|
734
|
-
if is_venv():
|
|
742
|
+
if is_venv() and Path(sys.argv[0]).parent != Path.home().joinpath(".local/bin"):
|
|
735
743
|
if not cls.check_lint_tool_installed():
|
|
736
744
|
should_run_by_tool = True
|
|
737
745
|
if check_call('python -c "import fast_dev_cli"'):
|
|
738
|
-
command = 'python -m pip install -U "
|
|
746
|
+
command = 'python -m pip install -U "fast-dev-cli"'
|
|
739
747
|
tip = "You may need to run following command to install lint tools:"
|
|
740
748
|
secho(f"{tip}\n\n {command}\n", fg="yellow")
|
|
741
749
|
else:
|
|
@@ -747,9 +755,14 @@ class LintCode(DryRun):
|
|
|
747
755
|
cmd += lint_them.format(prefix, paths, *tools)
|
|
748
756
|
if bandit or load_bool("FASTDEVCLI_BANDIT"):
|
|
749
757
|
command = prefix + "bandit"
|
|
750
|
-
if
|
|
751
|
-
|
|
752
|
-
|
|
758
|
+
if Path("pyproject.toml").exists():
|
|
759
|
+
toml_text = Project.load_toml_text()
|
|
760
|
+
if "[tool.bandit" in toml_text:
|
|
761
|
+
command += " -c pyproject.toml"
|
|
762
|
+
if paths == "." and " -c " not in command:
|
|
763
|
+
paths = cls.get_package_name()
|
|
764
|
+
command += f" -r {paths}"
|
|
765
|
+
cmd += " && " + command
|
|
753
766
|
return cmd
|
|
754
767
|
|
|
755
768
|
def gen(self: Self) -> str:
|
|
@@ -763,12 +776,12 @@ def parse_files(args: list[str] | tuple[str, ...]) -> list[str]:
|
|
|
763
776
|
return [i for i in args if not i.startswith("-")]
|
|
764
777
|
|
|
765
778
|
|
|
766
|
-
def lint(files=None, dry=False, skip_mypy=False, dmypy=False) -> None:
|
|
779
|
+
def lint(files=None, dry=False, bandit=False, skip_mypy=False, dmypy=False) -> None:
|
|
767
780
|
if files is None:
|
|
768
781
|
files = parse_files(sys.argv[1:])
|
|
769
782
|
if files and files[0] == "lint":
|
|
770
783
|
files = files[1:]
|
|
771
|
-
LintCode(files, dry=dry, skip_mypy=skip_mypy, dmypy=dmypy).run()
|
|
784
|
+
LintCode(files, dry=dry, skip_mypy=skip_mypy, bandit=bandit, dmypy=dmypy).run()
|
|
772
785
|
|
|
773
786
|
|
|
774
787
|
def check(files=None, dry=False, bandit=False, skip_mypy=False, dmypy=False) -> None:
|
|
@@ -787,11 +800,12 @@ def check(files=None, dry=False, bandit=False, skip_mypy=False, dmypy=False) ->
|
|
|
787
800
|
def make_style(
|
|
788
801
|
files: Optional[list[Path]] = typer.Argument(default=None), # noqa:B008
|
|
789
802
|
check_only: bool = Option(False, "--check-only", "-c"),
|
|
803
|
+
bandit: bool = Option(False, "--bandit", help="Run `bandit -r <package_dir>`"),
|
|
790
804
|
skip_mypy: bool = Option(False, "--skip-mypy"),
|
|
791
805
|
use_dmypy: bool = Option(
|
|
792
806
|
False, "--dmypy", help="Use `dmypy run` instead of `mypy`"
|
|
793
807
|
),
|
|
794
|
-
dry: bool =
|
|
808
|
+
dry: bool = DryOption,
|
|
795
809
|
) -> None:
|
|
796
810
|
"""Run: ruff check/format to reformat code and then mypy to check"""
|
|
797
811
|
if getattr(files, "default", files) is None:
|
|
@@ -800,17 +814,18 @@ def make_style(
|
|
|
800
814
|
files = [files]
|
|
801
815
|
skip = _ensure_bool(skip_mypy)
|
|
802
816
|
dmypy = _ensure_bool(use_dmypy)
|
|
817
|
+
bandit = _ensure_bool(bandit)
|
|
803
818
|
if _ensure_bool(check_only):
|
|
804
|
-
check(files, dry=dry, skip_mypy=skip, dmypy=dmypy)
|
|
819
|
+
check(files, dry=dry, skip_mypy=skip, dmypy=dmypy, bandit=bandit)
|
|
805
820
|
else:
|
|
806
|
-
lint(files, dry=dry, skip_mypy=skip, dmypy=dmypy)
|
|
821
|
+
lint(files, dry=dry, skip_mypy=skip, dmypy=dmypy, bandit=bandit)
|
|
807
822
|
|
|
808
823
|
|
|
809
824
|
@cli.command(name="check")
|
|
810
825
|
def only_check(
|
|
811
826
|
bandit: bool = Option(False, "--bandit", help="Run `bandit -r <package_dir>`"),
|
|
812
827
|
skip_mypy: bool = Option(False, "--skip-mypy"),
|
|
813
|
-
dry: bool =
|
|
828
|
+
dry: bool = DryOption,
|
|
814
829
|
) -> None:
|
|
815
830
|
"""Check code style without reformat"""
|
|
816
831
|
check(dry=dry, bandit=bandit, skip_mypy=_ensure_bool(skip_mypy))
|
|
@@ -861,7 +876,7 @@ def sync(
|
|
|
861
876
|
save: bool = Option(
|
|
862
877
|
False, "--save", "-s", help="Whether save the requirement file"
|
|
863
878
|
),
|
|
864
|
-
dry: bool =
|
|
879
|
+
dry: bool = DryOption,
|
|
865
880
|
) -> None:
|
|
866
881
|
"""Export dependencies by poetry to a txt file then install by pip."""
|
|
867
882
|
Sync(filename, extras, save, dry=dry).run()
|
|
@@ -895,7 +910,7 @@ def test(dry: bool, ignore_script=False) -> None:
|
|
|
895
910
|
|
|
896
911
|
@cli.command(name="test")
|
|
897
912
|
def coverage_test(
|
|
898
|
-
dry: bool =
|
|
913
|
+
dry: bool = DryOption,
|
|
899
914
|
ignore_script: bool = Option(False, "--ignore-script", "-i"),
|
|
900
915
|
) -> None:
|
|
901
916
|
"""Run unittest by pytest and report coverage"""
|
|
@@ -918,7 +933,7 @@ class Publish:
|
|
|
918
933
|
|
|
919
934
|
@cli.command()
|
|
920
935
|
def upload(
|
|
921
|
-
dry: bool =
|
|
936
|
+
dry: bool = DryOption,
|
|
922
937
|
) -> None:
|
|
923
938
|
"""Shortcut for package publish"""
|
|
924
939
|
cmd = Publish.gen()
|
|
@@ -957,7 +972,7 @@ def runserver(
|
|
|
957
972
|
file_or_port: Optional[str] = typer.Argument(default=None),
|
|
958
973
|
port: Optional[int] = Option(None, "-p", "--port"),
|
|
959
974
|
host: Optional[str] = Option(None, "-h", "--host"),
|
|
960
|
-
dry: bool =
|
|
975
|
+
dry: bool = DryOption,
|
|
961
976
|
) -> None:
|
|
962
977
|
"""Start a fastapi server(only for fastapi>=0.111.0)"""
|
|
963
978
|
if getattr(file_or_port, "default", file_or_port):
|
|
@@ -41,7 +41,7 @@ dependencies = [
|
|
|
41
41
|
"pytest >=8.2.0,<9",
|
|
42
42
|
"packaging>=20.5",
|
|
43
43
|
]
|
|
44
|
-
version = "0.14.
|
|
44
|
+
version = "0.14.2"
|
|
45
45
|
|
|
46
46
|
[project.urls]
|
|
47
47
|
Homepage = "https://github.com/waketzheng/fast-dev-cli"
|
|
@@ -154,3 +154,11 @@ extend-select = [
|
|
|
154
154
|
"fast_dev_cli/cli.py" = [
|
|
155
155
|
"UP007",
|
|
156
156
|
]
|
|
157
|
+
|
|
158
|
+
[tool.bandit]
|
|
159
|
+
exclude_dirs = [
|
|
160
|
+
"tests",
|
|
161
|
+
"scripts",
|
|
162
|
+
"examples",
|
|
163
|
+
".venv",
|
|
164
|
+
]
|
|
@@ -17,10 +17,11 @@ from fast_dev_cli.cli import (
|
|
|
17
17
|
StrEnum,
|
|
18
18
|
bump,
|
|
19
19
|
bump_version,
|
|
20
|
+
capture_cmd_output,
|
|
20
21
|
get_current_version,
|
|
21
22
|
)
|
|
22
23
|
|
|
23
|
-
from .utils import chdir, mock_sys_argv
|
|
24
|
+
from .utils import chdir, mock_sys_argv, prepare_poetry_project
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
def test_enum():
|
|
@@ -53,12 +54,14 @@ def test_bump_dry(mocker):
|
|
|
53
54
|
mocker.patch("fast_dev_cli.cli.Project.manage_by_poetry", return_value=True)
|
|
54
55
|
with pytest.raises(ShellCommandError):
|
|
55
56
|
get_current_version()
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
mocker.patch("fast_dev_cli.cli.Project.manage_by_poetry", return_value=False)
|
|
58
|
+
version = get_current_version()
|
|
59
|
+
patch_without_commit, patch_with_commit, minor_with_commit = _bump_commands(
|
|
60
|
+
version, filename="fast_dev_cli/__init__.py"
|
|
61
|
+
)
|
|
62
|
+
assert BumpUp(part="patch", commit=False, dry=True).gen() == patch_without_commit
|
|
63
|
+
assert BumpUp(part="patch", commit=True, dry=True).gen() == patch_with_commit
|
|
64
|
+
assert BumpUp(part="minor", commit=True, dry=True).gen() == minor_with_commit
|
|
62
65
|
|
|
63
66
|
|
|
64
67
|
def test_bump(
|
|
@@ -145,36 +148,46 @@ def test_bump_with_emoji(mocker, tmp_path, monkeypatch):
|
|
|
145
148
|
mocker.patch("fast_dev_cli.cli.Project.manage_by_poetry", return_value=True)
|
|
146
149
|
with pytest.raises(ShellCommandError):
|
|
147
150
|
get_current_version()
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
151
|
+
mocker.patch("fast_dev_cli.cli.Project.manage_by_poetry", return_value=False)
|
|
152
|
+
version = get_current_version()
|
|
153
|
+
patch_without_commit, patch_with_commit, minor_with_commit = _bump_commands(
|
|
154
|
+
version, filename="fast_dev_cli/__init__.py", emoji=True
|
|
155
|
+
)
|
|
156
|
+
last_commit = "📝 Update release notes"
|
|
157
|
+
mocker.patch(
|
|
158
|
+
"fast_dev_cli.cli.BumpUp.get_last_commit_message",
|
|
159
|
+
return_value=last_commit,
|
|
160
|
+
)
|
|
161
|
+
assert BumpUp(part="patch", commit=False, dry=True).gen() == patch_without_commit
|
|
162
|
+
assert BumpUp(part="patch", commit=True, dry=True).gen() == patch_with_commit
|
|
163
|
+
assert BumpUp(part="minor", commit=True, dry=True).gen() == minor_with_commit
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def test_bump_with_emoji_in_poetry_project(mocker, tmp_path, monkeypatch):
|
|
161
167
|
# real bump
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
last_commit = "📝 Update release notes"
|
|
169
|
+
_, patch_with_commit, __ = _bump_commands("0.1.0", emoji=True)
|
|
170
|
+
with prepare_poetry_project(tmp_path):
|
|
171
|
+
subprocess.run(["git", "init"])
|
|
172
|
+
subprocess.run(["git", "add", "."])
|
|
173
|
+
subprocess.run(["git", "config", "user.name", "sb"])
|
|
174
|
+
subprocess.run(["git", "config", "user.email", "sb@foo.com"])
|
|
175
|
+
assert BumpUp.should_add_emoji() is False
|
|
176
|
+
subprocess.run(["git", "commit", "-m", last_commit])
|
|
177
|
+
monkeypatch.setenv("DONT_GIT_PUSH", "1")
|
|
178
|
+
command = BumpUp(part="patch", commit=True).gen()
|
|
179
|
+
expected = patch_with_commit.split("&&")[0].strip().replace('""', '"0.1.0"')
|
|
180
|
+
assert expected == command
|
|
181
|
+
subprocess.run(["poetry", "run", "pip", "install", "bumpversion2"])
|
|
182
|
+
subprocess.run(["fast", "bump", "patch", "--commit"])
|
|
183
|
+
out = capture_cmd_output(["git", "log"])
|
|
184
|
+
assert BumpUp.should_add_emoji()
|
|
185
|
+
Path("a.txt").touch()
|
|
186
|
+
subprocess.run(["git", "add", "."])
|
|
187
|
+
subprocess.run(["git", "commit", "-m", "no emoji"])
|
|
188
|
+
assert BumpUp.should_add_emoji() is False
|
|
189
|
+
new_commit = "⬆️ Bump version: 0.1.0 → 0.1.1"
|
|
190
|
+
assert new_commit in out
|
|
178
191
|
|
|
179
192
|
|
|
180
193
|
def test_bump_with_uv(tmp_path):
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from contextlib import redirect_stdout
|
|
3
3
|
from io import StringIO
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
|
|
5
6
|
import pytest
|
|
6
7
|
import typer
|
|
@@ -16,6 +17,8 @@ from fast_dev_cli.cli import (
|
|
|
16
17
|
run_and_echo,
|
|
17
18
|
)
|
|
18
19
|
|
|
20
|
+
from .utils import prepare_poetry_project
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
def test_utils(capsys):
|
|
21
24
|
# parse files
|
|
@@ -64,12 +67,6 @@ def test_run_shell():
|
|
|
64
67
|
# current version
|
|
65
68
|
with pytest.raises(ShellCommandError):
|
|
66
69
|
get_current_version(True, is_poetry=True)
|
|
67
|
-
# TODO: add [tool.poetry] to pyproject.toml
|
|
68
|
-
# stream = StringIO()
|
|
69
|
-
# write_to_stream = redirect_stdout(stream)
|
|
70
|
-
# with write_to_stream:
|
|
71
|
-
# get_current_version(True, is_poetry=True)
|
|
72
|
-
# assert "poetry version -s" in stream.getvalue()
|
|
73
70
|
|
|
74
71
|
name = "TEST_EXIT_IF_RUN_FAILED"
|
|
75
72
|
value = "foo"
|
|
@@ -92,6 +89,15 @@ def test_run_shell():
|
|
|
92
89
|
A().run()
|
|
93
90
|
|
|
94
91
|
|
|
92
|
+
def test_get_version_in_poetry_project(tmp_path: Path):
|
|
93
|
+
with prepare_poetry_project(tmp_path):
|
|
94
|
+
stream = StringIO()
|
|
95
|
+
write_to_stream = redirect_stdout(stream)
|
|
96
|
+
with write_to_stream:
|
|
97
|
+
get_current_version(True, is_poetry=True)
|
|
98
|
+
assert "poetry version -s" in stream.getvalue()
|
|
99
|
+
|
|
100
|
+
|
|
95
101
|
def test_ensure_bool():
|
|
96
102
|
assert _ensure_bool(True) is True
|
|
97
103
|
assert _ensure_bool(False) is False
|
|
@@ -65,7 +65,7 @@ def test_check(mock_no_dmypy, monkeypatch, mocker):
|
|
|
65
65
|
for cmd in CHECK_CMD.split(SEP):
|
|
66
66
|
assert cmd in command
|
|
67
67
|
command2 = capture_cmd_output("fast check --bandit --dry")
|
|
68
|
-
assert command2 == command + " && bandit -r
|
|
68
|
+
assert command2 == command + " && bandit -c pyproject.toml -r ."
|
|
69
69
|
monkeypatch.setenv("FASTDEVCLI_BANDIT", "1")
|
|
70
70
|
command3 = capture_cmd_output("fast check --dry")
|
|
71
71
|
assert command3 == command2
|
|
@@ -84,6 +84,7 @@ def test_check_bandit(tmp_path):
|
|
|
84
84
|
src_dir = src_dir.parent / package_path.name
|
|
85
85
|
shutil.rmtree(src_dir)
|
|
86
86
|
with chdir(package_path):
|
|
87
|
+
assert LintCode.get_package_name() == "."
|
|
87
88
|
command = capture_cmd_output("fast check --bandit --dry")
|
|
88
89
|
assert "bandit -r ." in command
|
|
89
90
|
|
|
@@ -132,6 +133,23 @@ def test_lint_cmd(mock_no_dmypy):
|
|
|
132
133
|
)
|
|
133
134
|
|
|
134
135
|
|
|
136
|
+
def test_lint_html():
|
|
137
|
+
run = "pdm run "
|
|
138
|
+
lint_cmd = f"{run}python fast_dev_cli/cli.py lint"
|
|
139
|
+
command = capture_cmd_output(f"{lint_cmd} index.html --dry")
|
|
140
|
+
assert "prettier -w index.html" in command
|
|
141
|
+
command = capture_cmd_output(f"{lint_cmd} index.html flv.html --dry")
|
|
142
|
+
assert "prettier -w index.html flv.html" in command
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_lint_by_global_fast():
|
|
146
|
+
run = "pdm run "
|
|
147
|
+
fast = Path.home() / ".local" / "bin" / "fast"
|
|
148
|
+
command = capture_cmd_output(f"{fast} lint --dry")
|
|
149
|
+
for cmd in command.split(SEP):
|
|
150
|
+
assert run in cmd
|
|
151
|
+
|
|
152
|
+
|
|
135
153
|
def test_with_dmypy():
|
|
136
154
|
command = capture_cmd_output("fast lint --dmypy --dry .")
|
|
137
155
|
assert "dmypy run ." in command
|
|
@@ -200,7 +218,7 @@ def test_lint_without_ruff_installed(mocker, mock_no_dmypy):
|
|
|
200
218
|
with capture_stdout() as stream:
|
|
201
219
|
lint(".", dry=True)
|
|
202
220
|
output = stream.getvalue()
|
|
203
|
-
cmd = 'python -m pip install -U "
|
|
221
|
+
cmd = 'python -m pip install -U "fast-dev-cli"'
|
|
204
222
|
assert cmd in output
|
|
205
223
|
tip = "You may need to run following command to install lint tools"
|
|
206
224
|
assert tip in output
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import subprocess
|
|
2
3
|
import sys
|
|
3
4
|
from contextlib import contextmanager, redirect_stdout
|
|
4
5
|
from io import StringIO
|
|
@@ -66,3 +67,12 @@ def temp_file(name: str, text=""):
|
|
|
66
67
|
yield
|
|
67
68
|
if path.exists():
|
|
68
69
|
path.unlink()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@contextmanager
|
|
73
|
+
def prepare_poetry_project(tmp_path: Path):
|
|
74
|
+
with chdir(tmp_path):
|
|
75
|
+
project = "foo"
|
|
76
|
+
subprocess.run(["poetry", "new", project])
|
|
77
|
+
with chdir(tmp_path / project):
|
|
78
|
+
yield
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.14.0"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|