fast-dev-cli 0.19.2__tar.gz → 0.19.4__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 (34) hide show
  1. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/PKG-INFO +7 -11
  2. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/README.md +6 -10
  3. fast_dev_cli-0.19.4/fast_dev_cli/__init__.py +1 -0
  4. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/fast_dev_cli/cli.py +49 -9
  5. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/pyproject.toml +1 -1
  6. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_exec.py +10 -0
  7. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_lint.py +37 -0
  8. fast_dev_cli-0.19.2/fast_dev_cli/__init__.py +0 -1
  9. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/LICENSE +0 -0
  10. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/fast_dev_cli/__main__.py +0 -0
  11. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/fast_dev_cli/py.typed +0 -0
  12. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/pdm_build.py +0 -0
  13. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/scripts/check.py +0 -0
  14. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/scripts/deps.py +0 -0
  15. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/scripts/format.py +0 -0
  16. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/scripts/test.py +0 -0
  17. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/__init__.py +0 -0
  18. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/assets/uv-tx.lock +0 -0
  19. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/assets/uv.lock +0 -0
  20. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/conftest.py +0 -0
  21. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_bump.py +0 -0
  22. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_deps.py +0 -0
  23. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_fast_test.py +0 -0
  24. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_functions.py +0 -0
  25. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_help.py +0 -0
  26. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_poetry_version_plugin.py +0 -0
  27. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_pypi.py +0 -0
  28. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_runserver.py +0 -0
  29. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_sync.py +0 -0
  30. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_tag.py +0 -0
  31. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_upgrade.py +0 -0
  32. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_upload.py +0 -0
  33. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/test_version.py +0 -0
  34. {fast_dev_cli-0.19.2 → fast_dev_cli-0.19.4}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.19.2
3
+ Version: 0.19.4
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -74,7 +74,7 @@ Description-Content-Type: text/markdown
74
74
 
75
75
  ## Requirements
76
76
 
77
- Python 3.9+
77
+ Python 3.10+
78
78
 
79
79
  ## Features
80
80
 
@@ -88,7 +88,7 @@ Python 3.9+
88
88
  ```bash
89
89
  pip install fast-dev-cli
90
90
  ```
91
- *Will install: fast-dev-cli emoji typer ruff mypy bumpversion2 pytest coverage*
91
+ *Will install: fast-dev-cli emoji typer-slim mypy bumpversion2 pytest coverage*
92
92
 
93
93
  </div>
94
94
 
@@ -113,21 +113,17 @@ fast bump <part> --commit # bump version and run `git commit`
113
113
  ```bash
114
114
  fast test
115
115
  ```
116
- - Export requirement file and install `pip install -r `
116
+ - Install dependencies, support pip/pdm/uv/poetry
117
117
  ```bash
118
- fast sync
119
- ```
120
- - Upgrade main/dev dependencies to latest version (only for poetry project)
121
- ```bash
122
- fast upgrade
118
+ fast deps
123
119
  ```
124
120
  - Start a fastapi server in development mode
125
121
  ```bash
126
122
  fast dev
127
123
  ```
128
- - Publish to pypi
124
+ - Change register of uv.lock to be pypi.org
129
125
  ```bash
130
- fast upload
126
+ fast pypi
131
127
  ```
132
128
  *Note: all command support the `--dry` option*
133
129
 
@@ -39,7 +39,7 @@
39
39
 
40
40
  ## Requirements
41
41
 
42
- Python 3.9+
42
+ Python 3.10+
43
43
 
44
44
  ## Features
45
45
 
@@ -53,7 +53,7 @@ Python 3.9+
53
53
  ```bash
54
54
  pip install fast-dev-cli
55
55
  ```
56
- *Will install: fast-dev-cli emoji typer ruff mypy bumpversion2 pytest coverage*
56
+ *Will install: fast-dev-cli emoji typer-slim mypy bumpversion2 pytest coverage*
57
57
 
58
58
  </div>
59
59
 
@@ -78,21 +78,17 @@ fast bump <part> --commit # bump version and run `git commit`
78
78
  ```bash
79
79
  fast test
80
80
  ```
