fast-dev-cli 0.19.4__tar.gz → 0.19.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.
Files changed (34) hide show
  1. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/PKG-INFO +1 -1
  2. fast_dev_cli-0.19.5/fast_dev_cli/__init__.py +1 -0
  3. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/fast_dev_cli/cli.py +22 -10
  4. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/pyproject.toml +1 -1
  5. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/conftest.py +2 -5
  6. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_lint.py +4 -1
  7. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_upgrade.py +20 -16
  8. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/utils.py +18 -13
  9. fast_dev_cli-0.19.4/fast_dev_cli/__init__.py +0 -1
  10. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/LICENSE +0 -0
  11. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/README.md +0 -0
  12. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/fast_dev_cli/__main__.py +0 -0
  13. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/fast_dev_cli/py.typed +0 -0
  14. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/pdm_build.py +0 -0
  15. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/scripts/check.py +0 -0
  16. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/scripts/deps.py +0 -0
  17. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/scripts/format.py +0 -0
  18. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/scripts/test.py +0 -0
  19. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/__init__.py +0 -0
  20. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/assets/uv-tx.lock +0 -0
  21. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/assets/uv.lock +0 -0
  22. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_bump.py +0 -0
  23. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_deps.py +0 -0
  24. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_exec.py +0 -0
  25. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_fast_test.py +0 -0
  26. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_functions.py +0 -0
  27. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_help.py +0 -0
  28. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_poetry_version_plugin.py +0 -0
  29. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_pypi.py +0 -0
  30. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_runserver.py +0 -0
  31. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_sync.py +0 -0
  32. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_tag.py +0 -0
  33. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_upload.py +0 -0
  34. {fast_dev_cli-0.19.4 → fast_dev_cli-0.19.5}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.19.4
3
+ Version: 0.19.5
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.19.5"
@@ -180,7 +180,7 @@ class Shell:
180
180
  return (r.stdout or r.stderr or "").strip()
181
181
 
182
182
  def finish(
183
- self, env: dict[str, str] | None = None, _exit: bool = False, dry=False
183
+ self, env: dict[str, str] | None = None, _exit: bool = False, dry: bool = False
184
184
  ) -> subprocess.CompletedProcess[str]:
185
185
  self.run(verbose=True, dry=True)
186
186
  if _ensure_bool(dry):
@@ -395,7 +395,7 @@ class BumpUp(DryRun):
395
395
  @staticmethod
396
396
  def parse_dynamic_version(
397
397
  toml_text: str,
398
- context: dict,
398
+ context: dict[str, Any],
399
399
  work_dir: Path | None = None,
400
400
  ) -> str | None:
401
401
  if work_dir is None:
@@ -457,7 +457,7 @@ class BumpUp(DryRun):
457
457
  return TOML_FILE
458
458
 
459
459
  @staticmethod
460
- def parse_plugin_version(context: dict, package_name: str | None) -> str:
460
+ def parse_plugin_version(context: dict[str, Any], package_name: str | None) -> str:
461
461
  try:
462
462
  package_item = context["tool"]["poetry"]["packages"]
463
463
  except KeyError:
@@ -761,7 +761,7 @@ class Project:
761
761
 
762
762
  @classmethod
763
763
  def get_sync_command(
764
- cls, prod: bool = True, doc: dict | None = None, only_me: bool = False
764
+ cls, prod: bool = True, doc: dict[str, Any] | None = None, only_me: bool = False
765
765
  ) -> str:
766
766
  pdm_i = "pdm install --frozen" + " --prod" * prod
767
767
  if cls.is_pdm_project():
@@ -1060,6 +1060,7 @@ class LintCode(DryRun):
1060
1060
  prefix: bool = False,
1061
1061
  up: bool = False,
1062
1062
  sim: bool = True,
1063
+ strict: bool = False,
1063
1064
  ) -> None:
1064
1065
  self.args = args
