crackerjack 0.3.2__tar.gz → 0.7.29__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.
- {crackerjack-0.3.2 → crackerjack-0.7.29}/PKG-INFO +46 -29
- {crackerjack-0.3.2 → crackerjack-0.7.29}/README.md +23 -17
- {crackerjack-0.3.2 → crackerjack-0.7.29}/crackerjack/.gitignore +4 -3
- {crackerjack-0.3.2 → crackerjack-0.7.29}/crackerjack/.pre-commit-config.yaml +24 -39
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.1.11/3256171999636029978 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.1.14/602324811142551221 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.1.4/10355199064880463147 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.1.6/15140459877605758699 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.1.7/1790508110482614856 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.1.9/17041001205004563469 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.2.0/10047773857155985907 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.2.1/8522267973936635051 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.2.2/18053836298936336950 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.3.0/12548816621480535786 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.3.3/11081883392474770722 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.3.4/676973378459347183 +0 -0
- crackerjack-0.7.29/crackerjack/.ruff_cache/0.3.5/16311176246009842383 +0 -0
- {crackerjack-0.3.2 → crackerjack-0.7.29}/crackerjack/__main__.py +18 -4
- crackerjack-0.7.29/crackerjack/crackerjack.py +195 -0
- crackerjack-0.7.29/crackerjack/pyproject.toml +142 -0
- crackerjack-0.7.29/pyproject.toml +144 -0
- crackerjack-0.3.2/crackerjack/.crackerjack-config.yaml +0 -0
- crackerjack-0.3.2/crackerjack/.pyanalyze-report.json +0 -92
- crackerjack-0.3.2/crackerjack/.pyanalyze-report.md +0 -168
- crackerjack-0.3.2/crackerjack/crackerjack.py +0 -149
- crackerjack-0.3.2/crackerjack/pyproject.toml +0 -93
- crackerjack-0.3.2/pyproject.toml +0 -112
- {crackerjack-0.3.2 → crackerjack-0.7.29}/LICENSE +0 -0
- {crackerjack-0.3.2 → crackerjack-0.7.29}/crackerjack/.libcst.codemod.yaml +0 -0
- {crackerjack-0.3.2 → crackerjack-0.7.29}/crackerjack/.ruff_cache/.gitignore +0 -0
- {crackerjack-0.3.2 → crackerjack-0.7.29}/crackerjack/.ruff_cache/CACHEDIR.TAG +0 -0
- {crackerjack-0.3.2 → crackerjack-0.7.29}/crackerjack/__init__.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Crackerjack code
|
|
2
|
+
Name: Crackerjack
|
|
3
|
+
Version: 0.7.29
|
|
4
|
+
Summary: Crackerjack code style
|
|
5
5
|
Keywords: black ruff mypy creosote refurb
|
|
6
6
|
Home-page: https://github.com/lesleslie/crackerjack
|
|
7
7
|
Author-Email: lesleslie <les@wedgwoodwebworks.com>
|
|
@@ -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.
|
|
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.
|
|
18
|
-
Requires-Dist: click>=8.1.
|
|
19
|
-
Requires-Dist:
|
|
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:
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
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
|
-
[](https://docs.python.org/3/)
|
|
31
42
|
[](https://github.com/ambv/black)
|
|
32
43
|
[](https://microsoft.github.io/pyright/)
|
|
33
44
|
[](https://pdm.fming.dev)
|
|
45
|
+
[](https://github.com/PyCQA/bandit)
|
|
34
46
|
[](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.
|
|
@@ -66,7 +78,8 @@ break upon upgrade, file a bug report or fix it yourself. Simple enough.
|
|
|
66
78
|
|
|
67
79
|
#### ...the Crackerjack solution:
|
|
68
80
|
|
|
69
|
-
Crackerjack uses PDM with PEP-582
|
|
81
|
+
Crackerjack uses PDM with PEP-582 (yes, PEP-582 has been rejected but PDM still supports it and Crackerjack will continue to use it!).
|
|
82
|
+
No more virtualenvs. Update your system python versions as they are released and start
|
|
70
83
|
migrating your code. Crackerjack, and Crackerjack'd packages, should support the latest
|
|
71
84
|
python release's features within 2 month after the release and depend solely on that version. Again, if
|
|
72
85
|
something breaks, file a bug report or, even better, fix it yourself (maybe even learn something new things in the process).
|
|
@@ -79,22 +92,21 @@ This package:
|
|
|
79
92
|
|
|
80
93
|
- streamlines and standardizes code style across numerous packages
|
|
81
94
|
|
|
82
|
-
- removes pipenv, poetry, and hatch build, dependency management, and virtual environment
|
|
83
|
-
management packages and replaces them with PDM using PEP 582 (work in progress)
|
|
84
|
-
|
|
85
95
|
- installs, or updates, a project's pre-commit tools as well as .gitignore & other config files
|
|
86
96
|
to comply with evolving crackerjack standards
|
|
87
97
|
|
|
88
98
|
- runs the following pre-commit hooks (in order):
|
|
89
|
-
*
|
|
90
|
-
* [
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
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)
|
|
98
110
|
* ruff (again for sanity checking)
|
|
99
111
|
* black (again for sanity checking)
|
|
100
112
|
|
|
@@ -118,16 +130,16 @@ This package:
|
|
|
118
130
|
|
|
119
131
|
- use aiopath.AsyncPath or pathlib.Path not os.path
|
|
120
132
|
|
|
133
|
+
- import typing as t
|
|
134
|
+
|
|
121
135
|
- do not capitalize all letters in configuration settings or constants (we diverge from PEP-8 here
|
|
122
136
|
for not other reason than it looks ugly)
|
|
123
137
|
|
|
124
138
|
- functions that deal with path operations should get passed AsyncPaths or Paths - not strings
|
|
125
139
|
|
|
126
|
-
- if a class can be a dataclasses.dataclass, pydantic.BaseModel, or msgspec.Struct it should be
|
|
127
|
-
|
|
128
140
|
- force single line imports (will support isort Vertical Hanging Indent when ruff does)
|
|
129
141
|
|
|
130
|
-
- use PDM and PEP
|
|
142
|
+
- use PDM and PEP-582(proposed) for dependency management and package building/publishing
|
|
131
143
|
|
|
132
144
|
- use pdoc and mkdocs for producing documentation
|
|
133
145
|
|
|
@@ -171,6 +183,11 @@ project version for you. The options are 'micro', 'minor', and 'major'.
|
|
|
171
183
|
Put the -c option at the end and commit the bumped version to your git
|
|
172
184
|
repository at the same time.
|
|
173
185
|
|
|
186
|
+
### **Contributing**
|
|
187
|
+
|
|
188
|
+
Crackerjack is currently an evolving standard. If you like the idea, but don't like certain things about it, or
|
|
189
|
+
would like new features added, let me know in Discussions, Issues, or email me.
|
|
190
|
+
|
|
174
191
|
### **License**
|
|
175
192
|
|
|
176
193
|
BSD-3-Clause
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Crackerjack Python
|
|
2
2
|
|
|
3
|
-
[](https://docs.python.org/3/)
|
|
4
4
|
[](https://github.com/ambv/black)
|
|
5
5
|
[](https://microsoft.github.io/pyright/)
|
|
6
6
|
[](https://pdm.fming.dev)
|
|
7
|
+
[](https://github.com/PyCQA/bandit)
|
|
7
8
|
[](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.
|
|
@@ -39,7 +40,8 @@ break upon upgrade, file a bug report or fix it yourself. Simple enough.
|
|
|
39
40
|
|
|
40
41
|
#### ...the Crackerjack solution:
|
|
41
42
|
|
|
42
|
-
Crackerjack uses PDM with PEP-582
|
|
43
|
+
Crackerjack uses PDM with PEP-582 (yes, PEP-582 has been rejected but PDM still supports it and Crackerjack will continue to use it!).
|
|
44
|
+
No more virtualenvs. Update your system python versions as they are released and start
|
|
43
45
|
migrating your code. Crackerjack, and Crackerjack'd packages, should support the latest
|
|
44
46
|
python release's features within 2 month after the release and depend solely on that version. Again, if
|
|
45
47
|
something breaks, file a bug report or, even better, fix it yourself (maybe even learn something new things in the process).
|
|
@@ -52,22 +54,21 @@ This package:
|
|
|
52
54
|
|
|
53
55
|
- streamlines and standardizes code style across numerous packages
|
|
54
56
|
|
|
55
|
-
- removes pipenv, poetry, and hatch build, dependency management, and virtual environment
|
|
56
|
-
management packages and replaces them with PDM using PEP 582 (work in progress)
|
|
57
|
-
|
|
58
57
|
- installs, or updates, a project's pre-commit tools as well as .gitignore & other config files
|
|
59
58
|
to comply with evolving crackerjack standards
|
|
60
59
|
|
|
61
60
|
- runs the following pre-commit hooks (in order):
|
|
62
|
-
*
|
|
63
|
-
* [
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
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)
|
|
71
72
|
* ruff (again for sanity checking)
|
|
72
73
|
* black (again for sanity checking)
|
|
73
74
|
|
|
@@ -91,16 +92,16 @@ This package:
|
|
|
91
92
|
|
|
92
93
|
- use aiopath.AsyncPath or pathlib.Path not os.path
|
|
93
94
|
|
|
95
|
+
- import typing as t
|
|
96
|
+
|
|
94
97
|
- do not capitalize all letters in configuration settings or constants (we diverge from PEP-8 here
|
|
95
98
|
for not other reason than it looks ugly)
|
|
96
99
|
|
|
97
100
|
- functions that deal with path operations should get passed AsyncPaths or Paths - not strings
|
|
98
101
|
|
|
99
|
-
- if a class can be a dataclasses.dataclass, pydantic.BaseModel, or msgspec.Struct it should be
|
|
100
|
-
|
|
101
102
|
- force single line imports (will support isort Vertical Hanging Indent when ruff does)
|
|
102
103
|
|
|
103
|
-
- use PDM and PEP
|
|
104
|
+
- use PDM and PEP-582(proposed) for dependency management and package building/publishing
|
|
104
105
|
|
|
105
106
|
- use pdoc and mkdocs for producing documentation
|
|
106
107
|
|
|
@@ -144,6 +145,11 @@ project version for you. The options are 'micro', 'minor', and 'major'.
|
|
|
144
145
|
Put the -c option at the end and commit the bumped version to your git
|
|
145
146
|
repository at the same time.
|
|
146
147
|
|
|
148
|
+
### **Contributing**
|
|
149
|
+
|
|
150
|
+
Crackerjack is currently an evolving standard. If you like the idea, but don't like certain things about it, or
|
|
151
|
+
would like new features added, let me know in Discussions, Issues, or email me.
|
|
152
|
+
|
|
147
153
|
### **License**
|
|
148
154
|
|
|
149
155
|
BSD-3-Clause
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
repos:
|
|
2
2
|
- repo: https://github.com/pdm-project/pdm
|
|
3
|
-
rev: 2.
|
|
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.
|
|
7
|
+
rev: v4.5.0
|
|
8
8
|
hooks:
|
|
9
9
|
- id: trailing-whitespace
|
|
10
|
-
name: trailing-
|
|
10
|
+
name: trailing-whitespace
|
|
11
11
|
- id: end-of-file-fixer
|
|
12
12
|
name: end-of-file-fixer
|
|
13
13
|
- id: check-yaml
|
|
@@ -17,39 +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: '
|
|
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.
|
|
24
|
+
rev: v0.3.5
|
|
26
25
|
hooks:
|
|
27
26
|
- id: ruff
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
rev: v2.7.0
|
|
27
|
+
- repo: https://github.com/fredrikaverpil/creosote
|
|
28
|
+
rev: v3.0.0
|
|
31
29
|
hooks:
|
|
32
30
|
- id: creosote
|
|
33
|
-
args: [--paths, "crackerjack", --exclude-deps, "pdm-bump", "tomli-w", "--pep582"]
|
|
34
31
|
- repo: https://github.com/ikamensh/flynt/
|
|
35
|
-
rev: '0.
|
|
32
|
+
rev: '1.0.1'
|
|
36
33
|
hooks:
|
|
37
34
|
- id: flynt
|
|
38
35
|
- repo: https://github.com/codespell-project/codespell
|
|
39
|
-
rev: v2.2.
|
|
36
|
+
rev: v2.2.6
|
|
40
37
|
hooks:
|
|
41
38
|
- id: codespell
|
|
42
39
|
additional_dependencies:
|
|
43
40
|
- tomli
|
|
44
|
-
- repo: local
|
|
45
|
-
hooks:
|
|
46
|
-
- id: pyanalyze
|
|
47
|
-
name: pyanalyze
|
|
48
|
-
entry: python -m pyanalyze
|
|
49
|
-
language: python
|
|
50
|
-
files: \.py$
|
|
51
|
-
additional_dependencies:
|
|
52
|
-
- pyanalyze>=0.10.1
|
|
53
41
|
- repo: local
|
|
54
42
|
hooks:
|
|
55
43
|
- id: autotyping
|
|
@@ -61,7 +49,6 @@ repos:
|
|
|
61
49
|
- --show-successes
|
|
62
50
|
- --include-generated
|
|
63
51
|
- --guess-common-names
|
|
64
|
-
- --pyanalyze-report '.pyanalyze-report.json',
|
|
65
52
|
- crackerjack
|
|
66
53
|
types_or: [ python, pyi ]
|
|
67
54
|
language: python
|
|
@@ -70,13 +57,26 @@ repos:
|
|
|
70
57
|
- autotyping>=23.3.0
|
|
71
58
|
- libcst>=0.4.9
|
|
72
59
|
- repo: https://github.com/dosisod/refurb
|
|
73
|
-
rev:
|
|
60
|
+
rev: v2.0.0
|
|
74
61
|
hooks:
|
|
75
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"]
|
|
76
68
|
- repo: https://github.com/RobertCraigie/pyright-python
|
|
77
|
-
rev: v1.1.
|
|
69
|
+
rev: v1.1.356
|
|
78
70
|
hooks:
|
|
79
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
|
|
80
80
|
# - repo: https://github.com/pdoc3/pdoc
|
|
81
81
|
# rev: master
|
|
82
82
|
# hooks:
|
|
@@ -87,18 +87,3 @@ repos:
|
|
|
87
87
|
# require_serial: true
|
|
88
88
|
# types: [ python ]
|
|
89
89
|
# always_run: true
|
|
90
|
-
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
91
|
-
rev: v0.0.272
|
|
92
|
-
hooks:
|
|
93
|
-
- id: ruff
|
|
94
|
-
- repo: https://github.com/psf/black
|
|
95
|
-
rev: '23.3.0'
|
|
96
|
-
hooks:
|
|
97
|
-
- id: black
|
|
98
|
-
language_version: python3.11
|
|
99
|
-
- repo: https://github.com/pdm-project/pdm
|
|
100
|
-
rev: 2.7.4 # a PDM release exposing the hook
|
|
101
|
-
hooks:
|
|
102
|
-
- id: pdm-export
|
|
103
|
-
args: [ '-o', 'requirements.txt', '--without-hashes' ]
|
|
104
|
-
files: ^pdm.lock$
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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:
|
|
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(
|
|
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
|