dycw-actions 0.11.3__py3-none-any.whl → 0.14.0__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/.DS_Store +0 -0
- actions/__init__.py +1 -1
- actions/cli.py +5 -0
- actions/pre_commit/conformalize_repo/cli.py +1 -1
- actions/pre_commit/conformalize_repo/lib.py +128 -109
- actions/pre_commit/conformalize_repo/settings.py +3 -3
- actions/pre_commit/constants.py +3 -3
- actions/pre_commit/touch_empty_py/lib.py +2 -2
- actions/pre_commit/touch_py_typed/lib.py +4 -3
- actions/pre_commit/update_requirements/cli.py +10 -2
- actions/pre_commit/update_requirements/lib.py +74 -14
- actions/pre_commit/update_requirements/settings.py +23 -0
- actions/pre_commit/utilities.py +131 -39
- actions/publish_package/lib.py +17 -11
- actions/random_sleep/lib.py +3 -3
- actions/re_encrypt/__init__.py +1 -0
- actions/re_encrypt/cli.py +36 -0
- actions/re_encrypt/constants.py +7 -0
- actions/re_encrypt/lib.py +115 -0
- actions/re_encrypt/settings.py +26 -0
- actions/run_hooks/lib.py +13 -11
- actions/types.py +5 -9
- {dycw_actions-0.11.3.dist-info → dycw_actions-0.14.0.dist-info}/METADATA +4 -2
- {dycw_actions-0.11.3.dist-info → dycw_actions-0.14.0.dist-info}/RECORD +26 -19
- {dycw_actions-0.11.3.dist-info → dycw_actions-0.14.0.dist-info}/WHEEL +1 -1
- {dycw_actions-0.11.3.dist-info → dycw_actions-0.14.0.dist-info}/entry_points.txt +0 -0
actions/.DS_Store
ADDED
|
Binary file
|
actions/__init__.py
CHANGED
actions/cli.py
CHANGED
|
@@ -47,6 +47,8 @@ from actions.publish_package.constants import (
|
|
|
47
47
|
)
|
|
48
48
|
from actions.random_sleep.cli import random_sleep_sub_cmd
|
|
49
49
|
from actions.random_sleep.constants import RANDOM_SLEEP_DOCSTRING, RANDOM_SLEEP_SUB_CMD
|
|
50
|
+
from actions.re_encrypt.cli import re_encrypt_sub_cmd
|
|
51
|
+
from actions.re_encrypt.constants import RE_ENCRYPT_DOCSTRING, RE_ENCRYPT_SUB_CMD
|
|
50
52
|
from actions.register_gitea_runner.cli import register_gitea_runner_sub_cmd
|
|
51
53
|
from actions.register_gitea_runner.constants import (
|
|
52
54
|
REGISTER_GITEA_RUNNER_DOCSTRING,
|
|
@@ -87,6 +89,9 @@ _ = _main.command(name=RUN_HOOKS_SUB_CMD, help=RUN_HOOKS_DOCSTRING, **CONTEXT_SE
|
|
|
87
89
|
_ = _main.command(
|
|
88
90
|
name=RANDOM_SLEEP_SUB_CMD, help=RANDOM_SLEEP_DOCSTRING, **CONTEXT_SETTINGS
|
|
89
91
|
)(random_sleep_sub_cmd)
|
|
92
|
+
_ = _main.command(
|
|
93
|
+
name=RE_ENCRYPT_SUB_CMD, help=RE_ENCRYPT_DOCSTRING, **CONTEXT_SETTINGS
|
|
94
|
+
)(re_encrypt_sub_cmd)
|
|
90
95
|
_ = _main.command(
|
|
91
96
|
name=REGISTER_GITEA_RUNNER_SUB_CMD,
|
|
92
97
|
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
|
|
|
@@ -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
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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 =
|
|
398
|
-
bumpversion =
|
|
392
|
+
tool = get_set_table(doc, "tool")
|
|
393
|
+
bumpversion = get_set_table(tool, "bumpversion")
|
|
399
394
|
if pyproject:
|
|
400
|
-
files =
|
|
401
|
-
|
|
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 =
|
|
411
|
-
|
|
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 =
|
|
459
|
-
pull_request =
|
|
460
|
-
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 =
|
|
457
|
+
schedule = get_set_list_dicts(on, "schedule")
|
|
463
458
|
ensure_contains(schedule, {"cron": get_cron_job(repo_name=repo_name)})
|
|
464
|
-
jobs =
|
|
459
|
+
jobs = get_set_dict(dict_, "jobs")
|
|
465
460
|
if pre_commit:
|
|
466
|
-
pre_commit_dict =
|
|
461
|
+
pre_commit_dict = get_set_dict(jobs, "pre-commit")
|
|
467
462
|
pre_commit_dict["runs-on"] = "ubuntu-latest"
|
|
468
|
-
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 =
|
|
477
|
+
pyright_dict = get_set_dict(jobs, "pyright")
|
|
483
478
|
pyright_dict["runs-on"] = "ubuntu-latest"
|
|
484
|
-
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 =
|
|
499
|
-
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 =
|
|
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 =
|
|
515
|
+
strategy_dict = get_set_dict(pytest_dict, "strategy")
|
|
521
516
|
strategy_dict["fail-fast"] = False
|
|
522
|
-
matrix =
|
|
523
|
-
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 =
|
|
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 =
|
|
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 =
|
|
537
|
+
ruff_dict = get_set_dict(jobs, "ruff")
|
|
543
538
|
ruff_dict["runs-on"] = "ubuntu-latest"
|
|
544
|
-
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 =
|
|
590
|
-
push =
|
|
591
|
-
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 =
|
|
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 =
|
|
622
|
+
tag_dict = get_set_dict(jobs, "tag")
|
|
628
623
|
tag_dict["runs-on"] = "ubuntu-latest"
|
|
629
|
-
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 =
|
|
650
|
+
publish_dict = get_set_dict(jobs, publish_name)
|
|
656
651
|
if github:
|
|
657
|
-
environment =
|
|
652
|
+
environment = get_set_dict(publish_dict, "environment")
|
|
658
653
|
environment["name"] = "pypi"
|
|
659
|
-
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 =
|
|
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 =
|
|
678
|
+
html = get_set_table(doc, "html")
|
|
684
679
|
html["directory"] = ".coverage/html"
|
|
685
|
-
report =
|
|
686
|
-
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 =
|
|
686
|
+
run = get_set_table(doc, "run")
|
|
692
687
|
run["branch"] = True
|
|
693
688
|
run["data_file"] = ".coverage/data"
|
|
694
689
|
run["parallel"] = True
|
|
@@ -792,6 +787,8 @@ def add_pre_commit_config_yaml(
|
|
|
792
787
|
taplo: bool = SETTINGS.pre_commit__taplo,
|
|
793
788
|
uv: bool = SETTINGS.pre_commit__uv,
|
|
794
789
|
script: str | None = SETTINGS.script,
|
|
790
|
+
uv__indexes: list[tuple[str, str]] = SETTINGS.uv__indexes,
|
|
791
|
+
uv__native_tls: bool = SETTINGS.uv__native_tls,
|
|
795
792
|
) -> None:
|
|
796
793
|
with yield_yaml_dict(PRE_COMMIT_CONFIG_YAML, modifications=modifications) as dict_:
|
|
797
794
|
_add_pre_commit_config_repo(dict_, ACTIONS_URL, CONFORMALIZE_REPO_SUB_CMD)
|
|
@@ -839,7 +836,17 @@ def add_pre_commit_config_yaml(
|
|
|
839
836
|
)
|
|
840
837
|
_add_pre_commit_config_repo(dict_, ACTIONS_URL, TOUCH_EMPTY_PY_SUB_CMD)
|
|
841
838
|
_add_pre_commit_config_repo(dict_, ACTIONS_URL, TOUCH_PY_TYPED_SUB_CMD)
|
|
842
|
-
|
|
839
|
+
args: list[str] = []
|
|
840
|
+
if len(uv__indexes) >= 1:
|
|
841
|
+
args.extend(["--index", ",".join(v for _, v in uv__indexes)])
|
|
842
|
+
if uv__native_tls:
|
|
843
|
+
args.append("--native-tls")
|
|
844
|
+
_add_pre_commit_config_repo(
|
|
845
|
+
dict_,
|
|
846
|
+
ACTIONS_URL,
|
|
847
|
+
UPDATE_REQUIREMENTS_SUB_CMD,
|
|
848
|
+
args=("add", args) if len(args) >= 1 else None,
|
|
849
|
+
)
|
|
843
850
|
if ruff:
|
|
844
851
|
_add_pre_commit_config_repo(
|
|
845
852
|
dict_, RUFF_URL, "ruff-check", args=("add", ["--fix"])
|
|
@@ -866,16 +873,21 @@ def add_pre_commit_config_yaml(
|
|
|
866
873
|
),
|
|
867
874
|
)
|
|
868
875
|
if uv:
|
|
876
|
+
args: list[str] = [
|
|
877
|
+
"--upgrade",
|
|
878
|
+
"--resolution",
|
|
879
|
+
"highest",
|
|
880
|
+
"--prerelease",
|
|
881
|
+
"disallow",
|
|
882
|
+
]
|
|
883
|
+
if script is not None:
|
|
884
|
+
args.extend(["--script", script])
|
|
869
885
|
_add_pre_commit_config_repo(
|
|
870
886
|
dict_,
|
|
871
887
|
UV_URL,
|
|
872
888
|
"uv-lock",
|
|
873
889
|
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
|
-
),
|
|
890
|
+
args=("add", args),
|
|
879
891
|
)
|
|
880
892
|
|
|
881
893
|
|
|
@@ -892,11 +904,11 @@ def _add_pre_commit_config_repo(
|
|
|
892
904
|
types_or: list[str] | None = None,
|
|
893
905
|
args: tuple[Literal["add", "exact"], list[str]] | None = None,
|
|
894
906
|
) -> None:
|
|
895
|
-
repos_list =
|
|
907
|
+
repos_list = get_set_list_dicts(pre_commit_dict, "repos")
|
|
896
908
|
repo_dict = ensure_contains_partial_dict(
|
|
897
909
|
repos_list, {"repo": url}, extra={} if url == "local" else {"rev": "master"}
|
|
898
910
|
)
|
|
899
|
-
hooks_list =
|
|
911
|
+
hooks_list = get_set_list_dicts(repo_dict, "hooks")
|
|
900
912
|
hook_dict = ensure_contains_partial_dict(hooks_list, {"id": id_})
|
|
901
913
|
if name is not None:
|
|
902
914
|
hook_dict["name"] = name
|
|
@@ -911,7 +923,7 @@ def _add_pre_commit_config_repo(
|
|
|
911
923
|
if args is not None:
|
|
912
924
|
match args:
|
|
913
925
|
case "add", list() as args_i:
|
|
914
|
-
hook_args =
|
|
926
|
+
hook_args = get_set_list_strs(hook_dict, "args")
|
|
915
927
|
ensure_contains(hook_args, *args_i)
|
|
916
928
|
case "exact", list() as args_i:
|
|
917
929
|
hook_dict["args"] = args_i
|
|
@@ -931,13 +943,13 @@ def add_pyproject_toml(
|
|
|
931
943
|
readme: bool = SETTINGS.readme,
|
|
932
944
|
optional_dependencies__scripts: bool = SETTINGS.pyproject__project__optional_dependencies__scripts,
|
|
933
945
|
python_package_name: str | None = SETTINGS.python_package_name,
|
|
934
|
-
|
|
946
|
+
uv__indexes: list[tuple[str, str]] = SETTINGS.uv__indexes,
|
|
935
947
|
) -> None:
|
|
936
|
-
with
|
|
937
|
-
build_system =
|
|
948
|
+
with yield_pyproject_toml(modifications=modifications) as doc:
|
|
949
|
+
build_system = get_set_table(doc, "build-system")
|
|
938
950
|
build_system["build-backend"] = "uv_build"
|
|
939
951
|
build_system["requires"] = ["uv_build"]
|
|
940
|
-
project =
|
|
952
|
+
project = get_set_table(doc, "project")
|
|
941
953
|
project["requires-python"] = f">= {python_version}"
|
|
942
954
|
if description is not None:
|
|
943
955
|
project["description"] = description
|
|
@@ -946,33 +958,31 @@ def add_pyproject_toml(
|
|
|
946
958
|
if readme:
|
|
947
959
|
project["readme"] = "README.md"
|
|
948
960
|
project.setdefault("version", "0.1.0")
|
|
949
|
-
dependency_groups =
|
|
950
|
-
dev =
|
|
961
|
+
dependency_groups = get_set_table(doc, "dependency-groups")
|
|
962
|
+
dev = get_set_array(dependency_groups, "dev")
|
|
951
963
|
_ = ensure_contains_partial_str(dev, "dycw-utilities[test]")
|
|
952
964
|
_ = ensure_contains_partial_str(dev, "pyright")
|
|
953
965
|
_ = ensure_contains_partial_str(dev, "rich")
|
|
954
966
|
if optional_dependencies__scripts:
|
|
955
|
-
optional_dependencies =
|
|
956
|
-
scripts =
|
|
967
|
+
optional_dependencies = get_set_table(project, "optional-dependencies")
|
|
968
|
+
scripts = get_set_array(optional_dependencies, "scripts")
|
|
957
969
|
_ = ensure_contains_partial_str(scripts, "click")
|
|
958
970
|
if python_package_name is not None:
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
build_backend = get_table(uv, "build-backend")
|
|
971
|
+
uv = get_tool_uv(doc)
|
|
972
|
+
build_backend = get_set_table(uv, "build-backend")
|
|
962
973
|
build_backend["module-name"] = get_python_package_name(
|
|
963
974
|
package_name=package_name, python_package_name=python_package_name
|
|
964
975
|
)
|
|
965
976
|
build_backend["module-root"] = "src"
|
|
966
|
-
if len(
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
for name, url in tool__uv__indexes:
|
|
977
|
+
if len(uv__indexes) >= 1:
|
|
978
|
+
uv = get_tool_uv(doc)
|
|
979
|
+
indexes = get_set_aot(uv, "index")
|
|
980
|
+
for name, url in uv__indexes:
|
|
971
981
|
index = table()
|
|
972
982
|
index["explicit"] = True
|
|
973
983
|
index["name"] = name
|
|
974
984
|
index["url"] = url
|
|
975
|
-
|
|
985
|
+
ensure_contains(indexes, index)
|
|
976
986
|
|
|
977
987
|
|
|
978
988
|
##
|
|
@@ -987,7 +997,7 @@ def add_pyrightconfig_json(
|
|
|
987
997
|
with yield_json_dict(PYRIGHTCONFIG_JSON, modifications=modifications) as dict_:
|
|
988
998
|
dict_["deprecateTypingAliases"] = True
|
|
989
999
|
dict_["enableReachabilityAnalysis"] = False
|
|
990
|
-
include =
|
|
1000
|
+
include = get_set_list_strs(dict_, "include")
|
|
991
1001
|
ensure_contains(include, "src" if script is None else script)
|
|
992
1002
|
dict_["pythonVersion"] = python_version
|
|
993
1003
|
dict_["reportCallInDefaultInitializer"] = True
|
|
@@ -1028,8 +1038,8 @@ def add_pytest_toml(
|
|
|
1028
1038
|
script: str | None = SETTINGS.script,
|
|
1029
1039
|
) -> None:
|
|
1030
1040
|
with yield_toml_doc(PYTEST_TOML, modifications=modifications) as doc:
|
|
1031
|
-
pytest =
|
|
1032
|
-
addopts =
|
|
1041
|
+
pytest = get_set_table(doc, "pytest")
|
|
1042
|
+
addopts = get_set_array(pytest, "addopts")
|
|
1033
1043
|
ensure_contains(
|
|
1034
1044
|
addopts,
|
|
1035
1045
|
"-ra",
|
|
@@ -1054,18 +1064,18 @@ def add_pytest_toml(
|
|
|
1054
1064
|
)
|
|
1055
1065
|
pytest["collect_imported_tests"] = False
|
|
1056
1066
|
pytest["empty_parameter_set_mark"] = "fail_at_collect"
|
|
1057
|
-
filterwarnings =
|
|
1067
|
+
filterwarnings = get_set_array(pytest, "filterwarnings")
|
|
1058
1068
|
ensure_contains(filterwarnings, "error")
|
|
1059
1069
|
pytest["minversion"] = "9.0"
|
|
1060
1070
|
pytest["strict"] = True
|
|
1061
|
-
testpaths =
|
|
1071
|
+
testpaths = get_set_array(pytest, "testpaths")
|
|
1062
1072
|
ensure_contains(testpaths, "src/tests" if script is None else "tests")
|
|
1063
1073
|
pytest["xfail_strict"] = True
|
|
1064
1074
|
if asyncio:
|
|
1065
1075
|
pytest["asyncio_default_fixture_loop_scope"] = "function"
|
|
1066
1076
|
pytest["asyncio_mode"] = "auto"
|
|
1067
1077
|
if ignore_warnings:
|
|
1068
|
-
filterwarnings =
|
|
1078
|
+
filterwarnings = get_set_array(pytest, "filterwarnings")
|
|
1069
1079
|
ensure_contains(
|
|
1070
1080
|
filterwarnings,
|
|
1071
1081
|
"ignore::DeprecationWarning",
|
|
@@ -1107,14 +1117,14 @@ def add_ruff_toml(
|
|
|
1107
1117
|
with yield_toml_doc(RUFF_TOML, modifications=modifications) as doc:
|
|
1108
1118
|
doc["target-version"] = f"py{python_version.replace('.', '')}"
|
|
1109
1119
|
doc["unsafe-fixes"] = True
|
|
1110
|
-
fmt =
|
|
1120
|
+
fmt = get_set_table(doc, "format")
|
|
1111
1121
|
fmt["preview"] = True
|
|
1112
1122
|
fmt["skip-magic-trailing-comma"] = True
|
|
1113
|
-
lint =
|
|
1123
|
+
lint = get_set_table(doc, "lint")
|
|
1114
1124
|
lint["explicit-preview-rules"] = True
|
|
1115
|
-
fixable =
|
|
1125
|
+
fixable = get_set_array(lint, "fixable")
|
|
1116
1126
|
ensure_contains(fixable, "ALL")
|
|
1117
|
-
ignore =
|
|
1127
|
+
ignore = get_set_array(lint, "ignore")
|
|
1118
1128
|
ensure_contains(
|
|
1119
1129
|
ignore,
|
|
1120
1130
|
"ANN401", # any-type
|
|
@@ -1155,27 +1165,27 @@ def add_ruff_toml(
|
|
|
1155
1165
|
"ISC002", # multi-line-implicit-string-concatenation
|
|
1156
1166
|
)
|
|
1157
1167
|
lint["preview"] = True
|
|
1158
|
-
select =
|
|
1168
|
+
select = get_set_array(lint, "select")
|
|
1159
1169
|
selected_rules = [
|
|
1160
1170
|
"RUF022", # unsorted-dunder-all
|
|
1161
1171
|
"RUF029", # unused-async
|
|
1162
1172
|
]
|
|
1163
1173
|
ensure_contains(select, "ALL", *selected_rules)
|
|
1164
|
-
extend_per_file_ignores =
|
|
1165
|
-
test_py =
|
|
1174
|
+
extend_per_file_ignores = get_set_table(lint, "extend-per-file-ignores")
|
|
1175
|
+
test_py = get_set_array(extend_per_file_ignores, "test_*.py")
|
|
1166
1176
|
test_py_rules = [
|
|
1167
1177
|
"S101", # assert
|
|
1168
1178
|
"SLF001", # private-member-access
|
|
1169
1179
|
]
|
|
1170
1180
|
ensure_contains(test_py, *test_py_rules)
|
|
1171
1181
|
ensure_not_contains(ignore, *selected_rules, *test_py_rules)
|
|
1172
|
-
bugbear =
|
|
1173
|
-
extend_immutable_calls =
|
|
1182
|
+
bugbear = get_set_table(lint, "flake8-bugbear")
|
|
1183
|
+
extend_immutable_calls = get_set_array(bugbear, "extend-immutable-calls")
|
|
1174
1184
|
ensure_contains(extend_immutable_calls, "typing.cast")
|
|
1175
|
-
tidy_imports =
|
|
1185
|
+
tidy_imports = get_set_table(lint, "flake8-tidy-imports")
|
|
1176
1186
|
tidy_imports["ban-relative-imports"] = "all"
|
|
1177
|
-
isort =
|
|
1178
|
-
req_imps =
|
|
1187
|
+
isort = get_set_table(lint, "isort")
|
|
1188
|
+
req_imps = get_set_array(isort, "required-imports")
|
|
1179
1189
|
ensure_contains(req_imps, "from __future__ import annotations")
|
|
1180
1190
|
isort["split-on-trailing-comma"] = False
|
|
1181
1191
|
|
|
@@ -1224,13 +1234,21 @@ def get_python_package_name(
|
|
|
1224
1234
|
##
|
|
1225
1235
|
|
|
1226
1236
|
|
|
1237
|
+
def get_tool_uv(doc: TOMLDocument, /) -> Table:
|
|
1238
|
+
tool = get_set_table(doc, "tool")
|
|
1239
|
+
return get_set_table(tool, "uv")
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
##
|
|
1243
|
+
|
|
1244
|
+
|
|
1227
1245
|
def get_version_from_bumpversion_toml(
|
|
1228
1246
|
*, obj: TOMLDocument | str | None = None
|
|
1229
1247
|
) -> Version:
|
|
1230
1248
|
match obj:
|
|
1231
1249
|
case TOMLDocument() as doc:
|
|
1232
|
-
tool =
|
|
1233
|
-
bumpversion =
|
|
1250
|
+
tool = get_set_table(doc, "tool")
|
|
1251
|
+
bumpversion = get_set_table(tool, "bumpversion")
|
|
1234
1252
|
return parse_version(str(bumpversion["current_version"]))
|
|
1235
1253
|
case str() as text:
|
|
1236
1254
|
return get_version_from_bumpversion_toml(obj=tomlkit.parse(text))
|
|
@@ -1290,7 +1308,7 @@ def _run_pre_commit_update(*, modifications: MutableSet[Path] | None = None) ->
|
|
|
1290
1308
|
|
|
1291
1309
|
|
|
1292
1310
|
run_pre_commit_update = throttle(
|
|
1293
|
-
|
|
1311
|
+
duration=THROTTLE_DURATION, path=path_throttle_cache(_run_pre_commit_update)
|
|
1294
1312
|
)(_run_pre_commit_update)
|
|
1295
1313
|
|
|
1296
1314
|
|
|
@@ -1356,7 +1374,7 @@ def update_action_file_extensions(
|
|
|
1356
1374
|
|
|
1357
1375
|
def update_action_versions(*, modifications: MutableSet[Path] | None = None) -> None:
|
|
1358
1376
|
try:
|
|
1359
|
-
paths = list(
|
|
1377
|
+
paths = list(GITHUB.rglob("**/*.yaml"))
|
|
1360
1378
|
except FileNotFoundError:
|
|
1361
1379
|
return
|
|
1362
1380
|
versions = {
|
|
@@ -1385,8 +1403,8 @@ def yield_bumpversion_toml(
|
|
|
1385
1403
|
*, modifications: MutableSet[Path] | None = None
|
|
1386
1404
|
) -> Iterator[TOMLDocument]:
|
|
1387
1405
|
with yield_toml_doc(BUMPVERSION_TOML, modifications=modifications) as doc:
|
|
1388
|
-
tool =
|
|
1389
|
-
bumpversion =
|
|
1406
|
+
tool = get_set_table(doc, "tool")
|
|
1407
|
+
bumpversion = get_set_table(tool, "bumpversion")
|
|
1390
1408
|
bumpversion["allow_dirty"] = True
|
|
1391
1409
|
bumpversion.setdefault("current_version", str(Version(0, 1, 0)))
|
|
1392
1410
|
yield doc
|
|
@@ -1434,6 +1452,7 @@ __all__ = [
|
|
|
1434
1452
|
"check_versions",
|
|
1435
1453
|
"get_cron_job",
|
|
1436
1454
|
"get_python_package_name",
|
|
1455
|
+
"get_tool_uv",
|
|
1437
1456
|
"get_version_from_bumpversion_toml",
|
|
1438
1457
|
"get_version_from_git_show",
|
|
1439
1458
|
"get_version_from_git_tag",
|
|
@@ -115,9 +115,6 @@ class Settings:
|
|
|
115
115
|
default=False,
|
|
116
116
|
help="Set up 'pyproject.toml' [project.optional-dependencies.scripts]",
|
|
117
117
|
)
|
|
118
|
-
pyproject__tool__uv__indexes: list[tuple[str, str]] = option(
|
|
119
|
-
factory=list, help="Set up 'pyproject.toml' [[uv.tool.index]]"
|
|
120
|
-
)
|
|
121
118
|
pyright: bool = option(default=False, help="Set up 'pyrightconfig.json'")
|
|
122
119
|
pytest: bool = option(default=False, help="Set up 'pytest.toml'")
|
|
123
120
|
pytest__asyncio: bool = option(default=False, help="Set up 'pytest.toml' asyncio_*")
|
|
@@ -135,6 +132,9 @@ class Settings:
|
|
|
135
132
|
repo_name: str | None = option(default=None, help="Repo name")
|
|
136
133
|
ruff: bool = option(default=False, help="Set up 'ruff.toml'")
|
|
137
134
|
run_version_bump: bool = option(default=RUN_VERSION_BUMP, help="Run version bump")
|
|
135
|
+
uv__indexes: list[tuple[str, str]] = option(
|
|
136
|
+
factory=list, help="Set up 'uv' with index indexes"
|
|
137
|
+
)
|
|
138
138
|
uv__native_tls: bool = option(default=False, help="Setup 'uv' with native TLS")
|
|
139
139
|
script: str | None = option(
|
|
140
140
|
default=None, help="Set up a script instead of a package"
|