dycw-actions 0.11.3__py3-none-any.whl → 0.15.3__py3-none-any.whl

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.
actions/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.11.3"
3
+ __version__ = "0.15.3"
actions/cli.py CHANGED
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  from click import group
4
4
  from utilities.click import CONTEXT_SETTINGS
5
5
 
6
+ from actions import __version__
6
7
  from actions.clean_dir.cli import clean_dir_sub_cmd
7
8
  from actions.clean_dir.constants import CLEAN_DIR_DOCSTRING, CLEAN_DIR_SUB_CMD
8
9
  from actions.git_clone_with.cli import git_clone_with_sub_cmd
@@ -47,6 +48,8 @@ from actions.publish_package.constants import (
47
48
  )
48
49
  from actions.random_sleep.cli import random_sleep_sub_cmd
49
50
  from actions.random_sleep.constants import RANDOM_SLEEP_DOCSTRING, RANDOM_SLEEP_SUB_CMD
51
+ from actions.re_encrypt.cli import re_encrypt_sub_cmd
52
+ from actions.re_encrypt.constants import RE_ENCRYPT_DOCSTRING, RE_ENCRYPT_SUB_CMD
50
53
  from actions.register_gitea_runner.cli import register_gitea_runner_sub_cmd
51
54
  from actions.register_gitea_runner.constants import (
52
55
  REGISTER_GITEA_RUNNER_DOCSTRING,
@@ -68,7 +71,7 @@ from actions.tag_commit.cli import tag_commit_sub_cmd
68
71
  from actions.tag_commit.constants import TAG_COMMIT_DOCSTRING, TAG_COMMIT_SUB_CMD
69
72
 
70
73
 
71
- @group(**CONTEXT_SETTINGS)
74
+ @group(help=f"'actions' {__version__}", **CONTEXT_SETTINGS)
72
75
  def _main() -> None: ...
73
76
 
74
77
 
@@ -87,6 +90,9 @@ _ = _main.command(name=RUN_HOOKS_SUB_CMD, help=RUN_HOOKS_DOCSTRING, **CONTEXT_SE
87
90
  _ = _main.command(
88
91
  name=RANDOM_SLEEP_SUB_CMD, help=RANDOM_SLEEP_DOCSTRING, **CONTEXT_SETTINGS
89
92
  )(random_sleep_sub_cmd)
93
+ _ = _main.command(
94
+ name=RE_ENCRYPT_SUB_CMD, help=RE_ENCRYPT_DOCSTRING, **CONTEXT_SETTINGS
95
+ )(re_encrypt_sub_cmd)
90
96
  _ = _main.command(
91
97
  name=REGISTER_GITEA_RUNNER_SUB_CMD,
92
98
  help=REGISTER_GITEA_RUNNER_DOCSTRING,
@@ -57,7 +57,6 @@ def conformalize_repo_sub_cmd(settings: Settings, /) -> None:
57
57
  pre_commit__uv=settings.pre_commit__uv,
58
58
  pyproject=settings.pyproject,
59
59
  pyproject__project__optional_dependencies__scripts=settings.pyproject__project__optional_dependencies__scripts,
60
- pyproject__tool__uv__indexes=settings.pyproject__tool__uv__indexes,
61
60
  pyright=settings.pyright,
62
61
  pytest=settings.pytest,
63
62
  pytest__asyncio=settings.pytest__asyncio,
@@ -70,6 +69,7 @@ def conformalize_repo_sub_cmd(settings: Settings, /) -> None:
70
69
  ruff=settings.ruff,
71
70
  run_version_bump=settings.run_version_bump,
72
71
  script=settings.script,
72
+ uv__indexes=settings.uv__indexes,
73
73
  uv__native_tls=settings.uv__native_tls,
74
74
  )
75
75
 
@@ -3,8 +3,8 @@ from __future__ import annotations
3
3
  from pathlib import Path
4
4
  from re import search
5
5
 
6
+ from utilities.constants import IS_CI
6
7
  from utilities.pathlib import GetRootError, get_root
7
- from utilities.pytest import IS_CI
8
8
 
9
9
  from actions.pre_commit.constants import PATH_PRE_COMMIT
10
10
 
@@ -31,6 +31,7 @@ from actions.constants import (
31
31
  ENVRC,
32
32
  GITEA_PULL_REQUEST_YAML,
33
33
  GITEA_PUSH_YAML,
34
+ GITHUB,
34
35
  GITHUB_PULL_REQUEST_YAML,
35
36
  GITHUB_PUSH_YAML,
36
37
  GITIGNORE,
@@ -65,7 +66,7 @@ from actions.pre_commit.conformalize_repo.constants import (
65
66
  UV_URL,
66
67
  )
67
68
  from actions.pre_commit.conformalize_repo.settings import SETTINGS
68
- from actions.pre_commit.constants import THROTTLE_DELTA
69
+ from actions.pre_commit.constants import THROTTLE_DURATION
69
70
  from actions.pre_commit.format_requirements.constants import FORMAT_REQUIREMENTS_SUB_CMD
70
71
  from actions.pre_commit.replace_sequence_strs.constants import (
71
72
  REPLACE_SEQUENCE_STRS_SUB_CMD,
@@ -74,18 +75,19 @@ from actions.pre_commit.touch_empty_py.constants import TOUCH_EMPTY_PY_SUB_CMD
74
75
  from actions.pre_commit.touch_py_typed.constants import TOUCH_PY_TYPED_SUB_CMD
75
76
  from actions.pre_commit.update_requirements.constants import UPDATE_REQUIREMENTS_SUB_CMD
76
77
  from actions.pre_commit.utilities import (
77
- ensure_aot_contains,
78
78
  ensure_contains,
79
79
  ensure_contains_partial_dict,
80
80
  ensure_contains_partial_str,
81
81
  ensure_not_contains,
82
- get_aot,
83
- get_array,
84
- get_dict,
85
- get_list,
86
- get_table,
82
+ get_set_aot,
83
+ get_set_array,
84
+ get_set_dict,
85
+ get_set_list_dicts,
86
+ get_set_list_strs,
87
+ get_set_table,
87
88
  path_throttle_cache,
88
89
  yield_json_dict,
90
+ yield_pyproject_toml,
89
91
  yield_text_file,
90
92
  yield_toml_doc,
91
93
  yield_yaml_dict,
@@ -151,9 +153,6 @@ def conformalize_repo(
151
153
  pre_commit__uv: bool = SETTINGS.pre_commit__uv,
152
154
  pyproject: bool = SETTINGS.pyproject,
153
155
  pyproject__project__optional_dependencies__scripts: bool = SETTINGS.pyproject__project__optional_dependencies__scripts,
154
- pyproject__tool__uv__indexes: list[
155
- tuple[str, str]
156
- ] = SETTINGS.pyproject__tool__uv__indexes,
157
156
  pyright: bool = SETTINGS.pyright,
158
157
  pytest: bool = SETTINGS.pytest,
159
158
  pytest__asyncio: bool = SETTINGS.pytest__asyncio,
@@ -166,6 +165,7 @@ def conformalize_repo(
166
165
  ruff: bool = SETTINGS.ruff,
167
166
  run_version_bump: bool = SETTINGS.run_version_bump,
168
167
  script: str | None = SETTINGS.script,
168
+ uv__indexes: list[tuple[str, str]] = SETTINGS.uv__indexes,
169
169
  uv__native_tls: bool = SETTINGS.uv__native_tls,
170
170
  ) -> None:
171
171
  LOGGER.info(
@@ -213,7 +213,6 @@ def conformalize_repo(
213
213
  f"{pre_commit__uv=}",
214
214
  f"{pyproject=}",
215
215
  f"{pyproject__project__optional_dependencies__scripts=}",
216
- f"{pyproject__tool__uv__indexes=}",
217
216
  f"{pyright=}",
218
217
  f"{pytest=}",
219
218
  f"{pytest__asyncio=}",
@@ -226,6 +225,7 @@ def conformalize_repo(
226
225
  f"{ruff=}",
227
226
  f"{run_version_bump=}",
228
227
  f"{script=}",
228
+ f"{uv__indexes=}",
229
229
  f"{uv__native_tls=}",
230
230
  )
231
231
  )
@@ -251,16 +251,15 @@ def conformalize_repo(
251
251
  taplo=pre_commit__taplo,
252
252
  uv=pre_commit__uv,
253
253
  script=script,
254
+ uv__indexes=uv__indexes,
255
+ uv__native_tls=uv__native_tls,
254
256
  )
255
257
  if (
256
258
  ci__pull_request__pre_commit
257
- or ci__pull_request__pre_commit__submodules
258
259
  or ci__pull_request__pyright
259
260
  or ci__pull_request__pytest__macos
260
261
  or ci__pull_request__pytest__ubuntu
261
262
  or ci__pull_request__pytest__windows
262
- or ci__pull_request__pytest__all_versions
263
- or (ci__pull_request__pytest__sops_age_key is not None)
264
263
  or ci__pull_request__ruff
265
264
  ):
266
265
  add_ci_pull_request_yaml(
@@ -330,11 +329,7 @@ def conformalize_repo(
330
329
  )
331
330
  if gitignore:
332
331
  add_gitignore(modifications=modifications)
333
- if (
334
- pyproject
335
- or pyproject__project__optional_dependencies__scripts
336
- or (len(pyproject__tool__uv__indexes) >= 1)
337
- ):
332
+ if pyproject:
338
333
  add_pyproject_toml(
339
334
  modifications=modifications,
340
335
  python_version=python_version,
@@ -343,7 +338,7 @@ def conformalize_repo(
343
338
  readme=readme,
344
339
  optional_dependencies__scripts=pyproject__project__optional_dependencies__scripts,
345
340
  python_package_name=python_package_name,
346
- tool__uv__indexes=pyproject__tool__uv__indexes,
341
+ uv__indexes=uv__indexes,
347
342
  )
348
343
  if pyright:
349
344
  add_pyrightconfig_json(
@@ -394,11 +389,11 @@ def add_bumpversion_toml(
394
389
  python_package_name: str | None = SETTINGS.python_package_name,
395
390
  ) -> None:
396
391
  with yield_bumpversion_toml(modifications=modifications) as doc:
397
- tool = get_table(doc, "tool")
398
- bumpversion = get_table(tool, "bumpversion")
392
+ tool = get_set_table(doc, "tool")
393
+ bumpversion = get_set_table(tool, "bumpversion")
399
394
  if pyproject:
400
- files = get_aot(bumpversion, "files")
401
- ensure_aot_contains(
395
+ files = get_set_aot(bumpversion, "files")
396
+ ensure_contains(
402
397
  files,
403
398
  _add_bumpversion_toml_file(PYPROJECT_TOML, 'version = "${version}"'),
404
399
  )
@@ -407,8 +402,8 @@ def add_bumpversion_toml(
407
402
  package_name=package_name, python_package_name=python_package_name
408
403
  )
409
404
  ) is not None:
410
- files = get_aot(bumpversion, "files")
411
- ensure_aot_contains(
405
+ files = get_set_aot(bumpversion, "files")
406
+ ensure_contains(
412
407
  files,
413
408
  _add_bumpversion_toml_file(
414
409
  f"src/{python_package_name_use}/__init__.py",
@@ -455,17 +450,17 @@ def add_ci_pull_request_yaml(
455
450
  path = GITEA_PULL_REQUEST_YAML if gitea else GITHUB_PULL_REQUEST_YAML
456
451
  with yield_yaml_dict(path, modifications=modifications) as dict_:
457
452
  dict_["name"] = "pull-request"
458
- on = get_dict(dict_, "on")
459
- pull_request = get_dict(on, "pull_request")
460
- branches = get_list(pull_request, "branches")
453
+ on = get_set_dict(dict_, "on")
454
+ pull_request = get_set_dict(on, "pull_request")
455
+ branches = get_set_list_strs(pull_request, "branches")
461
456
  ensure_contains(branches, "master")
462
- schedule = get_list(on, "schedule")
457
+ schedule = get_set_list_dicts(on, "schedule")
463
458
  ensure_contains(schedule, {"cron": get_cron_job(repo_name=repo_name)})
464
- jobs = get_dict(dict_, "jobs")
459
+ jobs = get_set_dict(dict_, "jobs")
465
460
  if pre_commit:
466
- pre_commit_dict = get_dict(jobs, "pre-commit")
461
+ pre_commit_dict = get_set_dict(jobs, "pre-commit")
467
462
  pre_commit_dict["runs-on"] = "ubuntu-latest"
468
- steps = get_list(pre_commit_dict, "steps")
463
+ steps = get_set_list_dicts(pre_commit_dict, "steps")
469
464
  if certificates:
470
465
  ensure_contains(steps, update_ca_certificates_dict("pre-commit"))
471
466
  ensure_contains(
@@ -479,9 +474,9 @@ def add_ci_pull_request_yaml(
479
474
  ),
480
475
  )
481
476
  if pyright:
482
- pyright_dict = get_dict(jobs, "pyright")
477
+ pyright_dict = get_set_dict(jobs, "pyright")
483
478
  pyright_dict["runs-on"] = "ubuntu-latest"
484
- steps = get_list(pyright_dict, "steps")
479
+ steps = get_set_list_dicts(pyright_dict, "steps")
485
480
  if certificates:
486
481
  ensure_contains(steps, update_ca_certificates_dict("pyright"))
487
482
  ensure_contains(
@@ -495,14 +490,14 @@ def add_ci_pull_request_yaml(
495
490
  ),
496
491
  )
497
492
  if pytest__macos or pytest__ubuntu or pytest__windows:
498
- pytest_dict = get_dict(jobs, "pytest")
499
- env = get_dict(pytest_dict, "env")
493
+ pytest_dict = get_set_dict(jobs, "pytest")
494
+ env = get_set_dict(pytest_dict, "env")
500
495
  env["CI"] = "1"
501
496
  pytest_dict["name"] = (
502
497
  "pytest (${{matrix.os}}, ${{matrix.python-version}}, ${{matrix.resolution}})"
503
498
  )
504
499
  pytest_dict["runs-on"] = "${{matrix.os}}"
505
- steps = get_list(pytest_dict, "steps")
500
+ steps = get_set_list_dicts(pytest_dict, "steps")
506
501
  if certificates:
507
502
  ensure_contains(steps, update_ca_certificates_dict("pytest"))
508
503
  ensure_contains(
@@ -517,31 +512,31 @@ def add_ci_pull_request_yaml(
517
512
  with_requirements=script,
518
513
  ),
519
514
  )
520
- strategy_dict = get_dict(pytest_dict, "strategy")
515
+ strategy_dict = get_set_dict(pytest_dict, "strategy")
521
516
  strategy_dict["fail-fast"] = False
522
- matrix = get_dict(strategy_dict, "matrix")
523
- os = get_list(matrix, "os")
517
+ matrix = get_set_dict(strategy_dict, "matrix")
518
+ os = get_set_list_strs(matrix, "os")
524
519
  if pytest__macos:
525
520
  ensure_contains(os, "macos-latest")
526
521
  if pytest__ubuntu:
527
522
  ensure_contains(os, "ubuntu-latest")
528
523
  if pytest__windows:
529
524
  ensure_contains(os, "windows-latest")
530
- python_version_dict = get_list(matrix, "python-version")
525
+ python_version_dict = get_set_list_strs(matrix, "python-version")
531
526
  if pytest__all_versions:
532
527
  ensure_contains(
533
528
  python_version_dict, *yield_python_versions(python_version)
534
529
  )
535
530
  else:
536
531
  ensure_contains(python_version_dict, python_version)
537
- resolution = get_list(matrix, "resolution")
532
+ resolution = get_set_list_strs(matrix, "resolution")
538
533
  ensure_contains(resolution, "highest", "lowest-direct")
539
534
  if pytest__timeout is not None:
540
535
  pytest_dict["timeout-minutes"] = max(round(pytest__timeout / 60), 1)
541
536
  if ruff:
542
- ruff_dict = get_dict(jobs, "ruff")
537
+ ruff_dict = get_set_dict(jobs, "ruff")
543
538
  ruff_dict["runs-on"] = "ubuntu-latest"
544
- steps = get_list(ruff_dict, "steps")
539
+ steps = get_set_list_dicts(ruff_dict, "steps")
545
540
  if certificates:
546
541
  ensure_contains(steps, update_ca_certificates_dict("steps"))
547
542
  ensure_contains(
@@ -586,11 +581,11 @@ def add_ci_push_yaml(
586
581
  path = GITEA_PUSH_YAML if gitea else GITHUB_PUSH_YAML
587
582
  with yield_yaml_dict(path, modifications=modifications) as dict_:
588
583
  dict_["name"] = "push"
589
- on = get_dict(dict_, "on")
590
- push = get_dict(on, "push")
591
- branches = get_list(push, "branches")
584
+ on = get_set_dict(dict_, "on")
585
+ push = get_set_dict(on, "push")
586
+ branches = get_set_list_strs(push, "branches")
592
587
  ensure_contains(branches, "master")
593
- jobs = get_dict(dict_, "jobs")
588
+ jobs = get_set_dict(dict_, "jobs")
594
589
  if publish__github:
595
590
  _add_ci_push_yaml_publish_dict(
596
591
  jobs,
@@ -624,9 +619,9 @@ def add_ci_push_yaml(
624
619
  uv__native_tls=uv__native_tls,
625
620
  )
626
621
  if tag:
627
- tag_dict = get_dict(jobs, "tag")
622
+ tag_dict = get_set_dict(jobs, "tag")
628
623
  tag_dict["runs-on"] = "ubuntu-latest"
629
- steps = get_list(tag_dict, "steps")
624
+ steps = get_set_list_dicts(tag_dict, "steps")
630
625
  if certificates:
631
626
  ensure_contains(steps, update_ca_certificates_dict("tag"))
632
627
  ensure_contains(
@@ -652,14 +647,14 @@ def _add_ci_push_yaml_publish_dict(
652
647
  uv__native_tls: bool = SETTINGS.uv__native_tls,
653
648
  ) -> None:
654
649
  publish_name = f"publish-{name}"
655
- publish_dict = get_dict(jobs, publish_name)
650
+ publish_dict = get_set_dict(jobs, publish_name)
656
651
  if github:
657
- environment = get_dict(publish_dict, "environment")
652
+ environment = get_set_dict(publish_dict, "environment")
658
653
  environment["name"] = "pypi"
659
- permissions = get_dict(publish_dict, "permissions")
654
+ permissions = get_set_dict(publish_dict, "permissions")
660
655
  permissions["id-token"] = "write"
661
656
  publish_dict["runs-on"] = "ubuntu-latest"
662
- steps = get_list(publish_dict, "steps")
657
+ steps = get_set_list_dicts(publish_dict, "steps")
663
658
  if certificates:
664
659
  ensure_contains(steps, update_ca_certificates_dict(publish_name))
665
660
  ensure_contains(
@@ -680,15 +675,15 @@ def _add_ci_push_yaml_publish_dict(
680
675
 
681
676
  def add_coveragerc_toml(*, modifications: MutableSet[Path] | None = None) -> None:
682
677
  with yield_toml_doc(COVERAGERC_TOML, modifications=modifications) as doc:
683
- html = get_table(doc, "html")
678
+ html = get_set_table(doc, "html")
684
679
  html["directory"] = ".coverage/html"
685
- report = get_table(doc, "report")
686
- exclude_also = get_array(report, "exclude_also")
680
+ report = get_set_table(doc, "report")
681
+ exclude_also = get_set_array(report, "exclude_also")
687
682
  ensure_contains(exclude_also, "@overload", "if TYPE_CHECKING:")
688
683
  report["fail_under"] = 100.0
689
684
  report["skip_covered"] = True
690
685
  report["skip_empty"] = True
691
- run = get_table(doc, "run")
686
+ run = get_set_table(doc, "run")
692
687
  run["branch"] = True
693
688
  run["data_file"] = ".coverage/data"
694
689
  run["parallel"] = True
@@ -746,6 +741,7 @@ def _add_envrc_uv_text(
746
741
  strip_and_dedent(f"""
747
742
  export UV_PRERELEASE='disallow'
748
743
  export UV_PYTHON='{python_version}'
744
+ export UV_RESOLUTION='highest'
749
745
  export UV_VENV_CLEAR=1
750
746
  if ! command -v uv >/dev/null 2>&1; then
751
747
  \techo_date "ERROR: 'uv' not found" && exit 1
@@ -792,6 +788,8 @@ def add_pre_commit_config_yaml(
792
788
  taplo: bool = SETTINGS.pre_commit__taplo,
793
789
  uv: bool = SETTINGS.pre_commit__uv,
794
790
  script: str | None = SETTINGS.script,
791
+ uv__indexes: list[tuple[str, str]] = SETTINGS.uv__indexes,
792
+ uv__native_tls: bool = SETTINGS.uv__native_tls,
795
793
  ) -> None:
796
794
  with yield_yaml_dict(PRE_COMMIT_CONFIG_YAML, modifications=modifications) as dict_:
797
795
  _add_pre_commit_config_repo(dict_, ACTIONS_URL, CONFORMALIZE_REPO_SUB_CMD)
@@ -839,7 +837,17 @@ def add_pre_commit_config_yaml(
839
837
  )
840
838
  _add_pre_commit_config_repo(dict_, ACTIONS_URL, TOUCH_EMPTY_PY_SUB_CMD)
841
839
  _add_pre_commit_config_repo(dict_, ACTIONS_URL, TOUCH_PY_TYPED_SUB_CMD)
842
- _add_pre_commit_config_repo(dict_, ACTIONS_URL, UPDATE_REQUIREMENTS_SUB_CMD)
840
+ args: list[str] = []
841
+ if len(uv__indexes) >= 1:
842
+ args.extend(["--index", ",".join(v for _, v in uv__indexes)])
843
+ if uv__native_tls:
844
+ args.append("--native-tls")
845
+ _add_pre_commit_config_repo(
846
+ dict_,
847
+ ACTIONS_URL,
848
+ UPDATE_REQUIREMENTS_SUB_CMD,
849
+ args=("add", args) if len(args) >= 1 else None,
850
+ )
843
851
  if ruff:
844
852
  _add_pre_commit_config_repo(
845
853
  dict_, RUFF_URL, "ruff-check", args=("add", ["--fix"])
@@ -866,16 +874,21 @@ def add_pre_commit_config_yaml(
866
874
  ),
867
875
  )
868
876
  if uv:
877
+ args: list[str] = [
878
+ "--upgrade",
879
+ "--resolution",
880
+ "highest",
881
+ "--prerelease",
882
+ "disallow",
883
+ ]
884
+ if script is not None:
885
+ args.extend(["--script", script])
869
886
  _add_pre_commit_config_repo(
870
887
  dict_,
871
888
  UV_URL,
872
889
  "uv-lock",
873
890
  files=None if script is None else rf"^{escape(script)}$",
874
- args=(
875
- "add",
876
- ["--upgrade", "--resolution", "highest", "--prerelease", "disallow"]
877
- + ([] if script is None else [f"--script={script}"]),
878
- ),
891
+ args=("add", args),
879
892
  )
880
893
 
881
894
 
@@ -892,11 +905,11 @@ def _add_pre_commit_config_repo(
892
905
  types_or: list[str] | None = None,
893
906
  args: tuple[Literal["add", "exact"], list[str]] | None = None,
894
907
  ) -> None:
895
- repos_list = get_list(pre_commit_dict, "repos")
908
+ repos_list = get_set_list_dicts(pre_commit_dict, "repos")
896
909
  repo_dict = ensure_contains_partial_dict(
897
910
  repos_list, {"repo": url}, extra={} if url == "local" else {"rev": "master"}
898
911
  )
899
- hooks_list = get_list(repo_dict, "hooks")
912
+ hooks_list = get_set_list_dicts(repo_dict, "hooks")
900
913
  hook_dict = ensure_contains_partial_dict(hooks_list, {"id": id_})
901
914
  if name is not None:
902
915
  hook_dict["name"] = name
@@ -911,7 +924,7 @@ def _add_pre_commit_config_repo(
911
924
  if args is not None:
912
925
  match args:
913
926
  case "add", list() as args_i:
914
- hook_args = get_list(hook_dict, "args")
927
+ hook_args = get_set_list_strs(hook_dict, "args")
915
928
  ensure_contains(hook_args, *args_i)
916
929
  case "exact", list() as args_i:
917
930
  hook_dict["args"] = args_i
@@ -931,13 +944,13 @@ def add_pyproject_toml(
931
944
  readme: bool = SETTINGS.readme,
932
945
  optional_dependencies__scripts: bool = SETTINGS.pyproject__project__optional_dependencies__scripts,
933
946
  python_package_name: str | None = SETTINGS.python_package_name,
934
- tool__uv__indexes: list[tuple[str, str]] = SETTINGS.pyproject__tool__uv__indexes,
947
+ uv__indexes: list[tuple[str, str]] = SETTINGS.uv__indexes,
935
948
  ) -> None:
936
- with yield_toml_doc(PYPROJECT_TOML, modifications=modifications) as doc:
937
- build_system = get_table(doc, "build-system")
949
+ with yield_pyproject_toml(modifications=modifications) as doc:
950
+ build_system = get_set_table(doc, "build-system")
938
951
  build_system["build-backend"] = "uv_build"
939
952
  build_system["requires"] = ["uv_build"]
940
- project = get_table(doc, "project")
953
+ project = get_set_table(doc, "project")
941
954
  project["requires-python"] = f">= {python_version}"
942
955
  if description is not None:
943
956
  project["description"] = description
@@ -946,33 +959,31 @@ def add_pyproject_toml(
946
959
  if readme:
947
960
  project["readme"] = "README.md"
948
961
  project.setdefault("version", "0.1.0")
949
- dependency_groups = get_table(doc, "dependency-groups")
950
- dev = get_array(dependency_groups, "dev")
962
+ dependency_groups = get_set_table(doc, "dependency-groups")
963
+ dev = get_set_array(dependency_groups, "dev")
951
964
  _ = ensure_contains_partial_str(dev, "dycw-utilities[test]")
952
965
  _ = ensure_contains_partial_str(dev, "pyright")
953
966
  _ = ensure_contains_partial_str(dev, "rich")
954
967
  if optional_dependencies__scripts:
955
- optional_dependencies = get_table(project, "optional-dependencies")
956
- scripts = get_array(optional_dependencies, "scripts")
968
+ optional_dependencies = get_set_table(project, "optional-dependencies")
969
+ scripts = get_set_array(optional_dependencies, "scripts")
957
970
  _ = ensure_contains_partial_str(scripts, "click")
958
971
  if python_package_name is not None:
959
- tool = get_table(doc, "tool")
960
- uv = get_table(tool, "uv")
961
- build_backend = get_table(uv, "build-backend")
972
+ uv = get_tool_uv(doc)
973
+ build_backend = get_set_table(uv, "build-backend")
962
974
  build_backend["module-name"] = get_python_package_name(
963
975
  package_name=package_name, python_package_name=python_package_name
964
976
  )
965
977
  build_backend["module-root"] = "src"
966
- if len(tool__uv__indexes) >= 1:
967
- tool = get_table(doc, "tool")
968
- uv = get_table(tool, "uv")
969
- indexes = get_aot(uv, "index")
970
- for name, url in tool__uv__indexes:
978
+ if len(uv__indexes) >= 1:
979
+ uv = get_tool_uv(doc)
980
+ indexes = get_set_aot(uv, "index")
981
+ for name, url in uv__indexes:
971
982
  index = table()
972
983
  index["explicit"] = True
973
984
  index["name"] = name
974
985
  index["url"] = url
975
- ensure_aot_contains(indexes, index)
986
+ ensure_contains(indexes, index)
976
987
 
977
988
 
978
989
  ##
@@ -987,7 +998,7 @@ def add_pyrightconfig_json(
987
998
  with yield_json_dict(PYRIGHTCONFIG_JSON, modifications=modifications) as dict_:
988
999
  dict_["deprecateTypingAliases"] = True
989
1000
  dict_["enableReachabilityAnalysis"] = False
990
- include = get_list(dict_, "include")
1001
+ include = get_set_list_strs(dict_, "include")
991
1002
  ensure_contains(include, "src" if script is None else script)
992
1003
  dict_["pythonVersion"] = python_version
993
1004
  dict_["reportCallInDefaultInitializer"] = True
@@ -1028,8 +1039,8 @@ def add_pytest_toml(
1028
1039
  script: str | None = SETTINGS.script,
1029
1040
  ) -> None:
1030
1041
  with yield_toml_doc(PYTEST_TOML, modifications=modifications) as doc:
1031
- pytest = get_table(doc, "pytest")
1032
- addopts = get_array(pytest, "addopts")
1042
+ pytest = get_set_table(doc, "pytest")
1043
+ addopts = get_set_array(pytest, "addopts")
1033
1044
  ensure_contains(
1034
1045
  addopts,
1035
1046
  "-ra",
@@ -1054,18 +1065,18 @@ def add_pytest_toml(
1054
1065
  )
1055
1066
  pytest["collect_imported_tests"] = False
1056
1067
  pytest["empty_parameter_set_mark"] = "fail_at_collect"
1057
- filterwarnings = get_array(pytest, "filterwarnings")
1068
+ filterwarnings = get_set_array(pytest, "filterwarnings")
1058
1069
  ensure_contains(filterwarnings, "error")
1059
1070
  pytest["minversion"] = "9.0"
1060
1071
  pytest["strict"] = True
1061
- testpaths = get_array(pytest, "testpaths")
1072
+ testpaths = get_set_array(pytest, "testpaths")
1062
1073
  ensure_contains(testpaths, "src/tests" if script is None else "tests")
1063
1074
  pytest["xfail_strict"] = True
1064
1075
  if asyncio:
1065
1076
  pytest["asyncio_default_fixture_loop_scope"] = "function"
1066
1077
  pytest["asyncio_mode"] = "auto"
1067
1078
  if ignore_warnings:
1068
- filterwarnings = get_array(pytest, "filterwarnings")
1079
+ filterwarnings = get_set_array(pytest, "filterwarnings")
1069
1080
  ensure_contains(
1070
1081
  filterwarnings,
1071
1082
  "ignore::DeprecationWarning",
@@ -1107,14 +1118,14 @@ def add_ruff_toml(
1107
1118
  with yield_toml_doc(RUFF_TOML, modifications=modifications) as doc:
1108
1119
  doc["target-version"] = f"py{python_version.replace('.', '')}"
1109
1120
  doc["unsafe-fixes"] = True
1110
- fmt = get_table(doc, "format")
1121
+ fmt = get_set_table(doc, "format")
1111
1122
  fmt["preview"] = True
1112
1123
  fmt["skip-magic-trailing-comma"] = True
1113
- lint = get_table(doc, "lint")
1124
+ lint = get_set_table(doc, "lint")
1114
1125
  lint["explicit-preview-rules"] = True
1115
- fixable = get_array(lint, "fixable")
1126
+ fixable = get_set_array(lint, "fixable")
1116
1127
  ensure_contains(fixable, "ALL")
1117
- ignore = get_array(lint, "ignore")
1128
+ ignore = get_set_array(lint, "ignore")
1118
1129
  ensure_contains(
1119
1130
  ignore,
1120
1131
  "ANN401", # any-type
@@ -1155,27 +1166,27 @@ def add_ruff_toml(
1155
1166
  "ISC002", # multi-line-implicit-string-concatenation
1156
1167
  )
1157
1168
  lint["preview"] = True
1158
- select = get_array(lint, "select")
1169
+ select = get_set_array(lint, "select")
1159
1170
  selected_rules = [
1160
1171
  "RUF022", # unsorted-dunder-all
1161
1172
  "RUF029", # unused-async
1162
1173
  ]
1163
1174
  ensure_contains(select, "ALL", *selected_rules)
1164
- extend_per_file_ignores = get_table(lint, "extend-per-file-ignores")
1165
- test_py = get_array(extend_per_file_ignores, "test_*.py")
1175
+ extend_per_file_ignores = get_set_table(lint, "extend-per-file-ignores")
1176
+ test_py = get_set_array(extend_per_file_ignores, "test_*.py")
1166
1177
  test_py_rules = [
1167
1178
  "S101", # assert
1168
1179
  "SLF001", # private-member-access
1169
1180
  ]
1170
1181
  ensure_contains(test_py, *test_py_rules)
1171
1182
  ensure_not_contains(ignore, *selected_rules, *test_py_rules)
1172
- bugbear = get_table(lint, "flake8-bugbear")
1173
- extend_immutable_calls = get_array(bugbear, "extend-immutable-calls")
1183
+ bugbear = get_set_table(lint, "flake8-bugbear")
1184
+ extend_immutable_calls = get_set_array(bugbear, "extend-immutable-calls")
1174
1185
  ensure_contains(extend_immutable_calls, "typing.cast")
1175
- tidy_imports = get_table(lint, "flake8-tidy-imports")
1186
+ tidy_imports = get_set_table(lint, "flake8-tidy-imports")
1176
1187
  tidy_imports["ban-relative-imports"] = "all"
1177
- isort = get_table(lint, "isort")
1178
- req_imps = get_array(isort, "required-imports")
1188
+ isort = get_set_table(lint, "isort")
1189
+ req_imps = get_set_array(isort, "required-imports")
1179
1190
  ensure_contains(req_imps, "from __future__ import annotations")
1180
1191
  isort["split-on-trailing-comma"] = False
1181
1192
 
@@ -1224,13 +1235,21 @@ def get_python_package_name(
1224
1235
  ##
1225
1236
 
1226
1237
 
1238
+ def get_tool_uv(doc: TOMLDocument, /) -> Table:
1239
+ tool = get_set_table(doc, "tool")
1240
+ return get_set_table(tool, "uv")
1241
+
1242
+
1243
+ ##
1244
+
1245
+
1227
1246
  def get_version_from_bumpversion_toml(
1228
1247
  *, obj: TOMLDocument | str | None = None
1229
1248
  ) -> Version:
1230
1249
  match obj:
1231
1250
  case TOMLDocument() as doc:
1232
- tool = get_table(doc, "tool")
1233
- bumpversion = get_table(tool, "bumpversion")
1251
+ tool = get_set_table(doc, "tool")
1252
+ bumpversion = get_set_table(tool, "bumpversion")
1234
1253
  return parse_version(str(bumpversion["current_version"]))
1235
1254
  case str() as text:
1236
1255
  return get_version_from_bumpversion_toml(obj=tomlkit.parse(text))
@@ -1290,7 +1309,7 @@ def _run_pre_commit_update(*, modifications: MutableSet[Path] | None = None) ->
1290
1309
 
1291
1310
 
1292
1311
  run_pre_commit_update = throttle(
1293
- delta=THROTTLE_DELTA, path=path_throttle_cache(_run_pre_commit_update)
1312
+ duration=THROTTLE_DURATION, path=path_throttle_cache(_run_pre_commit_update)
1294
1313
  )(_run_pre_commit_update)
1295
1314
 
1296
1315
 
@@ -1356,7 +1375,7 @@ def update_action_file_extensions(
1356
1375
 
1357
1376
  def update_action_versions(*, modifications: MutableSet[Path] | None = None) -> None:
1358
1377
  try:
1359
- paths = list(Path(".github").rglob("**/*.yaml"))
1378
+ paths = list(GITHUB.rglob("**/*.yaml"))
1360
1379
  except FileNotFoundError:
1361
1380
  return
1362
1381
  versions = {
@@ -1385,8 +1404,8 @@ def yield_bumpversion_toml(
1385
1404
  *, modifications: MutableSet[Path] | None = None
1386
1405
  ) -> Iterator[TOMLDocument]:
1387
1406
  with yield_toml_doc(BUMPVERSION_TOML, modifications=modifications) as doc:
1388
- tool = get_table(doc, "tool")
1389
- bumpversion = get_table(tool, "bumpversion")
1407
+ tool = get_set_table(doc, "tool")
1408
+ bumpversion = get_set_table(tool, "bumpversion")
1390
1409
  bumpversion["allow_dirty"] = True
1391
1410
  bumpversion.setdefault("current_version", str(Version(0, 1, 0)))
1392
1411
  yield doc
@@ -1434,6 +1453,7 @@ __all__ = [
1434
1453
  "check_versions",
1435
1454
  "get_cron_job",
1436
1455
  "get_python_package_name",
1456
+ "get_tool_uv",
1437
1457
  "get_version_from_bumpversion_toml",
1438
1458
  "get_version_from_git_show",
1439
1459
  "get_version_from_git_tag",