81
- - Export requirement file and install `pip install -r `
81
+ - Install dependencies, support pip/pdm/uv/poetry
82
82
  ```bash
83
- fast sync
84
- ```
85
- - Upgrade main/dev dependencies to latest version (only for poetry project)
86
- ```bash
87
- fast upgrade
83
+ fast deps
88
84
  ```
89
85
  - Start a fastapi server in development mode
90
86
  ```bash
91
87
  fast dev
92
88
  ```
93
- - Publish to pypi
89
+ - Change register of uv.lock to be pypi.org
94
90
  ```bash
95
- fast upload
91
+ fast pypi
96
92
  ```
97
93
  *Note: all command support the `--dry` option*
98
94
 
@@ -0,0 +1 @@
1
+ __version__ = "0.19.4"
@@ -139,14 +139,25 @@ class Shell:
139
139
  @property
140
140
  def command(self) -> list[str] | str:
141
141
  command: list[str] | str = self._cmd
142
- if (
143
- isinstance(command, str)
144
- and "shell" not in self._kw
145
- and not (set(self._cmd) & {"|", ">", "&"})
146
- ):
147
- command = shlex.split(command)
142
+ if isinstance(command, str):
143
+ cs = shlex.split(command)
144
+ if "shell" not in self._kw and not (set(self._cmd) & {"|", ">", "&"}):
145
+ command = self.extend_user(cs)
146
+ elif any(i.startswith("~") for i in cs):
147
+ command = re.sub(r" ~", " " + os.path.expanduser("~"), command)
148
+ else:
149
+ command = self.extend_user(command)
148
150
  return command
149
151
 
152
+ @staticmethod
153
+ def extend_user(cs: list[str]) -> list[str]:
154
+ if cs[0] == "echo":
155
+ return cs
156
+ for i, c in enumerate(cs):
157
+ if c.startswith("~"):
158
+ cs[i] = os.path.expanduser(c)
159
+ return cs
160
+
150
161
  def _run(self) -> subprocess.CompletedProcess[str]:
151
162
  return self.run_by_subprocess(self.command, **self._kw)
152
163
 
@@ -1047,6 +1058,8 @@ class LintCode(DryRun):
1047
1058
  dmypy: bool = False,
1048
1059
  tool: str = ToolOption.default,
1049
1060
  prefix: bool = False,
1061
+ up: bool = False,
1062
+ sim: bool = True,
1050
1063
  ) -> None:
1051
1064
  self.args = args
1052
1065
  self.check_only = check_only
@@ -1055,6 +1068,8 @@ class LintCode(DryRun):
1055
1068
  self._use_dmypy = dmypy
1056
1069
  self._tool = tool
1057
1070
  self._prefix = prefix
1071
+ self._up = up
1072
+ self._sim = sim
1058
1073
  super().__init__(_exit, dry)
1059
1074
 
1060
1075
  @staticmethod
@@ -1097,6 +1112,8 @@ class LintCode(DryRun):
1097
1112
  use_dmypy: bool = False,
1098
1113
  tool: str = ToolOption.default,
1099
1114
  with_prefix: bool = False,
1115
+ ruff_check_up: bool = False,
1116
+ ruff_check_sim: bool = True,
1100
1117
  ) -> str:
1101
1118
  if paths != "." and all(i.endswith(".html") for i in paths.split()):
1102
1119
  return f"prettier -w {paths}"
@@ -1106,6 +1123,10 @@ class LintCode(DryRun):
1106
1123
  tools[0] += " --check"
1107
1124
  if check_only or load_bool("NO_FIX"):
1108
1125
  tools[1] = tools[1].replace(" --fix", "")
1126
+ if ruff_check_up or load_bool("FASTDEVCLI_UP"):
1127
+ tools[1] = tools[1].replace(",SIM", ",SIM,UP")
1128
+ if not ruff_check_sim or load_bool("FASTDEVCLI_NO_SIM"):
1129
+ tools[1] = tools[1].replace(",SIM", "")
1109
1130
  if skip_mypy or load_bool("SKIP_MYPY") or load_bool("FASTDEVCLI_NO_MYPY"):
1110
1131
  # Sometimes mypy is too slow
1111
1132
  tools = tools[:-1]