1065
1066
  self.check_only = check_only
@@ -1070,6 +1071,7 @@ class LintCode(DryRun):
1070
1071
  self._prefix = prefix
1071
1072
  self._up = up
1072
1073
  self._sim = sim
1074
+ self._strict = strict
1073
1075
  super().__init__(_exit, dry)
1074
1076
 
1075
1077
  @staticmethod
@@ -1114,6 +1116,7 @@ class LintCode(DryRun):
1114
1116
  with_prefix: bool = False,
1115
1117
  ruff_check_up: bool = False,
1116
1118
  ruff_check_sim: bool = True,
1119
+ mypy_strict: bool = False,
1117
1120
  ) -> str:
1118
1121
  if paths != "." and all(i.endswith(".html") for i in paths.split()):
1119
1122
  return f"prettier -w {paths}"
@@ -1130,8 +1133,11 @@ class LintCode(DryRun):
1130
1133
  if skip_mypy or load_bool("SKIP_MYPY") or load_bool("FASTDEVCLI_NO_MYPY"):
1131
1134
  # Sometimes mypy is too slow
1132
1135
  tools = tools[:-1]
1133
- elif load_bool("IGNORE_MISSING_IMPORTS"):
1134
- tools[-1] += " --ignore-missing-imports"
1136
+ else:
1137
+ if load_bool("IGNORE_MISSING_IMPORTS"):
1138
+ tools[-1] += " --ignore-missing-imports"
1139
+ if mypy_strict or load_bool("FASTDEVCLI_STRICT"):
1140
+ tools[-1] += " --strict"
1135
1141
  lint_them = " && ".join(
1136
1142
  "{0}{" + str(i) + "} {1}" for i in range(2, len(tools) + 2)
1137
1143
  )
@@ -1239,6 +1245,7 @@ class LintCode(DryRun):
1239
1245
  with_prefix=self._prefix,
1240
1246
  ruff_check_up=self._up,
1241
1247
  ruff_check_sim=self._sim,
1248
+ mypy_strict=self._strict,
1242
1249
  )
1243
1250
 
1244
1251
 
@@ -1256,6 +1263,7 @@ def lint(
1256
1263
  prefix: bool = False,
1257
1264
  up: bool = False,
1258
1265
  sim: bool = True,
1266
+ strict: bool = False,
1259
1267
  ) -> None:
1260
1268
  if files is None:
1261
1269
  files = parse_files(sys.argv[1:])
@@ -1271,6 +1279,7 @@ def lint(
1271
1279
  prefix=prefix,
1272
1280
  up=up,
1273
1281
  sim=sim,
1282
+ strict=strict,
1274
1283
  ).run()
1275
1284
 
1276
1285
 
@@ -1283,6 +1292,7 @@ def check(
1283
1292
  tool: str = ToolOption.default,
1284
1293
  up: bool = False,
1285
1294
  sim: bool = True,
1295
+ strict: bool = False,
1286
1296
  ) -> None:
