fast-dev-cli 0.19.9__tar.gz → 0.20.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 (35) hide show
  1. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/PKG-INFO +1 -3
  2. fast_dev_cli-0.20.0/fast_dev_cli/__init__.py +1 -0
  3. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/fast_dev_cli/cli.py +31 -6
  4. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/pyproject.toml +2 -3
  5. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/scripts/check.py +1 -1
  6. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_pypi.py +29 -1
  7. fast_dev_cli-0.19.9/fast_dev_cli/__init__.py +0 -1
  8. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/LICENSE +0 -0
  9. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/README.md +0 -0
  10. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/fast_dev_cli/__main__.py +0 -0
  11. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/fast_dev_cli/py.typed +0 -0
  12. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/pdm_build.py +0 -0
  13. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/scripts/deps.py +0 -0
  14. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/scripts/format.py +0 -0
  15. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/scripts/test.py +0 -0
  16. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/__init__.py +0 -0
  17. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/assets/uv-tx.lock +0 -0
  18. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/assets/uv-upload-time.lock +0 -0
  19. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/assets/uv.lock +0 -0
  20. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/conftest.py +0 -0
  21. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_bump.py +0 -0
  22. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_deps.py +0 -0
  23. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_exec.py +0 -0
  24. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_fast_test.py +0 -0
  25. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_functions.py +0 -0
  26. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_help.py +0 -0
  27. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_lint.py +0 -0
  28. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_poetry_version_plugin.py +0 -0
  29. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_runserver.py +0 -0
  30. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_sync.py +0 -0
  31. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_tag.py +0 -0
  32. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_upgrade.py +0 -0
  33. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_upload.py +0 -0
  34. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.0}/tests/test_version.py +0 -0
  35. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.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.19.9
3
+ Version: 0.20.0
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -26,8 +26,6 @@ Requires-Dist: tomli<3,>=2.0.1; python_version < "3.11"
26
26
  Requires-Dist: emoji>=2.12.1
27
27
  Requires-Dist: packaging>=20.5
28
28
  Requires-Dist: coverage>=7.5.1
29
- Requires-Dist: mypy>=1.15.0
30
- Requires-Dist: bumpversion2>=1.4.3
31
29
  Requires-Dist: pytest>=8.2.0
32
30
  Provides-Extra: include-optional-dependencies
33
31
  Requires-Dist: all; extra == "include-optional-dependencies"
@@ -0,0 +1 @@
1
+ __version__ = "0.20.0"
@@ -1642,18 +1642,25 @@ class UvPypi(DryRun):
1642
1642
  HOST = "https://files.pythonhosted.org"
1643
1643
 
1644
1644
  def __init__(
1645
- self, lock_file: Path, dry: bool, verbose: bool, quiet: bool, slim: bool = False
1645
+ self,
1646
+ lock_file: Path,
1647
+ dry: bool,
1648
+ verbose: bool,
1649
+ quiet: bool,
1650
+ slim: bool = False,
1651
+ reverse: bool = False,
1646
1652
  ) -> None:
1647
1653
  super().__init__(dry=dry)
1648
1654
  self.lock_file = lock_file
1649
1655
  self._verbose = _ensure_bool(verbose)
1650
1656
  self._quiet = _ensure_bool(quiet)
1651
1657
  self._slim = _ensure_bool(slim)
1658
+ self._reverse = _ensure_bool(reverse)
1652
1659
 
1653
1660
  def run(self) -> None:
1654
1661
  try:
1655
1662
  rc = self.update_lock(
1656
- self.lock_file, self._verbose, self._quiet, self._slim
1663
+ self.lock_file, self._verbose, self._quiet, self._slim, self._reverse
1657
1664
  )
1658
1665
  except ValueError as e:
1659
1666
  secho(str(e), fg=typer.colors.RED)
@@ -1712,16 +1719,33 @@ class UvPypi(DryRun):
1712
1719
 
1713
1720
  @classmethod
1714
1721
  def update_lock(
1715
- cls, p: Path, verbose: bool, quiet: bool, slim: bool = False
1722
+ cls,
1723
+ p: Path,
1724
+ verbose: bool,
1725
+ quiet: bool,
1726
+ slim: bool = False,
1727
+ reverse: bool = False,
1716
1728
  ) -> int:
1717
1729
  text = p.read_text("utf-8")
1718
- new_text = cls.get_target_content(text, verbose, cls.PYPI, cls.HOST)
1730
+ target_register, target_host = cls.PYPI, cls.HOST
1731
+ if reverse:
1732
+ target_register, target_host = cls.get_register_from_uv_config()
1733
+ new_text = cls.get_target_content(text, verbose, target_register, target_host)
1719
1734
  if new_text is None:
1720
1735
  if verbose:
1721
- echo(f"Registry of {p} is {cls.PYPI}, no need to change.")
1736
+ echo(f"Registry of {p} is {target_register}, no need to change.")
1722
1737
  return 0
1723
1738
  return cls.slim_and_write(new_text, slim, p, verbose, quiet)
1724
1739
 
1740
+ @staticmethod
1741
+ def get_register_from_uv_config() -> tuple[str, str]:
1742
+ config_dir = "AppData/Roaming" if is_windows() else ".config"
1743
+ config_file = Path.home() / config_dir / "uv/uv.toml"
1744
+ text = config_file.read_text("utf-8")
1745
+ doc = tomllib.loads(text)
1746
+ index_url = doc["index"][0]["url"]
1747
+ return index_url, index_url.replace("/simple", "").rstrip("/")
1748
+
1725
1749
  @staticmethod
