copier-python 0.9.0__tar.gz → 0.11.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 (54) hide show
  1. {copier_python-0.9.0 → copier_python-0.11.0}/PKG-INFO +3 -1
  2. {copier_python-0.9.0 → copier_python-0.11.0}/copier_python/repo.py +6 -1
  3. {copier_python-0.9.0 → copier_python-0.11.0}/pyproject.toml +2 -0
  4. {copier_python-0.9.0 → copier_python-0.11.0}/tests/test_update.py +32 -38
  5. {copier_python-0.9.0 → copier_python-0.11.0}/.gitignore +0 -0
  6. {copier_python-0.9.0 → copier_python-0.11.0}/AGENTS.md +0 -0
  7. {copier_python-0.9.0 → copier_python-0.11.0}/CONTRIBUTING.md +0 -0
  8. {copier_python-0.9.0 → copier_python-0.11.0}/LICENSE +0 -0
  9. {copier_python-0.9.0 → copier_python-0.11.0}/README.md +0 -0
  10. {copier_python-0.9.0 → copier_python-0.11.0}/copier_python/__init__.py +0 -0
  11. {copier_python-0.9.0 → copier_python-0.11.0}/copier_python/__main__.py +0 -0
  12. {copier_python-0.9.0 → copier_python-0.11.0}/copier_python/py.typed +0 -0
  13. {copier_python-0.9.0 → copier_python-0.11.0}/copier_python/update.py +0 -0
  14. {copier_python-0.9.0 → copier_python-0.11.0}/docs/contributing.md +0 -0
  15. {copier_python-0.9.0 → copier_python-0.11.0}/docs/development/requirements.md +0 -0
  16. {copier_python-0.9.0 → copier_python-0.11.0}/docs/development/updates.md +0 -0
  17. {copier_python-0.9.0 → copier_python-0.11.0}/docs/development/workflow.md +0 -0
  18. {copier_python-0.9.0 → copier_python-0.11.0}/docs/index.md +0 -0
  19. {copier_python-0.9.0 → copier_python-0.11.0}/docs/license.md +0 -0
  20. {copier_python-0.9.0 → copier_python-0.11.0}/docs/project-creation.md +0 -0
  21. {copier_python-0.9.0 → copier_python-0.11.0}/docs/project-development.md +0 -0
  22. {copier_python-0.9.0 → copier_python-0.11.0}/docs/project-release.md +0 -0
  23. {copier_python-0.9.0 → copier_python-0.11.0}/docs/project-setup.md +0 -0
  24. {copier_python-0.9.0 → copier_python-0.11.0}/docs/project-updates.md +0 -0
  25. {copier_python-0.9.0 → copier_python-0.11.0}/docs/releasing.md +0 -0
  26. {copier_python-0.9.0 → copier_python-0.11.0}/docs/requirements.md +0 -0
  27. {copier_python-0.9.0 → copier_python-0.11.0}/docs/setup.md +0 -0
  28. {copier_python-0.9.0 → copier_python-0.11.0}/tests/__init__.py +0 -0
  29. {copier_python-0.9.0 → copier_python-0.11.0}/tests/conftest.py +0 -0
  30. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__init__.py +0 -0
  31. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_agents.ambr +0 -0
  32. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_compose.ambr +0 -0
  33. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_contributing.ambr +0 -0
  34. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_dockerfile.ambr +0 -0
  35. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_docs.ambr +0 -0
  36. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_license.ambr +0 -0
  37. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_pyproject.ambr +0 -0
  38. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_readme.ambr +0 -0
  39. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_workflows.ambr +0 -0
  40. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/__snapshots__/test_zensical.ambr +0 -0
  41. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_agents.py +0 -0
  42. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_compose.py +0 -0
  43. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_contributing.py +0 -0
  44. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_dockerfile.py +0 -0
  45. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_docs.py +0 -0
  46. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_license.py +0 -0
  47. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_pyproject.py +0 -0
  48. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_readme.py +0 -0
  49. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_structure.py +0 -0
  50. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_template.py +0 -0
  51. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_version.py +0 -0
  52. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_workflows.py +0 -0
  53. {copier_python-0.9.0 → copier_python-0.11.0}/tests/template/test_zensical.py +0 -0
  54. {copier_python-0.9.0 → copier_python-0.11.0}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: copier-python
3
- Version: 0.9.0
3
+ Version: 0.11.0
4
4
  Summary: Copier template for Python projects with modern tooling
5
5
  Project-URL: Homepage, https://smkent.github.io/copier-python