@@ -1216,6 +1237,8 @@ class LintCode(DryRun):
1216
1237
  self._use_dmypy,
1217
1238
  tool=self._tool,
1218
1239
  with_prefix=self._prefix,
1240
+ ruff_check_up=self._up,
1241
+ ruff_check_sim=self._sim,
1219
1242
  )
1220
1243
 
1221
1244
 
@@ -1231,6 +1254,8 @@ def lint(
1231
1254
  dmypy: bool = False,
1232
1255
  tool: str = ToolOption.default,
1233
1256
  prefix: bool = False,
1257
+ up: bool = False,
1258
+ sim: bool = True,
1234
1259
  ) -> None:
1235
1260
  if files is None:
1236
1261
  files = parse_files(sys.argv[1:])
@@ -1244,6 +1269,8 @@ def lint(
1244
1269
  dmypy=dmypy,
1245
1270
  tool=tool,
1246
1271
  prefix=prefix,
1272
+ up=up,
1273
+ sim=sim,
1247
1274
  ).run()
1248
1275
 
1249
1276
 
@@ -1254,6 +1281,8 @@ def check(
1254
1281
  skip_mypy: bool = False,
1255
1282
  dmypy: bool = False,
1256
1283
  tool: str = ToolOption.default,
1284
+ up: bool = False,
1285
+ sim: bool = True,
1257
1286
  ) -> None:
1258
1287
  LintCode(
1259
1288
  files,
@@ -1264,6 +1293,8 @@ def check(
1264
1293
  skip_mypy=skip_mypy,
1265
1294
  dmypy=dmypy,
1266
1295
  tool=tool,
1296
+ up=up,
1297
+ sim=sim,
1267
1298
  ).run()
1268
1299
 
1269
1300
 
@@ -1283,6 +1314,8 @@ def make_style(
1283
1314
  ),
1284
1315
  tool: str = ToolOption,
1285
1316
  dry: bool = DryOption,
1317
+ up: bool = Option(False, help="Whether ruff check with --extend-select=UP"),
1318
+ sim: bool = Option(True, help="Whether ruff check with --extend-select=SIM"),
1286
1319
  ) -> None:
1287
1320
  """Run: ruff check/format to reformat code and then mypy to check"""
1288
1321
  if getattr(files, "default", files) is None:
@@ -1294,11 +1327,13 @@ def make_style(
1294
1327
  bandit = _ensure_bool(bandit)
1295
1328
  prefix = _ensure_bool(prefix)
1296
1329
  tool = _ensure_str(tool)
1330
+ up = _ensure_bool(up)
1331
+ sim = _ensure_bool(sim)
1297
1332
  kwargs = {"dry": dry, "skip_mypy": skip, "dmypy": dmypy, "bandit": bandit}
1298
1333
  if _ensure_bool(check_only):
1299
- check(files, tool=tool, **kwargs)
1334
+ check(files, tool=tool, up=up, sim=sim, **kwargs)
1300
1335
  else:
1301
- lint(files, prefix=prefix, tool=tool, **kwargs)
1336
+ lint(files, prefix=prefix, tool=tool, up=up, sim=sim, **kwargs)
1302
1337
 
1303
1338
 
1304
1339
  @cli.command(name="check")
@@ -1306,9 +1341,14 @@ def only_check(
1306
1341
  bandit: bool = Option(False, "--bandit", help="Run `bandit -r <package_dir>`"),
1307
1342
  skip_mypy: bool = Option(False, "--skip-mypy"),
1308
1343
  dry: bool = DryOption,
1344
+ up: bool = Option(False, help="Whether ruff check with --extend-select=UP"),
1345
+ sim: bool = Option(True, help="Whether ruff check with --extend-select=SIM"),
1309
1346
  ) -> None:
1310
1347
  """Check code style without reformat"""
1311
- check(dry=dry, bandit=bandit, skip_mypy=_ensure_bool(skip_mypy))
1348
+ bandit = _ensure_bool(bandit)
1349
+ up = _ensure_bool(up)
1350
+ sim = _ensure_bool(sim)
1351
+ check(dry=dry, bandit=bandit, skip_mypy=_ensure_bool(skip_mypy), up=up, sim=sim)
1312
1352
 
1313
1353
 
1314
1354
  class Sync(DryRun):
@@ -41,7 +41,7 @@ dependencies = [
41
41
  "bumpversion2 >=1.4.3",
42
42
  "pytest >=8.2.0",
43
43
  ]
44
- version = "0.19.2"
44
+ version = "0.19.4"
45
45
 
46
46
  [project.urls]
47
47
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -1,3 +1,5 @@
1
+ import os
2
+
1
3
  import pytest
2
4
 
3
5
  from fast_dev_cli.cli import Exit, capture_cmd_output, run_by_subprocess
@@ -15,6 +17,8 @@ def test_exec_dry():
15
17
  )
