fast-dev-cli 0.17.1__tar.gz → 0.17.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.
Files changed (30) hide show
  1. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/PKG-INFO +1 -1
  2. fast_dev_cli-0.17.2/fast_dev_cli/__init__.py +1 -0
  3. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/fast_dev_cli/cli.py +53 -14
  4. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/pyproject.toml +1 -1
  5. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_help.py +1 -1
  6. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_lint.py +9 -1
  7. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_version.py +3 -3
  8. fast_dev_cli-0.17.1/fast_dev_cli/__init__.py +0 -1
  9. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/LICENSE +0 -0
  10. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/README.md +0 -0
  11. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/fast_dev_cli/__main__.py +0 -0
  12. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/fast_dev_cli/py.typed +0 -0
  13. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/pdm_build.py +0 -0
  14. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/scripts/check.py +0 -0
  15. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/scripts/deps.py +0 -0
  16. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/scripts/format.py +0 -0
  17. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/scripts/test.py +0 -0
  18. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/__init__.py +0 -0
  19. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/conftest.py +0 -0
  20. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_bump.py +0 -0
  21. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_exec.py +0 -0
  22. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_fast_test.py +0 -0
  23. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_functions.py +0 -0
  24. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_poetry_version_plugin.py +0 -0
  25. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_runserver.py +0 -0
  26. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_sync.py +0 -0
  27. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_tag.py +0 -0
  28. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_upgrade.py +0 -0
  29. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/test_upload.py +0 -0
  30. {fast_dev_cli-0.17.1 → fast_dev_cli-0.17.2}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.17.1
3
+ Version: 0.17.2
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -0,0 +1 @@
1
+ __version__ = "0.17.2"
@@ -89,6 +89,10 @@ def is_emoji(char: str) -> bool:
89
89
  return not "\u4e00" <= char <= "\u9fff" # Chinese character
90
90
 
91
91
 
92
+ def yellow_warn(msg: str) -> None:
93
+ secho(msg, fg="yellow")
94
+
95
+
92
96
  def load_bool(name: str, default: bool = False) -> bool:
93
97
  if not (v := os.getenv(name)):
94
98
  return default
@@ -922,6 +926,7 @@ class LintCode(DryRun):
922
926
  skip_mypy: bool = False,
923
927
  dmypy: bool = False,
924
928
  tool: str = ToolOption.default,
929
+ prefix: bool = False,
925
930
  ) -> None:
926
931
  self.args = args
927
932
  self.check_only = check_only
@@ -929,6 +934,7 @@ class LintCode(DryRun):
929
934
  self._skip_mypy = skip_mypy
930
935
  self._use_dmypy = dmypy
931
936
  self._tool = tool
937
+ self._prefix = prefix
932
938
  super().__init__(_exit, dry)
933
939
 
934
940
  @staticmethod
@@ -962,6 +968,7 @@ class LintCode(DryRun):
962
968
  skip_mypy: bool = False,
963
969
  use_dmypy: bool = False,
964
970
  tool: str = ToolOption.default,
971
+ with_prefix: bool = False,
965
972
  ) -> str:
966
973
  if paths != "." and all(i.endswith(".html") for i in paths.split()):
967
974
  return f"prettier -w {paths}"
@@ -991,23 +998,28 @@ class LintCode(DryRun):
991
998
  for i, tool in enumerate(tools, 2)
992
999
  )
993
1000
  prefix = ""
994
- should_run_by_tool = False
995
- if is_venv() and Path(sys.argv[0]).parent != Path.home().joinpath(".local/bin"):
996
- if not ruff_exists:
1001
+ should_run_by_tool = with_prefix
1002
+ if not should_run_by_tool:
1003
+ if is_venv() and Path(sys.argv[0]).parent != Path.home().joinpath(
1004
+ ".local/bin"
1005
+ ):
1006
+ if not ruff_exists:
1007
+ should_run_by_tool = True
1008
+ if check_call('python -c "import fast_dev_cli"'):
1009
+ command = 'python -m pip install -U "fast-dev-cli"'
1010
+ yellow_warn(
1011
+ "You may need to run the following command"
1012
+ f" to install lint tools:\n\n {command}\n"
1013
+ )
1014
+ else:
997
1015
  should_run_by_tool = True
998
- if check_call('python -c "import fast_dev_cli"'):
999
- command = 'python -m pip install -U "fast-dev-cli"'
1000
- tip = "You may need to run following command to install lint tools:"
1001
- secho(f"{tip}\n\n {command}\n", fg="yellow")
1002
- else:
1003
- should_run_by_tool = True
1004
1016
  if should_run_by_tool and tool:
1005
1017
  if tool == ToolOption.default:
1006
1018
  tool = Project.get_manage_tool() or ""
1007
1019
  if tool:
1008
1020
  prefix = (
1009
- str(bin_dir)
1010
- if tool == "uv" and (bin_dir := Path(".venv/bin/")).exists()
1021
+ bin_dir
1022
+ if tool == "uv" and Path(bin_dir := ".venv/bin/").exists()
1011
1023
  else (tool + " run ")
1012
1024
  )
1013
1025
  if cls.prefer_dmypy(paths, tools, use_dmypy=use_dmypy):
@@ -1030,7 +1042,13 @@ class LintCode(DryRun):
1030
1042
  args = args.split()
1031
1043
  paths = " ".join(map(str, args)) if args else "."
1032
1044
  return self.to_cmd(
1033
- paths, self.check_only, self._bandit, self._skip_mypy, self._use_dmypy
1045
+ paths,
1046
+ self.check_only,
1047
+ self._bandit,
1048
+ self._skip_mypy,
1049
+ self._use_dmypy,
1050
+ tool=self._tool,
1051
+ with_prefix=self._prefix,
1034
1052
  )