6
6
  Project-URL: Repository, https://github.com/smkent/copier-python
@@ -23,7 +23,9 @@ Classifier: Topic :: Utilities
23
23
  Classifier: Typing :: Typed
24
24
  Requires-Python: >=3.10
25
25
  Requires-Dist: pyyaml>=6
26
+ Requires-Dist: rich>=15
26
27
  Requires-Dist: typer>=0.9
28
+ Requires-Dist: typing-extensions>=4.1; python_version < '3.12'
27
29
  Description-Content-Type: text/markdown
28
30
 
29
31
  # copier-python
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import os
4
4
  import re
5
5
  import subprocess
6
+ import sys
6
7
  import tempfile
7
8
  from contextlib import contextmanager, suppress
8
9
  from dataclasses import InitVar, dataclass, field
@@ -14,7 +15,11 @@ import yaml
14
15
  from rich import print # noqa: A004
15
16
  from rich.panel import Panel
16
17
  from rich.text import Text
17
- from typing_extensions import Self
18
+
19
+ if sys.version_info >= (3, 11):
20
+ from typing import Self
21
+ else:
22
+ from typing_extensions import Self
18
23
 
19
24
  if TYPE_CHECKING:
20
25
  from collections.abc import Generator, Sequence
@@ -31,7 +31,9 @@ classifiers = [
31
31
  keywords = []
32
32
  dependencies = [
33
33
  "pyyaml>=6",
34
+ "rich>=15",
34
35
  "typer>=0.9",
36
+ "typing_extensions>=4.1; python_version < '3.12'",
35
37
  ]
36
38
 
37
39
  [project.scripts]
@@ -26,6 +26,7 @@ if TYPE_CHECKING:
26
26
 
27
27
 
28
28
  DEFAULT_BRANCH_NAME = "fhqwhgads"
29
+ DEFAULT_END_REF = "v0.8.0"
29
30
 
30
31
 
31
32
  @pytest.fixture(params=["v0.6.0"])
@@ -33,7 +34,7 @@ def start_ref(request: pytest.FixtureRequest) -> str:
33
34
  return request.param
34
35
 
35
36
 
36
- @pytest.fixture(params=["v0.8.0"])
37
+ @pytest.fixture(params=[DEFAULT_END_REF])
37
38
  def end_ref(request: pytest.FixtureRequest) -> str:
38
39
  return request.param
39
40
 
@@ -103,13 +104,8 @@ def mock_temp_dir(tmp_path: Path) -> Iterator[Path]:
103
104
 
104
105
 
105
106
  @pytest.fixture
106
- def mock_worktree(mock_temp_dir: Path) -> Path:
107
- wt = mock_temp_dir / "mock_worktree"
108
- wt.mkdir(exist_ok=True)
109
-
110
- with Path.open(wt / ".copier-answers.yml", "w") as f:
111
- yaml.dump({"_commit": "deadbeef"}, f)
112
- return wt
107
+ def worktree(mock_temp_dir: Path) -> Path:
108
+ return mock_temp_dir / "worktree"
113
109
 
114
110
 
115
111
  @pytest.fixture(
@@ -127,10 +123,8 @@ class ExpectRun:
127
123
  disallow_subprocess: DisallowCallable
128
124
  mock_shell: Path
129
125
  origin: Path
126
+ worktree: Path
130
127
  expected_calls: list[_Call] = field(default_factory=list, init=False)
131
- run_mocks: list[tuple[Callable[Sequence[str], bool], object]] = field(
132
- default_factory=list
133
- )
134
128
 
135
129
  @contextmanager
136
130
  def patch(
@@ -144,25 +138,29 @@ class ExpectRun:
144
138
  subp_run = subprocess.run
145
139
 
146
140
  def _run(cmd: Sequence[str], *args: Any, **kwargs: Any) -> Any:
147
- for match_mock, mock_value in self.run_mocks:
148
- if match_mock(cmd):
149
- return mock_value
150
141
  if cmd[0] == str(self.mock_shell):
151
142
  if shell_callback:
152
143
  return shell_callback()
153
144
  return MagicMock()
145
+ if tuple(cmd[:2]) == ("copier", "check-update"):
146
+ if mock:
147
+ current_version = "11.38.0"
148
+ latest_version = current_version
149
+ else:
150
+ current_version = yaml.safe_load(
151
+ (self.worktree / ".copier-answers.yml").read_text()
152
+ )["_commit"].removeprefix("v")
153
+ latest_version = DEFAULT_END_REF.removeprefix("v")
154
+ data = {
155
+ "update_available": (current_version != latest_version),
156
+ "current_version": current_version,
157
+ "latest_version": latest_version,
158
+ }
159
+ return SimpleNamespace(stdout=json.dumps(data))
154
160
  if mock:
155
- if tuple(cmd[:2]) == ("copier", "check-update"):
156
- return SimpleNamespace(
157
- stdout=json.dumps(
158
- {
159
- "update_available": False,
160
- "current_version": "11.38.0",
161
- "latest_version": "11.38.0",
162
- }
163
- )
164
- )
165
161
  return MagicMock()
162
+ if tuple(cmd) == ("copier", "update", "-l"):
163
+ cmd = [*cmd, "--vcs-ref", DEFAULT_END_REF]
166
164
  cmd = [
167
165
  (
168
166
  str(self.origin)
@@ -193,12 +191,16 @@ class ExpectRun:
193
191
 
194
192
  @pytest.fixture
195
193
  def expect_run(
196
- disallow_subprocess: DisallowCallable, mock_shell: Path, origin: Path
194
+ disallow_subprocess: DisallowCallable,
195
+ mock_shell: Path,
196
+ origin: Path,
197
+ worktree: Path,
197
198
  ) -> ExpectRun:
198
199
  return ExpectRun(
199
200
  disallow_subprocess=disallow_subprocess,
200
201
  mock_shell=mock_shell,
201
202
  origin=origin,
203
+ worktree=worktree,
202
204
  )
203
205
 
204
206
 
@@ -209,7 +211,7 @@ def test_main_help(monkeypatch: pytest.MonkeyPatch) -> None:
209
211
 
210
212
 
211
213
  def test_main_update_with_project_current(
212
- mock_temp_dir: Path,
214
+ worktree: Path,
213
215
  expect_run: ExpectRun,
214
216
  create_project: Callable[..., Path],
215
217
  end_ref: str,
@@ -217,7 +219,6 @@ def test_main_update_with_project_current(
217
219
  dry_run: bool,
218
220
  ) -> None:
219
221
  create_project(vcs_ref=end_ref)
220
- worktree = mock_temp_dir / "worktree"
221
222
  expect_run.expect(
222
223
  ["git", "clone", "https://github.com/ness/pkfire", str(worktree)]
223
224
  )
@@ -241,8 +242,8 @@ def test_main_update_with_project_current(
241
242
 
242
243
  def test_main_update_error(
243
244
  disallow_subprocess: DisallowCallable,
245
+ worktree: Path,
244
246
  mock_shell: Path,
245
- mock_temp_dir: Path,
246
247
  expect_run: ExpectRun,
247
248
  create_project: Callable[..., Path],
248
249
  start_ref: str,
@@ -261,7 +262,6 @@ def test_main_update_error(
261
262
  )
262
263
 
263
264
  create_project(vcs_ref=start_ref, postcreate=_postcreate)
264
- worktree = mock_temp_dir / "worktree"
265
265
  commit_message = os.linesep.join(
266
266
  (
267
267
  "Apply template updates",
@@ -338,22 +338,17 @@ def test_main_update_error(
338
338
  ],
339
339
  )
340
340
  def test_main_update_repo_arguments(
341
- mock_temp_dir: Path, expect_run: ExpectRun, arg: str, repo: str
341
+ worktree: Path, expect_run: ExpectRun, arg: str, repo: str
342
342
  ) -> None:
343
343
  expect_run.expect(
344
- [
345
- "git",
346
- "clone",
347
- f"https://github.com/{repo}",
348
- str(mock_temp_dir / "worktree"),
349
- ]
344
+ ["git", "clone", f"https://github.com/{repo}", str(worktree)]
350
345
  )
351
346
  with expect_run.patch(mock=True, has_any=True):
352
347
  update([arg], dry_run=True)
353
348
 
354
349
 
355
350
  def test_main_update_with_project(
356
- mock_temp_dir: Path,
351
+ worktree: Path,
357
352
  expect_run: ExpectRun,
358
353
  create_project: Callable[..., Path],
359
354
  end_ref: str,
@@ -362,7 +357,6 @@ def test_main_update_with_project(
362
357
  dry_run: bool,
363
358
  ) -> None:
364
359
  create_project(vcs_ref=start_ref)
365
- worktree = mock_temp_dir / "worktree"
366
360
  commit_message = os.linesep.join(
367
361
  (
368
362
  "Apply template updates",
File without changes
File without changes
File without changes
File without changes