16
18
  assert "success" in out
17
19
  assert "failed" not in out
20
+ out = capture_cmd_output('fast exec "python ~/0.py" --dry')
21
+ assert "--> python ~/0.py" in out
18
22
 
19
23
 
20
24
  def test_exec():
@@ -29,6 +33,12 @@ def test_exec():
29
33
  )
30
34
  assert "failed" in out
31
35
  assert "success" not in out
36
+ out = capture_cmd_output('fast exec "ls -a ~/"')
37
+ assert "--> ls -a ~" in out
38
+ assert ".bashrc" in out
39
+ home = os.path.expanduser("~")
40
+ expected = capture_cmd_output(f"ls {home}")
41
+ assert not (set(expected.splitlines()) - set(out.splitlines()))
32
42
 
33
43
 
34
44
  def test_run_by_subprocess(capsys):
@@ -74,6 +74,43 @@ def test_check(mock_no_dmypy, monkeypatch, mocker):
74
74
  assert command4 == command
75
75
 
76
76
 
77
+ def test_check_up_sim(monkeypatch):
78
+ _test_up_sim(monkeypatch)
79
+
80
+
81
+ def test_lint_up_sim(monkeypatch):
82
+ _test_up_sim(monkeypatch, "lint")
83
+
84
+
85
+ def _test_up_sim(monkeypatch, command="check"):
86
+ out = capture_cmd_output(f"fast {command} --up --dry")
87
+ assert "--extend-select=I,B,SIM,UP " in out
88
+ out = capture_cmd_output(f"fast {command} --no-sim --up --dry")
89
+ assert "--extend-select=I,B,UP " in out
90
+ out = capture_cmd_output(f"fast {command} --no-sim --dry")
91
+ assert "--extend-select=I,B " in out
92
+ out = capture_cmd_output(f"fast {command} --dry")
93
+ assert "--extend-select=I,B,SIM " in out
94
+ monkeypatch.setenv("FASTDEVCLI_NO_SIM", "1")
95
+ out = capture_cmd_output(f"fast {command} --dry")
96
+ assert "--extend-select=I,B " in out
97
+ monkeypatch.setenv("FASTDEVCLI_NO_SIM", "0")
98
+ out = capture_cmd_output(f"fast {command} --dry")
99
+ assert "--extend-select=I,B,SIM " in out
100
+ monkeypatch.setenv("FASTDEVCLI_UP", "1")
101
+ out = capture_cmd_output(f"fast {command} --dry")
102
+ assert "--extend-select=I,B,SIM,UP " in out
103
+ monkeypatch.setenv("FASTDEVCLI_NO_SIM", "1")
104
+ out = capture_cmd_output(f"fast {command} --dry")
105
+ assert "--extend-select=I,B,UP " in out
106
+ monkeypatch.setenv("FASTDEVCLI_UP", "0")
107
+ out = capture_cmd_output(f"fast {command} --dry")
108
+ assert "--extend-select=I,B " in out
109
+ monkeypatch.setenv("FASTDEVCLI_NO_SIM", "0")
110
+ out = capture_cmd_output(f"fast {command} --dry")
111
+ assert "--extend-select=I,B,SIM " in out
112
+
113
+
77
114
  def test_check_bandit(tmp_path):
78
115
  package_path = tmp_path / "foo"
79
116
  with chdir(tmp_path):
@@ -1 +0,0 @@
1
- __version__ = "0.19.2"
File without changes