fast-dev-cli 0.19.9__tar.gz → 0.20.1__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.1}/PKG-INFO +2 -4
  2. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/README.md +1 -1
  3. fast_dev_cli-0.20.1/fast_dev_cli/__init__.py +1 -0
  4. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/fast_dev_cli/cli.py +42 -6
  5. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/pyproject.toml +2 -3
  6. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/scripts/check.py +1 -1
  7. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_pypi.py +38 -1
  8. fast_dev_cli-0.19.9/fast_dev_cli/__init__.py +0 -1
  9. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/LICENSE +0 -0
  10. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/fast_dev_cli/__main__.py +0 -0
  11. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/fast_dev_cli/py.typed +0 -0
  12. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/pdm_build.py +0 -0
  13. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/scripts/deps.py +0 -0
  14. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/scripts/format.py +0 -0
  15. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/scripts/test.py +0 -0
  16. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/__init__.py +0 -0
  17. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/assets/uv-tx.lock +0 -0
  18. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/assets/uv-upload-time.lock +0 -0
  19. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/assets/uv.lock +0 -0
  20. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/conftest.py +0 -0
  21. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_bump.py +0 -0
  22. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_deps.py +0 -0
  23. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_exec.py +0 -0
  24. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_fast_test.py +0 -0
  25. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_functions.py +0 -0
  26. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_help.py +0 -0
  27. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_lint.py +0 -0
  28. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_poetry_version_plugin.py +0 -0
  29. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_runserver.py +0 -0
  30. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_sync.py +0 -0
  31. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_tag.py +0 -0
  32. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_upgrade.py +0 -0
  33. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_upload.py +0 -0
  34. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/tests/test_version.py +0 -0
  35. {fast_dev_cli-0.19.9 → fast_dev_cli-0.20.1}/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.1
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"
@@ -102,7 +100,7 @@ uv tool install --python 3.14 fastdevcli-slim
102
100
  ```bash
103
101
  pip install fast-dev-cli
104
102
  ```
105
- *Will install: fast-dev-cli emoji typer-slim mypy bumpversion2 pytest coverage*
103
+ *Will install: fast-dev-cli emoji typer-slim pytest coverage*
106
104
 
107
105
  </div>
108
106
 
@@ -67,7 +67,7 @@ uv tool install --python 3.14 fastdevcli-slim
67
67
  ```bash
68
68
  pip install fast-dev-cli
69
69
  ```
70
- *Will install: fast-dev-cli emoji typer-slim mypy bumpversion2 pytest coverage*
70
+ *Will install: fast-dev-cli emoji typer-slim pytest coverage*
71
71
 
72
72
  </div>
73
73
 
@@ -0,0 +1 @@
1
+ __version__ = "0.20.1"
@@ -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,44 @@ 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
+ try:
1733
+ target_register, target_host = cls.get_register_from_uv_config()
1734
+ except FileNotFoundError:
1735
+ if verbose:
1736
+ echo("Skip register reverse as global uv config file not found.")
1737
+ if quiet:
1738
+ return 0
1739
+ return 1
1740
+ new_text = cls.get_target_content(text, verbose, target_register, target_host)
1719
1741
  if new_text is None:
1720
1742
  if verbose:
1721
- echo(f"Registry of {p} is {cls.PYPI}, no need to change.")
1743
+ echo(f"Registry of {p} is {target_register}, no need to change.")
1722
1744
  return 0
1723
1745
  return cls.slim_and_write(new_text, slim, p, verbose, quiet)
1724
1746
 
1747
+ @classmethod
1748
+ def get_register_from_uv_config(cls) -> tuple[str, str]:
1749
+ config_file = cls.get_uv_config_file()
1750
+ text = config_file.read_text("utf-8")
1751
+ doc = tomllib.loads(text)
1752
+ index_url = doc["index"][0]["url"]
1753
+ return index_url, index_url.replace("/simple", "").rstrip("/")
1754
+
1755
+ @staticmethod
1756
+ def get_uv_config_file() -> Path:
1757
+ config_dir = "AppData/Roaming" if is_windows() else ".config"
1758
+ return Path.home() / config_dir / "uv/uv.toml"
1759
+
1725
1760
  @staticmethod
1726
1761
  def slim_and_write(
1727
1762
  text: str, slim: bool, p: Path, verbose: bool, quiet: bool
@@ -1744,6 +1779,7 @@ def pypi(
1744
1779
  verbose: bool = False,
1745
1780
  quiet: bool = False,
1746
1781
  slim: bool = False,
1782
+ reverse: bool = False,
1747
1783
  ) -> None:
1748
1784
  """Change registry of uv.lock to be pypi.org"""
1749
1785
  if not (p := Path(_ensure_str(file) or "uv.lock")).exists() and not (
@@ -1751,7 +1787,7 @@ def pypi(
1751
1787
  ):
1752
1788
  yellow_warn(f"{p.name!r} not found!")
1753
1789
  return
1754
- UvPypi(p, dry, verbose, quiet, slim).run()
1790
+ UvPypi(p, dry, verbose, quiet, slim, reverse).run()
1755
1791
 
1756
1792
 
1757
1793
  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.1"
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,39 @@ 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, mocker, capsys):
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
+ if not UvPypi.get_uv_config_file().exists():
98
+ run_and_echo("uvx pip-conf-mirror --uv aliyun")
99
+ pypi(reverse=True, verbose=True, quiet=True)
100
+ new_text = lock_file.read_text("utf-8")
101
+ assert "aliyun" in new_text and "pypi.org" not in new_text
102
+ else:
103
+ pypi(reverse=True, verbose=True, quiet=True)
104
+ new_text = lock_file.read_text("utf-8")
105
+ assert "pypi.org" not in new_text
106
+ register_url = UvPypi.get_register_from_uv_config()[0]
107
+ assert register_url in new_text
108
+ assert "upload-time" in new_text
109
+ # Check output for uv config file not exist case
110
+ mocker.patch(
111
+ "fast_dev_cli.cli.UvPypi.get_uv_config_file",
112
+ return_value=Path("not-exist-file"),
113
+ )
114
+ pypi(reverse=True, verbose=True, quiet=True)
115
+ assert (
116
+ "Skip register reverse as global uv config file not found."
117
+ in capsys.readouterr().out
118
+ )
@@ -1 +0,0 @@
1
- __version__ = "0.19.9"
File without changes