crackerjack 0.3.3__tar.gz → 0.7.30__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.

Potentially problematic release.


This version of crackerjack might be problematic. Click here for more details.

Files changed (32) hide show
  1. {crackerjack-0.3.3 → crackerjack-0.7.30}/PKG-INFO +36 -27
  2. {crackerjack-0.3.3 → crackerjack-0.7.30}/README.md +14 -16
  3. {crackerjack-0.3.3 → crackerjack-0.7.30}/crackerjack/.gitignore +4 -3
  4. {crackerjack-0.3.3 → crackerjack-0.7.30}/crackerjack/.pre-commit-config.yaml +23 -37
  5. crackerjack-0.7.30/crackerjack/.ruff_cache/0.1.11/3256171999636029978 +0 -0
  6. crackerjack-0.7.30/crackerjack/.ruff_cache/0.1.14/602324811142551221 +0 -0
  7. crackerjack-0.7.30/crackerjack/.ruff_cache/0.1.4/10355199064880463147 +0 -0
  8. crackerjack-0.7.30/crackerjack/.ruff_cache/0.1.6/15140459877605758699 +0 -0
  9. crackerjack-0.7.30/crackerjack/.ruff_cache/0.1.7/1790508110482614856 +0 -0
  10. crackerjack-0.7.30/crackerjack/.ruff_cache/0.1.9/17041001205004563469 +0 -0
  11. crackerjack-0.7.30/crackerjack/.ruff_cache/0.2.0/10047773857155985907 +0 -0
  12. crackerjack-0.7.30/crackerjack/.ruff_cache/0.2.1/8522267973936635051 +0 -0
  13. crackerjack-0.7.30/crackerjack/.ruff_cache/0.2.2/18053836298936336950 +0 -0
  14. crackerjack-0.7.30/crackerjack/.ruff_cache/0.3.0/12548816621480535786 +0 -0
  15. crackerjack-0.7.30/crackerjack/.ruff_cache/0.3.3/11081883392474770722 +0 -0
  16. crackerjack-0.7.30/crackerjack/.ruff_cache/0.3.4/676973378459347183 +0 -0
  17. crackerjack-0.7.30/crackerjack/.ruff_cache/0.3.5/16311176246009842383 +0 -0
  18. {crackerjack-0.3.3 → crackerjack-0.7.30}/crackerjack/__main__.py +18 -4
  19. crackerjack-0.7.30/crackerjack/crackerjack.py +195 -0
  20. crackerjack-0.7.30/crackerjack/pyproject.toml +144 -0
  21. crackerjack-0.7.30/pyproject.toml +144 -0
  22. crackerjack-0.3.3/crackerjack/.crackerjack-config.yaml +0 -0
  23. crackerjack-0.3.3/crackerjack/.pyanalyze-report.json +0 -92
  24. crackerjack-0.3.3/crackerjack/.pyanalyze-report.md +0 -168
  25. crackerjack-0.3.3/crackerjack/crackerjack.py +0 -149
  26. crackerjack-0.3.3/crackerjack/pyproject.toml +0 -93
  27. crackerjack-0.3.3/pyproject.toml +0 -112
  28. {crackerjack-0.3.3 → crackerjack-0.7.30}/LICENSE +0 -0
  29. {crackerjack-0.3.3 → crackerjack-0.7.30}/crackerjack/.libcst.codemod.yaml +0 -0
  30. {crackerjack-0.3.3 → crackerjack-0.7.30}/crackerjack/.ruff_cache/.gitignore +0 -0
  31. {crackerjack-0.3.3 → crackerjack-0.7.30}/crackerjack/.ruff_cache/CACHEDIR.TAG +0 -0
  32. {crackerjack-0.3.3 → crackerjack-0.7.30}/crackerjack/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: crackerjack
3
- Version: 0.3.3
2
+ Name: Crackerjack
3
+ Version: 0.7.30
4
4
  Summary: Crackerjack code style
5
5
  Keywords: black ruff mypy creosote refurb