1287
1297
  LintCode(
1288
1298
  files,
@@ -1295,6 +1305,7 @@ def check(
1295
1305
  tool=tool,
1296
1306
  up=up,
1297
1307
  sim=sim,
1308
+ strict=strict,
1298
1309
  ).run()
1299
1310
 
1300
1311
 
@@ -1316,6 +1327,7 @@ def make_style(
1316
1327
  dry: bool = DryOption,
1317
1328
  up: bool = Option(False, help="Whether ruff check with --extend-select=UP"),
1318
1329
  sim: bool = Option(True, help="Whether ruff check with --extend-select=SIM"),
1330
+ strict: bool = Option(False, help="Whether run mypy with --strict"),
1319
1331
  ) -> None:
1320
1332
  """Run: ruff check/format to reformat code and then mypy to check"""
1321
1333
  if getattr(files, "default", files) is None:
@@ -1329,11 +1341,10 @@ def make_style(
1329
1341
  tool = _ensure_str(tool)
1330
1342
  up = _ensure_bool(up)
1331
1343
  sim = _ensure_bool(sim)
1344
+ strict = _ensure_bool(strict)
1332
1345
  kwargs = {"dry": dry, "skip_mypy": skip, "dmypy": dmypy, "bandit": bandit}
1333
- if _ensure_bool(check_only):
1334
- check(files, tool=tool, up=up, sim=sim, **kwargs)
1335
- else:
1336
- lint(files, prefix=prefix, tool=tool, up=up, sim=sim, **kwargs)
1346
+ run = check if _ensure_bool(check_only) else functools.partial(lint, prefix=prefix)
1347
+ run(files, tool=tool, up=up, sim=sim, strict=strict, **kwargs)
1337
1348
 
1338
1349
 
1339
1350
  @cli.command(name="check")
@@ -1343,6 +1354,7 @@ def only_check(
1343
1354
  dry: bool = DryOption,
1344
1355
  up: bool = Option(False, help="Whether ruff check with --extend-select=UP"),
1345
1356
  sim: bool = Option(True, help="Whether ruff check with --extend-select=SIM"),
1357
+ strict: bool = Option(False, help="Whether run mypy with --strict"),
1346
1358
  ) -> None:
1347
1359
  """Check code style without reformat"""
1348
1360
  bandit = _ensure_bool(bandit)
@@ -41,7 +41,7 @@ dependencies = [
41
41
  "bumpversion2 >=1.4.3",
42
42
  "pytest >=8.2.0",
43
43
  ]
44
- version = "0.19.4"
44
+ version = "0.19.5"
45
45
 
46
46
  [project.urls]
47
47
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -1,7 +1,7 @@
1
1
  from pathlib import Path
2
2
 
3
3
  import pytest
4
- from asynctor.compat import chdir
4
+ from asynctor.testing import chdir_tmp_fixture
5
5
 
6
6
  from fast_dev_cli.cli import TOML_FILE, run_and_echo
7
7
 
@@ -49,10 +49,7 @@ build-backend = "poetry.core.masonry.api"
49
49
  """
50
50
 
51
51
 
52
- @pytest.fixture
53
- def tmp_work_dir(tmp_path):
54
- with chdir(tmp_path):
55
- yield tmp_path
52
+ tmp_work_dir = chdir_tmp_fixture()
56
53
 
57
54
 
58
55
  @pytest.fixture
@@ -162,7 +162,7 @@ def _fast_check():
162
162
  assert cmd in command
163
163
 
164
164
 
165
- def test_lint_cmd(mock_no_dmypy):
165
+ def test_lint_cmd(mock_no_dmypy, monkeypatch):
166
166
  run = "pdm run "
167
167
  lint_cmd = f"{run}python fast_dev_cli/cli.py lint"
168
168
  command = capture_cmd_output(f"{lint_cmd} . --dry")
@@ -178,6 +178,9 @@ def test_lint_cmd(mock_no_dmypy):
178
178
  == capture_cmd_output(f"{lint_cmd}")
179
179
  == capture_cmd_output(f"{run}fast lint")
180
180
  )
181
+ assert "mypy --strict" in capture_cmd_output("fast lint --strict --dry")
182
+ monkeypatch.setenv("FASTDEVCLI_STRICT", "1")
183
+ assert "mypy --strict" in capture_cmd_output("fast lint --dry")
181
184
 
182
185
 
183
186
  def test_lint_html():
@@ -85,24 +85,28 @@ uvicorn = {version = "^0.23.2", platform = "linux", optional = true}
85
85
  def test_dev_flag(tmp_path: Path):
86
86
  assert UpgradeDependencies.should_with_dev() is False
87
87
  with prepare_poetry_project(tmp_path) as poetry:
88
- is_newer_poetry = Project.get_poetry_version(poetry) >= "2.2.0"
89
- assert not UpgradeDependencies.should_with_dev()
90
- run_and_echo(f"{poetry} add pytest")
88
+ _test_dev_flag(poetry)
89
+
90
+
91
+ def _test_dev_flag(poetry):
92
+ is_newer_poetry = Project.get_poetry_version(poetry) >= "2.2.0"
93
+ assert not UpgradeDependencies.should_with_dev()
94
+ run_and_echo(f"{poetry} add pytest")
95
+ assert not UpgradeDependencies.should_with_dev()
96
+ run_and_echo(f"{poetry} add --group=dev typer")
97
+ if is_newer_poetry:
91
98
  assert not UpgradeDependencies.should_with_dev()
92
- run_and_echo(f"{poetry} add --group=dev typer")
93
- if is_newer_poetry:
94
- assert not UpgradeDependencies.should_with_dev()
99
+ else:
100
+ toml_file = Path(TOML_FILE)
101
+ assert UpgradeDependencies.should_with_dev()
102
+ text = toml_file.read_text()
103
+ DevFlag = UpgradeDependencies.DevFlag
104
+ if DevFlag.new in text:
105
+ new_text = text.replace(DevFlag.new, DevFlag.old)
95
106
  else:
96
- toml_file = Path(TOML_FILE)
97
- assert UpgradeDependencies.should_with_dev()
98
- text = toml_file.read_text()
99
- DevFlag = UpgradeDependencies.DevFlag
100
- if DevFlag.new in text:
101
- new_text = text.replace(DevFlag.new, DevFlag.old)
102
- else:
103
- new_text = text.replace(DevFlag.old, DevFlag.new)
104
- toml_file.write_text(new_text)
105
- assert UpgradeDependencies.should_with_dev()
107
+ new_text = text.replace(DevFlag.old, DevFlag.new)
108
+ toml_file.write_text(new_text)
109
+ assert UpgradeDependencies.should_with_dev()
106
110
 
107
111
 
108
112
  def test_parse_item():
@@ -47,23 +47,28 @@ def temp_file(name: str, text=""):
47
47
  path.write_text(text)
48
48
  else:
49
49
  path.touch()
50
- yield
51
- if path.exists():
52
- path.unlink()
50
+ try:
51
+ yield
52
+ finally:
53
+ if path.exists():
54
+ path.unlink()
53
55
 
54
56
 
55
57
  @contextmanager
56
- def prepare_poetry_project(tmp_path: Path) -> Generator[str]:
58
+ def prepare_poetry_project(work_dir: Path) -> Generator[str]:
57
59
  py = "{}.{}".format(*sys.version_info)
58
60
  poetry = "poetry"
59
61
  if shutil.which(poetry) is None:
60
62
  poetry = "uvx " + poetry
61
- with chdir(tmp_path):
62
- project = "foo"
63
- Shell.run_by_subprocess(f"{poetry} new {project} --python=^{py}")
64
- with chdir(tmp_path / project):
65
- Shell.run_by_subprocess(
66
- f"{poetry} config --local virtualenvs.in-project true"
67
- )
68
- Shell.run_by_subprocess(f"{poetry} env use {py}")
69
- yield poetry
63
+ project = "foo"
64
+ with chdir(work_dir), _new_poetry_project(py, poetry, project):
65
+ yield poetry
66
+
67
+
68
+ @contextmanager
69
+ def _new_poetry_project(py: str, poetry: str, project: str) -> Generator[None]:
70
+ Shell.run_by_subprocess(f"{poetry} new {project} --python=^{py}")
71
+ with chdir(project):
72
+ Shell.run_by_subprocess(f"{poetry} config --local virtualenvs.in-project true")
73
+ Shell.run_by_subprocess(f"{poetry} env use {py}")
74
+ yield
@@ -1 +0,0 @@
1
- __version__ = "0.19.4"
File without changes
File without changes