fast-dev-cli 0.11.6__tar.gz → 0.12.0__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 (27) hide show
  1. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/PKG-INFO +3 -3
  2. fast_dev_cli-0.12.0/fast_dev_cli/__init__.py +1 -0
  3. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/fast_dev_cli/cli.py +35 -19
  4. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/pyproject.toml +11 -3
  5. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_fast_test.py +1 -1
  6. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_poetry_version_plugin.py +3 -3
  7. fast_dev_cli-0.11.6/fast_dev_cli/__init__.py +0 -1
  8. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/LICENSE +0 -0
  9. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/README.md +0 -0
  10. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/fast_dev_cli/__main__.py +0 -0
  11. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/fast_dev_cli/py.typed +0 -0
  12. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/pdm_build.py +0 -0
  13. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/scripts/check.py +0 -0
  14. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/scripts/format.py +0 -0
  15. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/scripts/test.py +0 -0
  16. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/__init__.py +0 -0
  17. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/conftest.py +0 -0
  18. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_bump.py +0 -0
  19. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_functions.py +0 -0
  20. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_lint.py +0 -0
  21. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_runserver.py +0 -0
  22. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_sync.py +0 -0
  23. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_tag.py +0 -0
  24. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_upgrade.py +0 -0
  25. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_upload.py +0 -0
  26. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/test_version.py +0 -0
  27. {fast_dev_cli-0.11.6 → fast_dev_cli-0.12.0}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.11.6
3
+ Version: 0.12.0
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -20,8 +20,8 @@ Classifier: Topic :: Software Development
20
20
  Classifier: Typing :: Typed
21
21
  Classifier: License :: OSI Approved :: MIT License
22
22
  Project-URL: Homepage, https://github.com/waketzheng/fast-dev-cli
23
- Requires-Python: <4,>=3.9
24
- Requires-Dist: typer<0.16,>=0.12.3
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: typer<1,>=0.12.3
25
25
  Requires-Dist: emoji<3,>=2.12.1
26
26
  Requires-Dist: tomli<3,>=2.0.1; python_version < "3.11"
27
27
  Requires-Dist: coverage<8,>=7.5.1
@@ -0,0 +1 @@
1
+ __version__ = "0.12.0"
@@ -8,7 +8,7 @@ import subprocess # nosec:B404
8
8
  import sys
9
9
  from functools import cached_property
10
10
  from pathlib import Path
11
- from typing import Literal, Optional, Type, get_args
11
+ from typing import Literal, Optional, get_args
12
12
 
13
13
  import emoji
14
14
  import typer
@@ -358,6 +358,10 @@ class EnvError(Exception):
358
358
  class Project:
359
359
  path_depth = 5
360
360
 
361
+ @staticmethod
362
+ def is_poetry_v2(text: str) -> bool:
363
+ return 'build-backend = "poetry' in text
364
+
361
365
  @staticmethod
362
366
  def work_dir(name: str, parent: Path, depth: int, be_file=False) -> Path | None:
363
367
  for _ in range(depth):
@@ -370,7 +374,7 @@ class Project:
370
374
 
371
375
  @classmethod
