fast-dev-cli 0.19.8__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.8 → fast_dev_cli-0.20.0}/PKG-INFO +20 -11
  2. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/README.md +19 -8
  3. fast_dev_cli-0.20.0/fast_dev_cli/__init__.py +1 -0
  4. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/fast_dev_cli/cli.py +33 -8
  5. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/pyproject.toml +2 -3
  6. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/scripts/check.py +1 -1
  7. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_pypi.py +29 -1
  8. fast_dev_cli-0.19.8/fast_dev_cli/__init__.py +0 -1
  9. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/LICENSE +0 -0
  10. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/fast_dev_cli/__main__.py +0 -0
  11. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/fast_dev_cli/py.typed +0 -0
  12. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/pdm_build.py +0 -0
  13. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/scripts/deps.py +0 -0
  14. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/scripts/format.py +0 -0
  15. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/scripts/test.py +0 -0
  16. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/__init__.py +0 -0
  17. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/assets/uv-tx.lock +0 -0
  18. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/assets/uv-upload-time.lock +0 -0
  19. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/assets/uv.lock +0 -0
  20. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/conftest.py +0 -0
  21. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_bump.py +0 -0
  22. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_deps.py +0 -0
  23. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_exec.py +0 -0
  24. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_fast_test.py +0 -0
  25. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_functions.py +0 -0
  26. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_help.py +0 -0
  27. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_lint.py +0 -0
  28. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_poetry_version_plugin.py +0 -0
  29. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_runserver.py +0 -0
  30. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_sync.py +0 -0
  31. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_tag.py +0 -0
  32. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_upgrade.py +0 -0
  33. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_upload.py +0 -0
  34. {fast_dev_cli-0.19.8 → fast_dev_cli-0.20.0}/tests/test_version.py +0 -0
  35. {fast_dev_cli-0.19.8 → 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.8
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"
@@ -78,11 +76,25 @@ Python 3.10+
78
76
 
79
77
  ## Features
80
78
 
81
- - Support poetry/pdm/uv
82
- - Support Windows/MacOS/Linux
79
+ - Support uv/pd/mpoetry
80
+ - Support MacOS/Linux/Windows
83
81
 
84
82
  ## Installation
85
83
 
84
+ - Global install
85
+
86
+ <div class="termy">
87
+
88
+ ```bash
89
+ uv tool install --python 3.14 fastdevcli-slim
90
+ # Or: pipx install fastdevcli-slim
91
+ ```
92
+ *Will create a `fast` command in ~/.local/bin
93
+
94
+ - Install in project
95
+
96
+ </div>
97
+
86
98
  <div class="termy">
87
99
 
88
100
  ```bash
@@ -133,11 +145,8 @@ fast pypi
133
145
  uvx --from fastdevcli-slim fast
134
146
  ```
135
147
 
136
- ## Install global
137
- ```bash
138
- pipx install fastdevcli-slim
139
- ```
140
- Or:
148
+ ## Lint/Check by ty instead of mypy
141
149
  ```bash
142
- uv tool install fastdevcli-slim
150
+ fast lint --ty
151
+ fast check --ty
143
152
  ```
@@ -43,11 +43,25 @@ Python 3.10+
43
43
 
44
44
  ## Features
45
45
 
46
- - Support poetry/pdm/uv
47
- - Support Windows/MacOS/Linux
46
+ - Support uv/pd/mpoetry
47
+ - Support MacOS/Linux/Windows
48
48
 
49
49
  ## Installation
50
50
 
51
+ - Global install
52
+
53
+ <div class="termy">
54
+
55
+ ```bash
56
+ uv tool install --python 3.14 fastdevcli-slim
57
+ # Or: pipx install fastdevcli-slim
58
+ ```
59
+ *Will create a `fast` command in ~/.local/bin
60
+
61
+ - Install in project
62
+
63
+ </div>
64
+
51
65
  <div class="termy">
52
66
 
53
67
  ```bash
@@ -98,11 +112,8 @@ fast pypi
98
112
  uvx --from fastdevcli-slim fast
99
113
  ```
100
114
 
101
- ## Install global
102
- ```bash
103
- pipx install fastdevcli-slim
104
- ```
105
- Or:
115
+ ## Lint/Check by ty instead of mypy
106
116
  ```bash
107
- uv tool install fastdevcli-slim
117
+ fast lint --ty
118
+ fast check --ty
108
119
  ```
@@ -0,0 +1 @@
1
+ __version__ = "0.20.0"
@@ -1163,7 +1163,7 @@ class LintCode(DryRun):
1163
1163
  )
1164
1164
  prefix = ""
1165
1165
  should_run_by_tool = with_prefix
1166
- if not should_run_by_tool:
1166
+ if not should_run_by_tool and "mypy" in str(tools):
1167
1167
  if is_venv() and Path(sys.argv[0]).parent != Path.home().joinpath(
1168
1168
  ".local/bin"
1169
1169
  ): # Virtual environment activated and fast-dev-cli is installed in it
@@ -1177,7 +1177,7 @@ class LintCode(DryRun):
1177
1177
  "You may need to run the following command"
1178
1178
  f" to install ruff:\n\n {command}\n"
1179
1179
  )
1180
- elif "mypy" in str(tools) and cls.missing_mypy_exec():
1180
+ elif cls.missing_mypy_exec():
1181
1181
  should_run_by_tool = True
1182
1182
  if check_call('python -c "import fast_dev_cli"'):
1183
1183
  command = 'python -m pip install -U "fast-dev-cli"'
@@ -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.8"
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.8"
File without changes