1726
1750
  def slim_and_write(
1727
1751
  text: str, slim: bool, p: Path, verbose: bool, quiet: bool
@@ -1744,6 +1768,7 @@ def pypi(
1744
1768
  verbose: bool = False,
1745
1769
  quiet: bool = False,
1746
1770
  slim: bool = False,
1771
+ reverse: bool = False,
1747
1772
  ) -> None:
1748
1773
  """Change registry of uv.lock to be pypi.org"""
1749
1774
  if not (p := Path(_ensure_str(file) or "uv.lock")).exists() and not (
@@ -1751,7 +1776,7 @@ def pypi(
1751
1776
  ):
1752
1777
  yellow_warn(f"{p.name!r} not found!")
1753
1778
  return
1754
- UvPypi(p, dry, verbose, quiet, slim).run()
1779
+ UvPypi(p, dry, verbose, quiet, slim, reverse).run()
1755
1780
 
1756
1781
 
1757
1782
  def version_callback(value: bool) -> None:
@@ -37,11 +37,9 @@ dependencies = [
37
37
  "emoji >=2.12.1",
38
38
  "packaging >=20.5",
39
39
  "coverage >=7.5.1",
40
- "mypy >=1.15.0",
41
- "bumpversion2 >=1.4.3",
42
40
  "pytest >=8.2.0",
43
41
  ]
44
- version = "0.19.9"
42
+ version = "0.20.0"
45
43
 
46
44
  [project.urls]
47
45
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -168,6 +166,7 @@ exclude = [
168
166
 
169
167
  [tool.ty.rules]
170
168
  unresolved-import = "ignore"
169
+ unused-ignore-comment = "ignore"
171
170
 
172
171
  [tool.ty.environment]
173
172
  python-version = "3.10"
@@ -23,7 +23,7 @@ if run_and_echo("fast check --skip-mypy", verbose=False) != 0:
23
23
  print("\033[1m Please run './scripts/format.py' to auto-fix style issues \033[0m")
24
24
  sys.exit(1)
25
25
  package_name = os.path.basename(work_dir).replace("-", "_").replace(" ", "_")
26
- if run_and_echo("mypy {} {}".format(package_name, "tests")) != 0:
26
+ if run_and_echo("ty check {} {}".format(package_name, "tests")) != 0:
27
27
  sys.exit(1)
28
28
  if run_and_echo("bandit -r {}".format(package_name)) != 0:
29
29
  sys.exit(1)
@@ -3,7 +3,7 @@ from pathlib import Path
3
3
 
4
4
  import pytest
5
5
 
6
- from fast_dev_cli.cli import Exit, pypi
6
+ from fast_dev_cli.cli import Exit, UvPypi, pypi, run_and_echo
7
7
 
8
8
  ASSERTS_DIR = Path(__file__).parent / "assets"
9
9
 
@@ -72,6 +72,7 @@ def test_pypi_slim(tmp_work_dir, capsys):
72
72
  assert "aliyun" not in new_text and "pypi.org" in new_text
73
73
  assert "upload-time" in new_text
74
74
  pypi(slim=True, verbose=True)
75
+ new_text = lock_file.read_text("utf-8")
75
76
  assert "upload-time" in new_text
76
77
  assert "no need to change" in capsys.readouterr().out
77
78
  shutil.copy(origin_lock, lock_file)
@@ -79,3 +80,30 @@ def test_pypi_slim(tmp_work_dir, capsys):
79
80
  new_text = lock_file.read_text("utf-8")
80
81
  assert "pypi.org" in new_text
81
82
  assert "upload-time" not in new_text
83
+
84
+
85
+ def test_pypi_reverse(tmp_work_dir):
86
+ origin_lock = ASSERTS_DIR / "uv-upload-time.lock"
87
+ lock_file = Path("uv.lock")
88
+ Path("pyproject.toml").touch()
89
+ shutil.copy(origin_lock, lock_file)
90
+ text = origin_lock.read_text("utf-8")
91
+ pypi(quiet=True)
92
+ new_text = lock_file.read_text("utf-8")
93
+ assert new_text != text
94
+ assert "aliyun" in text and "pypi.org" not in text
95
+ assert "aliyun" not in new_text and "pypi.org" in new_text
96
+ assert "upload-time" in new_text
97
+ try:
98
+ pypi(reverse=True, verbose=True, quiet=True)
99
+ except FileNotFoundError:
100
+ run_and_echo("uvx pip-conf-mirror --uv aliyun")
101
+ pypi(reverse=True, verbose=True, quiet=True)
102
+ new_text = lock_file.read_text("utf-8")
103
+ assert "aliyun" in new_text and "pypi.org" not in new_text
104
+ else:
105
+ new_text = lock_file.read_text("utf-8")
106
+ assert "pypi.org" not in new_text
107
+ register_url = UvPypi.get_register_from_uv_config()[0]
108
+ assert register_url in new_text
109
+ assert "upload-time" in new_text
@@ -1 +0,0 @@
1
- __version__ = "0.19.9"
File without changes
File without changes