6
6
  Home-page: https://github.com/lesleslie/crackerjack
@@ -10,27 +10,39 @@ License: BSD-3-Clause
10
10
  Classifier: Environment :: Console
11
11
  Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: Python
13
- Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Software Development :: Quality Assurance
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Classifier: Topic :: Utilities
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: License :: OSI Approved :: BSD License
21
+ Classifier: Typing :: Typed
14
22
  Project-URL: Homepage, https://github.com/lesleslie/crackerjack
15
23
  Project-URL: Documentation, https://github.com/lesleslie/crackerjack
16
24
  Project-URL: Repository, https://github.com/lesleslie/crackerjack
17
- Requires-Python: >=3.11
18
- Requires-Dist: click>=8.1.3
19
- Requires-Dist: aiopath>=0.6.11
20
- Requires-Dist: aioconsole>=0.6.1
21
- Requires-Dist: pydantic>=2.0b2
25
+ Requires-Python: >=3.12
26
+ Requires-Dist: click>=8.1.7
27
+ Requires-Dist: aioconsole>=0.7.0
22
28
  Requires-Dist: inflection>=0.5.1
23
- Requires-Dist: acb>=0.1.8
24
- Requires-Dist: tomli-w>=1.0.0
25
- Requires-Dist: pdm-bump>=0.7.0
29
+ Requires-Dist: autotyping>=23.3.0
30
+ Requires-Dist: pre-commit>=3.6.0
31
+ Requires-Dist: pytest>=7.4.3
32
+ Requires-Dist: pydantic>=2.5.3
33
+ Requires-Dist: aiopath>=0.7.7
34
+ Requires-Dist: acb>=0.4.0
35
+ Requires-Dist: pdm-bump>=0.7.3
36
+ Requires-Dist: pdm>=2.12.3
26
37
  Description-Content-Type: text/markdown
27
38
 
28
39
  # Crackerjack Python
29
40
 