372
376
  def get_work_dir(
373
- cls: Type[Self],
377
+ cls: type[Self],
374
378
  name=TOML_FILE,
375
379
  cwd: Path | None = None,
376
380
  allow_cwd=False,
@@ -384,16 +388,16 @@ class Project:
384
388
  raise EnvError(f"{name} not found! Make sure this is a poetry project.")
385
389
 
386
390
  @classmethod
387
- def load_toml_text(cls: Type[Self], name=TOML_FILE) -> str:
391
+ def load_toml_text(cls: type[Self], name=TOML_FILE) -> str:
388
392
  toml_file = cls.get_work_dir(name, be_file=True)
389
393
  return toml_file.read_text("utf8")
390
394
 
391
395
  @classmethod
392
- def manage_by_poetry(cls: Type[Self]) -> bool:
396
+ def manage_by_poetry(cls: type[Self]) -> bool:
393
397
  return cls.get_manage_tool() == "poetry"
394
398
 
395
399
  @classmethod
396
- def get_manage_tool(cls: Type[Self]) -> ToolName | None:
400
+ def get_manage_tool(cls: type[Self]) -> ToolName | None:
397
401
  try:
398
402
  text = cls.load_toml_text()
399
403
  except EnvError:
@@ -402,8 +406,8 @@ class Project:
402
406
  for name in get_args(ToolName):
403
407
  if f"[tool.{name}]" in text:
404
408
  return name
405
- if 'build-backend = "poetry.core.masonry.api"' in text:
406
- # Poetry 2.0 default to not include the '[tool.poetry]' section
409
+ # Poetry 2.0 default to not include the '[tool.poetry]' section
410
+ if cls.is_poetry_v2(text):
407
411
  return "poetry"
408
412
  return None
409
413
 
@@ -412,7 +416,7 @@ class Project:
412
416
  return Path(sys.executable).parent
413
417
 
414
418
  @classmethod
415
- def get_root_dir(cls: Type[Self], cwd: Path | None = None) -> Path:
419
+ def get_root_dir(cls: type[Self], cwd: Path | None = None) -> Path:
416
420
  root = cwd or Path.cwd()
417
421
  venv_parent = cls.python_exec_dir().parent.parent
418
422
  if root.is_relative_to(venv_parent):
@@ -423,7 +427,7 @@ class Project:
423
427
  class ParseError(Exception):
424
428
  """Raise this if parse dependence line error"""
425
429
 
426
- ...
430
+ pass
427
431
 
428
432
 
429
433
  class UpgradeDependencies(Project, DryRun):
@@ -474,7 +478,7 @@ class UpgradeDependencies(Project, DryRun):
474
478
 
475
479
  @classmethod
476
480
  def build_args(
477
- cls: Type[Self], package_lines: list[str]
481
+ cls: type[Self], package_lines: list[str]
478
482
  ) -> tuple[list[str], dict[str, list[str]]]:
479
483
  args: list[str] = [] # ['typer[all]', 'fastapi']
480
484
  specials: dict[str, list[str]] = {} # {'--platform linux': ['gunicorn']}
@@ -513,7 +517,7 @@ class UpgradeDependencies(Project, DryRun):
513
517
  return args, specials
514
518
 
515
519
  @classmethod
516
- def should_with_dev(cls: Type[Self]) -> bool:
520
+ def should_with_dev(cls: type[Self]) -> bool:
517
521
  text = cls.load_toml_text()
518
522
  return cls.DevFlag.new in text or cls.DevFlag.old in text
519
523
 
@@ -530,12 +534,14 @@ class UpgradeDependencies(Project, DryRun):
530
534
 
531
535
  @classmethod
532
536
  def get_args(
533
- cls: Type[Self], toml_text: str | None = None
537
+ cls: type[Self], toml_text: str | None = None
534
538
  ) -> tuple[list[str], list[str], list[list[str]], str]:
535
539
  if toml_text is None:
536
540
  toml_text = cls.load_toml_text()
537
541
  main_title = "[tool.poetry.dependencies]"
538
- if main_title not in toml_text:
542
+ if (no_main_deps := main_title not in toml_text) and not cls.is_poetry_v2(
543
+ toml_text
544
+ ):
539
545
  raise EnvError(
540
546
  f"{main_title} not found! Make sure this is a poetry project."
541
547
  )
@@ -551,7 +557,8 @@ class UpgradeDependencies(Project, DryRun):
551
557
  except ValueError:
552
558
  dev_toml = ""
553
559
  main_toml = text
554
- mains, devs = cls.parse_item(main_toml), cls.parse_item(dev_toml)
560
+ mains = [] if no_main_deps else cls.parse_item(main_toml)
561
+ devs = cls.parse_item(dev_toml)
555
562
  prod_packs, specials = cls.build_args(mains)
556
563
  if specials:
557
564
  others.extend([[k] + v for k, v in specials.items()])
@@ -561,7 +568,7 @@ class UpgradeDependencies(Project, DryRun):
561
568
  return prod_packs, dev_packs, others, dev_flag
562
569
 
563
570
  @classmethod
564
- def gen_cmd(cls: Type[Self]) -> str:
571
+ def gen_cmd(cls: type[Self]) -> str:
565
572
  main_args, dev_args, others, dev_flags = cls.get_args()
566
573
  return cls.to_cmd(main_args, dev_args, others, dev_flags)
567
574
 
@@ -593,7 +600,12 @@ def upgrade(
593
600
  dry: bool = Option(False, "--dry", help="Only print, not really run shell command"),
594
601
  ) -> None:
595
602
  """Upgrade dependencies in pyproject.toml to latest versions"""
596
- UpgradeDependencies(dry=dry).run()
603
+ if (tool := Project.get_manage_tool()) == "uv":
604
+ exit_if_run_failed("uv lock --upgrade && uv sync", dry=dry)
605
+ elif tool == "pdm":
606
+ exit_if_run_failed("pdm update && pdm install", dry=dry)
607
+ else:
608
+ UpgradeDependencies(dry=dry).run()
597
609
 
598
610
 
599
611
  class GitTag(DryRun):
@@ -684,7 +696,7 @@ class LintCode(DryRun):
684
696
 
685
697
  @classmethod
686
698
  def to_cmd(
687
- cls: Type[Self], paths=".", check_only=False, bandit=False, skip_mypy=False
699
+ cls: type[Self], paths=".", check_only=False, bandit=False, skip_mypy=False
688
700
  ) -> str:
689
701
  cmd = ""
690
702
  tools = ["ruff format", "ruff check --extend-select=I,B,SIM --fix", "mypy"]
@@ -697,7 +709,9 @@ class LintCode(DryRun):
697
709
  tools = tools[:-1]
698
710
  elif load_bool("IGNORE_MISSING_IMPORTS"):
699
711
  tools[-1] += " --ignore-missing-imports"
700
- lint_them = " && ".join("{0}{%d} {1}" % i for i in range(2, len(tools) + 2))
712
+ lint_them = " && ".join(
713
+ "{0}{" + str(i) + "} {1}" for i in range(2, len(tools) + 2)
714
+ )
701
715
  prefix = ""
702
716
  should_run_by_tool = False
703
717
  if is_venv():
@@ -803,7 +817,9 @@ class Sync(DryRun):
803
817
  export_cmd += f" --{extras=}".replace("'", '"')
804
818
  elif check_call(prefix + "python -m pip --version"):
805
819
  ensurepip = ""
806
- install_cmd = "{2} -o {0} &&%s {1}python -m pip install -r {0}" % ensurepip
820
+ install_cmd = (
821
+ f"{{2}} -o {{0}} &&{ensurepip} {{1}}python -m pip install -r {{0}}"
822
+ )
807
823
  if should_remove and not save:
808
824
  install_cmd += " && rm -f {0}"
809
825
  return install_cmd.format(self.filename, prefix, export_cmd)
@@ -12,7 +12,7 @@ authors = [
12
12
  { name = "Waket Zheng", email = "waketzheng@gmail.com>" },
13
13
  ]
14
14
  readme = "README.md"
15
- requires-python = ">=3.9,<4"
15
+ requires-python = ">=3.9"
16
16
  classifiers = [
17
17
  "Development Status :: 4 - Beta",
18
18
  "Intended Audience :: Developers",
@@ -32,7 +32,7 @@ classifiers = [
32
32
  "License :: OSI Approved :: MIT License",
33
33
  ]
34
34
  dependencies = [
35
- "typer>=0.12.3,<0.16",
35
+ "typer>=0.12.3,<1",
36
36
  "emoji >=2.12.1,<3",
37
37
  "tomli>=2.0.1,<3; python_version < '3.11'",
38
38
  "coverage >=7.5.1,<8",
@@ -42,7 +42,7 @@ dependencies = [
42
42
  "pytest >=8.2.0,<9",
43
43
  "packaging>=20.5",
44
44
  ]
45
- version = "0.11.6"
45
+ version = "0.12.0"
46
46
 
47
47
  [project.urls]
48
48
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -141,9 +141,17 @@ extend-select = [
141
141
  "I",
142
142
  "B",
143
143
  "C4",
144
+ "UP",
144
145
  ]
145
146
 
146
147
  [tool.ruff.lint.per-file-ignores]
147
148
  "test_*.py" = [
148
149
  "E501",
149
150
  ]
151
+ "scripts/*.py" = [
152
+ "UP009",
153
+ "UP032",
154
+ ]
155
+ "fast_dev_cli/cli.py" = [
156
+ "UP007",
157
+ ]
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  import pathlib
3
- from typing import Generator
3
+ from collections.abc import Generator
4
4
 
5
5
  import pytest
6
6
  from pytest_mock import MockerFixture
@@ -1,9 +1,9 @@
1
1
  import os
2
2
  import shutil
3
3
  import sys
4
+ from collections.abc import Generator
4
5
  from contextlib import contextmanager
5
6
  from pathlib import Path
6
- from typing import Generator
7
7
 
8
8
  import pytest
9
9
 
@@ -38,11 +38,11 @@ def _prepare_package(
38
38
  init_file = package_path / package_name / "__init__.py"
39
39
  a, b = 'version = "0.1.0"', f'version = "{mark}"'
40
40
  if define_include:
41
- b += '\npackages = [{include = "%s"}]' % package_name
41
+ b += f'\npackages = [{{include = "{package_name}"}}]'
42
42
  with chdir(package_path.parent):
43
43
  run_and_echo(f'poetry new "{package_path.name}"')
44
44
  toml_file.unlink()
45
- py_version = "{0}.{1}".format(*sys.version_info)
45
+ py_version = "{}.{}".format(*sys.version_info)
46
46
  with chdir(package_path):
47
47
  run_and_echo(f'poetry init --python="^{py_version}" --no-interaction')
48
48
  text = toml_file.read_text().replace(a, b)
@@ -1 +0,0 @@
1
- __version__ = "0.11.6"
File without changes
File without changes