1035
1053
 
1036
1054
 
@@ -1045,13 +1063,20 @@ def lint(
1045
1063
  skip_mypy: bool = False,
1046
1064
  dmypy: bool = False,
1047
1065
  tool: str = ToolOption.default,
1066
+ prefix: bool = False,
1048
1067
  ) -> None:
1049
1068
  if files is None:
1050
1069
  files = parse_files(sys.argv[1:])
1051
1070
  if files and files[0] == "lint":
1052
1071
  files = files[1:]
1053
1072
  LintCode(
1054
- files, dry=dry, skip_mypy=skip_mypy, bandit=bandit, dmypy=dmypy, tool=tool
1073
+ files,
1074
+ dry=dry,
1075
+ skip_mypy=skip_mypy,
1076
+ bandit=bandit,
1077
+ dmypy=dmypy,
1078
+ tool=tool,
1079
+ prefix=prefix,
1055
1080
  ).run()
1056
1081
 
1057
1082
 
@@ -1080,6 +1105,11 @@ def make_style(
1080
1105
  files: Optional[list[str]] = typer.Argument(default=None), # noqa:B008
1081
1106
  check_only: bool = Option(False, "--check-only", "-c"),
1082
1107
  bandit: bool = Option(False, "--bandit", help="Run `bandit -r <package_dir>`"),
1108
+ prefix: bool = Option(
1109
+ False,
1110
+ "--prefix",
1111
+ help="Run lint command with tool prefix, e.g.: pdm run ruff ...",
1112
+ ),
1083
1113
  skip_mypy: bool = Option(False, "--skip-mypy"),
1084
1114
  use_dmypy: bool = Option(
1085
1115
  False, "--dmypy", help="Use `dmypy run` instead of `mypy`"
@@ -1095,11 +1125,20 @@ def make_style(
1095
1125
  skip = _ensure_bool(skip_mypy)
1096
1126
  dmypy = _ensure_bool(use_dmypy)
1097
1127
  bandit = _ensure_bool(bandit)
1128
+ prefix = _ensure_bool(prefix)
1098
1129
  tool = _ensure_str(tool)
1099
1130
  if _ensure_bool(check_only):
1100
1131
  check(files, dry=dry, skip_mypy=skip, dmypy=dmypy, bandit=bandit, tool=tool)
1101
1132
  else:
1102
- lint(files, dry=dry, skip_mypy=skip, dmypy=dmypy, bandit=bandit, tool=tool)
1133
+ lint(
1134
+ files,
1135
+ dry=dry,
1136
+ skip_mypy=skip,
1137
+ dmypy=dmypy,
1138
+ bandit=bandit,
1139
+ tool=tool,
1140
+ prefix=prefix,
1141
+ )
1103
1142
 
1104
1143
 
1105
1144
  @cli.command(name="check")
@@ -42,7 +42,7 @@ dependencies = [
42
42
  "bumpversion2 >=1.4.3,<2",
43
43
  "pytest >=8.2.0,<9",
44
44
  ]
45
- version = "0.17.1"
45
+ version = "0.17.2"
46
46
 
47
47
  [project.urls]
48
48
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -4,4 +4,4 @@ from asynctor import Shell
4
4
  def test_help():
5
5
  out = Shell("fast").capture_output()
6
6
  out_help = Shell("fast --help").capture_output()
7
- assert out == out_help
7
+ assert out.strip() == out_help.strip()
@@ -187,6 +187,14 @@ def test_lint_with_prefix(mocker):
187
187
  assert "pdm run" in stream.getvalue()
188
188
 
189
189
 
190
+ def test_fast_lint_with_uv():
191
+ command = capture_cmd_output("fast lint --tool=uv --prefix --dry")
192
+ assert (
193
+ command
194
+ == "--> ruff format . && ruff check --extend-select=I,B,SIM --fix . && .venv/bin/mypy ."
195
+ )
196
+
197
+
190
198
  def test_make_style(mock_skip_mypy_0, mocker, mock_no_dmypy):
191
199
  mocker.patch("fast_dev_cli.cli.is_venv", return_value=True)
192
200
  with capture_stdout() as stream:
@@ -239,7 +247,7 @@ def test_lint_without_ruff_installed(mocker, mock_no_dmypy):
239
247
  output = stream.getvalue()
240
248
  cmd = 'python -m pip install -U "fast-dev-cli"'
241
249
  assert cmd in output
242
- tip = "You may need to run following command to install lint tools"
250
+ tip = "You may need to run the following command to install lint tools"
243
251
  assert tip in output
244
252
  assert f"{tip}:\n\n {cmd}" in output
245
253
 
@@ -67,12 +67,12 @@ def test_display_self_version(capsys):
67
67
  version_callback(True)
68
68
  assert __version__ in capsys.readouterr().out
69
69
  out = Shell("fast --version").capture_output().strip()
70
- assert out == "Fast Dev Cli Version: 0.17.0"
70
+ assert out == f"Fast Dev Cli Version: {__version__}"
71
71
  out_v = Shell("fast -V").capture_output().strip()
72
72
  assert out_v == out
73
73
 
74
74
 
75
75
  def test_fast_version(capsys):
76
76
  out = Shell("fast version").capture_output().strip()
77
- assert "Fast Dev Cli Version: 0.17.0" in out
78
- assert "fast_dev_cli/__init__.py: 0.17.0" in out
77
+ assert f"Fast Dev Cli Version: {__version__}" in out
78
+ assert f"fast_dev_cli/__init__.py: {__version__}" in out
@@ -1 +0,0 @@
1
- __version__ = "0.17.1"
File without changes
File without changes