30
- [![Python: 3.11](https://img.shields.io/badge/python-3.11%2B-blue)](https://docs.python.org/3/)
41
+ [![Python: 3.12](https://img.shields.io/badge/python-3.12%2B-blue)](https://docs.python.org/3/)
31
42
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
32
43
  [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
33
44
  [![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
45
+ [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
34
46
  [![Code style: crackerjack](https://img.shields.io/badge/code%20style-crackerjack-000042)](https://github.com/lesleslie/crackerjack)
35
47
 
36
48
  Crackerjack is a python coding style which uses a minimalist approach to produce elegant, easy to read, code.
@@ -80,22 +92,21 @@ This package:
80
92
 
81
93
  - streamlines and standardizes code style across numerous packages
82
94
 
83
- - removes pipenv, poetry, and hatch build, dependency management, and virtual environment
84
- management packages and replaces them with PDM using PEP-582 (work in progress)
85
-
86
95
  - installs, or updates, a project's pre-commit tools as well as .gitignore & other config files
87
96
  to comply with evolving crackerjack standards
88
97
 
89
98
  - runs the following pre-commit hooks (in order):
90
- * various core pre-commit hooks
91
- * [black](https://github.com/ambv/black)
92
- * ruff
93
- * creosote
94
- * flynt
95
- * pyanalyze
96
- * autotyping
97
- * refurb
98
- * pyright
99
+ * [pdm-lock-check](https://github.com/pdm-project/pdm)
100
+ * various core [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks)
101
+ * [black](https://github.com/psf/black)
102
+ * [ruff](https://github.com/charliermarsh/ruff-pre-commit)
103
+ * [creosote](https://github.com/fredrikaverpil/creosote)
104
+ * [flynt](https://github.com/ikamensh/flynt/)
105
+ * [codespell](https://github.com/codespell-project/codespell)
106
+ * [autotyping](https://github.com/JelleZijlstra/autotyping)
107
+ * [refurb](https://github.com/dosisod/refurb)
108
+ * [bandit](https://github.com/PyCQA/bandit)
109
+ * [pyright](https://github.com/RobertCraigie/pyright-python)
99
110
  * ruff (again for sanity checking)
100
111
  * black (again for sanity checking)
101
112
 
@@ -126,11 +137,9 @@ This package:
126
137
 
127
138
  - functions that deal with path operations should get passed AsyncPaths or Paths - not strings
128
139
 
129
- - if a class can be a dataclasses.dataclass, pydantic.BaseModel, or msgspec.Struct it should be
130
-
131
140
  - force single line imports (will support isort Vertical Hanging Indent when ruff does)
132
141
 
133
- - use PDM and PEP-582 for dependency management and package building/publishing
142
+ - use PDM and PEP-582(proposed) for dependency management and package building/publishing
134
143
 
135
144
  - use pdoc and mkdocs for producing documentation
136
145
 
@@ -1,9 +1,10 @@
1
1
  # Crackerjack Python
2
2
 
3
- [![Python: 3.11](https://img.shields.io/badge/python-3.11%2B-blue)](https://docs.python.org/3/)
3
+ [![Python: 3.12](https://img.shields.io/badge/python-3.12%2B-blue)](https://docs.python.org/3/)
4
4
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
5
5
  [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
6
6
  [![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
7
+ [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
7
8
  [![Code style: crackerjack](https://img.shields.io/badge/code%20style-crackerjack-000042)](https://github.com/lesleslie/crackerjack)
8
9
 
9
10
  Crackerjack is a python coding style which uses a minimalist approach to produce elegant, easy to read, code.
@@ -53,22 +54,21 @@ This package:
53
54
 
54
55
  - streamlines and standardizes code style across numerous packages
55
56
 
56
- - removes pipenv, poetry, and hatch build, dependency management, and virtual environment
57
- management packages and replaces them with PDM using PEP-582 (work in progress)
58
-
59
57
  - installs, or updates, a project's pre-commit tools as well as .gitignore & other config files
60
58
  to comply with evolving crackerjack standards
61
59
 
62
60
  - runs the following pre-commit hooks (in order):
63
- * various core pre-commit hooks
64
- * [black](https://github.com/ambv/black)
65
- * ruff
66
- * creosote
67
- * flynt
68
- * pyanalyze
69
- * autotyping
70
- * refurb
71
- * pyright
61
+ * [pdm-lock-check](https://github.com/pdm-project/pdm)
62
+ * various core [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks)
63
+ * [black](https://github.com/psf/black)
64
+ * [ruff](https://github.com/charliermarsh/ruff-pre-commit)
65
+ * [creosote](https://github.com/fredrikaverpil/creosote)
66
+ * [flynt](https://github.com/ikamensh/flynt/)
67
+ * [codespell](https://github.com/codespell-project/codespell)
68
+ * [autotyping](https://github.com/JelleZijlstra/autotyping)
69
+ * [refurb](https://github.com/dosisod/refurb)
70
+ * [bandit](https://github.com/PyCQA/bandit)
71
+ * [pyright](https://github.com/RobertCraigie/pyright-python)
72
72
  * ruff (again for sanity checking)
73
73
  * black (again for sanity checking)
74
74
 
@@ -99,11 +99,9 @@ This package:
99
99
 
100
100
  - functions that deal with path operations should get passed AsyncPaths or Paths - not strings
101
101
 
102
- - if a class can be a dataclasses.dataclass, pydantic.BaseModel, or msgspec.Struct it should be
103
-
104
102
  - force single line imports (will support isort Vertical Hanging Indent when ruff does)
105
103
 
106
- - use PDM and PEP-582 for dependency management and package building/publishing
104
+ - use PDM and PEP-582(proposed) for dependency management and package building/publishing
107
105
 
108
106
  - use pdoc and mkdocs for producing documentation
109
107
 
@@ -7,7 +7,8 @@
7
7
  /dist/
8
8
  /.mypy_cache/
9
9
  /.ruff_cache/
10
- /.crackerjack-config.yaml
11
- /.pyanalyze-report.json
12
- /.pyanalyze-report.md
13
10
  /.pdm-build/
11
+ /tmp/
12
+ /__pycache__/
13
+ /*.pyc
14
+ /.crackerjack.yaml
@@ -1,13 +1,13 @@
1
1
  repos:
2
2
  - repo: https://github.com/pdm-project/pdm
3
- rev: 2.7.4 # a PDM release exposing the hook
3
+ rev: 2.13.2 # a PDM release exposing the hook
4
4
  hooks:
5
5
  - id: pdm-lock-check
6
6
  - repo: https://github.com/pre-commit/pre-commit-hooks
7
- rev: v4.4.0
7
+ rev: v4.5.0
8
8
  hooks:
9
9
  - id: trailing-whitespace
10
- name: trailing-whitspace
10
+ name: trailing-whitespace
11
11
  - id: end-of-file-fixer
12
12
  name: end-of-file-fixer
13
13
  - id: check-yaml
@@ -17,38 +17,27 @@ repos:
17
17
  - id: check-added-large-files
18
18
  name: check-added-large-files
19
19
  - repo: https://github.com/psf/black
20
- rev: '23.3.0'
20
+ rev: '24.3.0'
21
21
  hooks:
22
22
  - id: black
23
- language_version: python3.11
24
23
  - repo: https://github.com/charliermarsh/ruff-pre-commit
25
- rev: v0.0.272
24
+ rev: v0.3.5
26
25
  hooks:
27
26
  - id: ruff
28
27
  - repo: https://github.com/fredrikaverpil/creosote
29
- rev: v2.6.2
28
+ rev: v3.0.0
30
29
  hooks:
31
30
  - id: creosote
32
- args: [--paths, "crackerjack", --exclude-deps, "pdm-bump", "tomli-w"]
33
31
  - repo: https://github.com/ikamensh/flynt/
34
- rev: '0.78'
32
+ rev: '1.0.1'
35
33
  hooks:
36
34
  - id: flynt
37
35
  - repo: https://github.com/codespell-project/codespell
38
- rev: v2.2.4
36
+ rev: v2.2.6
39
37
  hooks:
40
38
  - id: codespell
41
39
  additional_dependencies:
42
40
  - tomli
43
- - repo: local
44
- hooks:
45
- - id: pyanalyze
46
- name: pyanalyze
47
- entry: python -m pyanalyze
48
- language: python
49
- files: \.py$
50
- additional_dependencies:
51
- - pyanalyze>=0.10.1
52
41
  - repo: local
53
42
  hooks:
54
43
  - id: autotyping
@@ -60,7 +49,6 @@ repos:
60
49
  - --show-successes
61
50
  - --include-generated
62
51
  - --guess-common-names
63
- - --pyanalyze-report '.pyanalyze-report.json',
64
52
  - crackerjack
65
53
  types_or: [ python, pyi ]
66
54
  language: python
@@ -69,13 +57,26 @@ repos:
69
57
  - autotyping>=23.3.0
70
58
  - libcst>=0.4.9
71
59
  - repo: https://github.com/dosisod/refurb
72
- rev: v1.16.0
60
+ rev: v2.0.0
73
61
  hooks:
74
62
  - id: refurb
63
+ - repo: https://github.com/PyCQA/bandit
64
+ rev: '1.7.8'
65
+ hooks:
66
+ - id: bandit
67
+ args: ["-c", "pyproject.toml"]
75
68
  - repo: https://github.com/RobertCraigie/pyright-python
76
- rev: v1.1.313
69
+ rev: v1.1.356
77
70
  hooks:
78
71
  - id: pyright
72
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
73
+ rev: v0.3.5
74
+ hooks:
75
+ - id: ruff
76
+ - repo: https://github.com/psf/black
77
+ rev: '24.3.0'
78
+ hooks:
79
+ - id: black
79
80
  # - repo: https://github.com/pdoc3/pdoc
80
81
  # rev: master
81
82
  # hooks:
@@ -86,18 +87,3 @@ repos:
86
87
  # require_serial: true
87
88
  # types: [ python ]
88
89
  # always_run: true
89
- - repo: https://github.com/charliermarsh/ruff-pre-commit
90
- rev: v0.0.272
91
- hooks:
92
- - id: ruff
93
- - repo: https://github.com/psf/black
94
- rev: '23.3.0'
95
- hooks:
96
- - id: black
97
- language_version: python3.11
98
- - repo: https://github.com/pdm-project/pdm
99
- rev: 2.7.4 # a PDM release exposing the hook
100
- hooks:
101
- - id: pdm-export
102
- args: [ '-o', 'requirements.txt', '--without-hashes' ]
103
- files: ^pdm.lock$
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import typing as t
2
3
 
3
4
  from click import command
4
5
  from click import help_option
@@ -12,7 +13,8 @@ class Options(BaseModel):
12
13
  interactive: bool = False
13
14
  doc: bool = False
14
15
  do_not_update_configs: bool = False
15
- publish: str | bool = False
16
+ publish: t.Literal["micro", "minor", "major"] | bool = False
17
+ bump: t.Literal["micro", "minor", "major"] | bool = False
16
18
  verbose: bool = False
17
19
  update_precommit: bool = False
18
20
 
@@ -28,9 +30,19 @@ options = Options()
28
30
  @option("-x", is_flag=True, help="do not update configs")
29
31
  @option("-u", is_flag=True, help="update pre-commit")
30
32
  @option("-v", is_flag=True, help="verbose")
31
- @option("-p", help="publish: -p [micro, minor, major]")
33
+ @option("-p", help="bump version and publish: -p [micro, minor, major]")
34
+ @option("-b", help="bump version: -b [micro, minor, major]")
32
35
  # @option("-f", help="format: -f [module]")
33
- def crackerjack(c: bool, i: bool, d: bool, u: bool, v: bool, x: bool, p: str) -> None:
36
+ def crackerjack(
37
+ c: bool = False,
38
+ i: bool = False,
39
+ d: bool = False,
40
+ u: bool = False,
41
+ v: bool = False,
42
+ x: bool = False,
43
+ p: str | bool = False,
44
+ b: str | bool = False,
45
+ ) -> None:
34
46
  if c:
35
47
  options.commit = c
36
48
  if i:
@@ -43,10 +55,12 @@ def crackerjack(c: bool, i: bool, d: bool, u: bool, v: bool, x: bool, p: str) ->
43
55
  options.do_not_update_configs = x
44
56
  if p in ("micro", "minor", "major"):
45
57
  options.publish = p
58
+ if b in ("micro", "minor", "major"):
59
+ options.bump = b
46
60
  if v:
47
61
  print("-v not currently implemented")
48
62
  options.verbose = v
49
- asyncio.run(crackerjack_it(options))
63
+ asyncio.run(crackerjack_it(options=options))
50
64
 
51
65
 
52
66
  if __name__ == "__main__":
@@ -0,0 +1,195 @@
1
+ import asyncio
2
+ import re
3
+ import sys
4
+ import typing as t
5
+ from pathlib import Path
6
+ from subprocess import run
7
+
8
+ from acb.actions.encode import dump
9
+ from acb.actions.encode import load
10
+ from aioconsole import ainput
11
+ from aioconsole import aprint
12
+ from aiopath import AsyncPath
13
+ from inflection import underscore
14
+ from pydantic import BaseModel
15
+
16
+
17
+ class Config(BaseModel):
18
+ python_version: t.Optional[str] = None
19
+ pre_commit_path: t.Optional[Path] = None
20
+ git_path: t.Optional[Path] = None
21
+ pdm_path: t.Optional[Path] = None
22
+ zshenv_path: t.Optional[Path] = None
23
+
24
+
25
+ class Crackerjack(BaseModel, arbitrary_types_allowed=True):
26
+ our_path: AsyncPath = AsyncPath(__file__).parent
27
+ pkg_path: AsyncPath = AsyncPath(Path.cwd())
28
+ settings_path: AsyncPath = pkg_path / ".crackerjack.yaml"
29
+ pkg_dir: t.Optional[AsyncPath] = None
30
+ pkg_name: str = "crackerjack"
31
+ our_toml: t.Optional[dict[str, t.Any]] = None
32
+ pkg_toml: t.Optional[dict[str, t.Any]] = None
33
+ our_toml_path: t.Optional[AsyncPath] = None
34
+ pkg_toml_path: t.Optional[AsyncPath] = None
35
+ config: t.Optional[Config] = None
36
+
37
+ async def update_pyproject_configs(self) -> None:
38
+ toml_file = "pyproject.toml"
39
+ self.our_toml_path = self.our_path / toml_file
40
+ self.pkg_toml_path = self.pkg_path / toml_file
41
+ if self.pkg_path.stem == "crackerjack":
42
+ await self.our_toml_path.write_text(await self.pkg_toml_path.read_text())
43
+ return
44
+ our_toml_config: t.Any = await load.toml(self.our_toml_path) # type: ignore
45
+ pkg_toml_config: t.Any = await load.toml(self.pkg_toml_path) # type: ignore
46
+ pkg_deps = pkg_toml_config["tool"]["pdm"]["dev-dependencies"]
47
+ for tool, settings in our_toml_config["tool"].items():
48
+ for setting, value in settings.items():
49
+ if isinstance(value, str | list) and "crackerjack" in value:
50
+ if isinstance(value, list):
51
+ value.remove("crackerjack")
52
+ value.append(self.pkg_name)
53
+ else:
54
+ value = value.replace("crackerjack", self.pkg_name)
55
+ settings[setting] = value
56
+ if setting in (
57
+ "exclude-deps",
58
+ "exclude",
59
+ "excluded",
60
+ "skips",
61
+ "ignore",
62
+ ) and isinstance(value, list):
63
+ settings[setting] = set(
64
+ pkg_toml_config["tool"][tool][setting] + value
65
+ )
66
+ pkg_toml_config["tool"][tool] = settings
67
+ pkg_toml_config["tool"]["pdm"]["dev-dependencies"] = pkg_deps
68
+ python_version_pattern = r"\s*W*(\d\.\d*)"
69
+ requires_python = our_toml_config["project"]["requires-python"]
70
+ classifiers = []
71
+ for classifier in pkg_toml_config["project"]["classifiers"]:
72
+ classifier = re.sub(
73
+ python_version_pattern, f" {self.config.python_version}", classifier
74
+ )
75
+ classifiers.append(classifier)
76
+ pkg_toml_config["project"]["classifiers"] = classifiers
77
+ pkg_toml_config["project"]["requires-python"] = requires_python
78
+ await dump.toml(pkg_toml_config, self.pkg_toml_path) # type: ignore
79
+
80
+ async def copy_configs(self) -> None:
81
+ config_files = (
82
+ ".gitignore",
83
+ ".pre-commit-config.yaml",
84
+ ".libcst.codemod.yaml",
85
+ )
86
+ for config in config_files:
87
+ config_path = self.our_path / config
88
+ pkg_config_path = self.pkg_path / config
89
+ await pkg_config_path.touch(exist_ok=True)
90
+ if self.pkg_path.stem == "crackerjack":
91
+ await config_path.write_text(await pkg_config_path.read_text())
92
+ continue
93
+ config_text = await config_path.read_text()
94
+ if config == ".gitignore":
95
+ await pkg_config_path.write_text(
96
+ config_text.replace("crackerjack", self.pkg_name)
97
+ )
98
+ run([str(self.config.git_path), "add", config])
99
+
100
+ async def run_interactive(self, hook: str) -> None:
101
+ success: bool = False
102
+ while not success:
103
+ fail = run(
104
+ [str(self.config.pre_commit_path), "run", hook.lower(), "--all-files"]
105
+ )
106
+ if fail.returncode > 0:
107
+ retry = await ainput(f"\n\n{hook.title()} failed. Retry? (y/N): ")
108
+ await aprint()
109
+ if retry.strip().lower() == "y":
110
+ continue
111
+ sys.exit()
112
+ success = True
113
+
114
+ async def update_pkg_configs(self) -> None:
115
+ await self.copy_configs()
116
+ installed_pkgs = run(
117
+ [str(self.config.pdm_path), "list", "--freeze"],
118
+ capture_output=True,
119
+ text=True,
120
+ ).stdout.splitlines()
121
+ if not len([pkg for pkg in installed_pkgs if "pre-commit" in pkg]):
122
+ print('Installing "pre-commit"...')
123
+ run([str(self.config.pdm_path), "self", "add", "keyring"])
124
+ run([str(self.config.pdm_path), "config", "python.use_venv", "false"])
125
+ run([str(self.config.git_path), "init"])
126
+ run([str(self.config.git_path), "branch", "-m", "main"])
127
+ run([str(self.config.git_path), "add", "pyproject.toml"])
128
+ run([str(self.config.git_path), "add", "pdm.lock"])
129
+ run([str(self.config.pre_commit_path), "install"])
130
+ run(
131
+ [
132
+ str(self.config.git_path),
133
+ "config",
134
+ "advice.addIgnoredFile",
135
+ "false",
136
+ ]
137
+ )
138
+ await self.update_pyproject_configs()
139
+
140
+ async def process(self, options: t.Any) -> None:
141
+ await self.settings_path.touch(exist_ok=True)
142
+ try:
143
+ self.config = Config(**await load.yaml(self.settings_path))
144
+ except TypeError:
145
+ self.config = Config()
146
+ await dump.yaml(self.config.model_dump(), self.settings_path)
147
+ raise SystemExit("\nPlease configure '.crackerjack.yaml' and try again\n")
148
+ imp_dir = self.pkg_path / "__pypackages__" / self.config.python_version / "lib"
149
+ sys.path.append(str(imp_dir))
150
+ self.pkg_name = underscore(self.pkg_path.stem.lower())
151
+ self.pkg_dir = self.pkg_path / self.pkg_name
152
+ await self.pkg_dir.mkdir(exist_ok=True)
153
+ await aprint("\nCrackerjacking...\n")
154
+ if not options.do_not_update_configs:
155
+ await self.update_pkg_configs()
156
+ run([str(self.config.pdm_path), "install"])
157
+ if self.pkg_path.stem == "crackerjack" and options.update_precommit:
158
+ run([str(self.config.pre_commit_path), "autoupdate"])
159
+ if options.interactive:
160
+ for hook in ("refurb", "bandit", "pyright"):
161
+ await self.run_interactive(hook)
162
+ check_all = run([str(self.config.pre_commit_path), "run", "--all-files"])
163
+ if check_all.returncode > 0:
164
+ check_all = run([str(self.config.pre_commit_path), "run", "--all-files"])
165
+ if check_all.returncode > 0:
166
+ await aprint("\n\nPre-commit failed. Please fix errors.\n")
167
+ raise SystemExit()
168
+ for option in (options.publish, options.bump):
169
+ if option:
170
+ run([str(self.config.pdm_path), "bump", option])
171
+ break
172
+ if options.publish:
173
+ run([str(self.config.pdm_path), "publish"])
174
+ if options.commit:
175
+ commit_msg = await ainput("\nCommit message: ")
176
+ run(
177
+ [
178
+ str(self.config.git_path),
179
+ "commit",
180
+ "-m",
181
+ str(commit_msg),
182
+ "--no-verify",
183
+ "--",
184
+ ".",
185
+ ]
186
+ )
187
+ run([str(self.config.git_path), "push", "origin", "main"])
188
+ await aprint("\nCrackerjack complete!\n")
189
+
190
+ async def run(self, options: t.Any) -> None:
191
+ process = asyncio.create_task(self.process(options))
192
+ await process
193
+
194
+
195
+ crackerjack_it = Crackerjack().run