crackerjack 0.11.4__tar.gz → 0.12.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crackerjack-0.12.0/PKG-INFO +225 -0
- crackerjack-0.12.0/README.md +186 -0
- crackerjack-0.12.0/crackerjack/.coverage +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.gitignore +2 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.pre-commit-config.yaml +3 -3
- crackerjack-0.12.0/crackerjack/.pytest_cache/.gitignore +2 -0
- crackerjack-0.12.0/crackerjack/.pytest_cache/CACHEDIR.TAG +4 -0
- crackerjack-0.12.0/crackerjack/.pytest_cache/README.md +8 -0
- crackerjack-0.12.0/crackerjack/.pytest_cache/v/cache/nodeids +1 -0
- crackerjack-0.12.0/crackerjack/.pytest_cache/v/cache/stepwise +1 -0
- crackerjack-0.12.0/crackerjack/.ruff_cache/0.9.10/12813592349865671909 +0 -0
- crackerjack-0.12.0/crackerjack/.ruff_cache/0.9.9/12813592349865671909 +0 -0
- crackerjack-0.12.0/crackerjack/.ruff_cache/0.9.9/8843823720003377982 +0 -0
- crackerjack-0.12.0/crackerjack/__init__.py +4 -0
- crackerjack-0.12.0/crackerjack/__main__.py +119 -0
- crackerjack-0.12.0/crackerjack/crackerjack.py +437 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/pyproject.toml +7 -5
- {crackerjack-0.11.4 → crackerjack-0.12.0}/pyproject.toml +9 -5
- crackerjack-0.12.0/tests/data/init.py +2 -0
- crackerjack-0.12.0/tests/test_crackerjack.py +268 -0
- crackerjack-0.12.0/tests/test_main.py +239 -0
- crackerjack-0.11.4/PKG-INFO +0 -164
- crackerjack-0.11.4/README.md +0 -126
- crackerjack-0.11.4/crackerjack/.ruff_cache/0.9.9/12813592349865671909 +0 -0
- crackerjack-0.11.4/crackerjack/__init__.py +0 -7
- crackerjack-0.11.4/crackerjack/__main__.py +0 -64
- crackerjack-0.11.4/crackerjack/crackerjack.py +0 -161
- crackerjack-0.11.4/tests/test_crackerjack.py +0 -174
- crackerjack-0.11.4/tests/test_main.py +0 -142
- {crackerjack-0.11.4 → crackerjack-0.12.0}/LICENSE +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.libcst.codemod.yaml +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.pdm.toml +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/.gitignore +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.1.11/3256171999636029978 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.1.14/602324811142551221 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.1.4/10355199064880463147 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.1.6/15140459877605758699 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.1.7/1790508110482614856 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.1.9/17041001205004563469 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.2.0/10047773857155985907 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.2.1/8522267973936635051 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.2.2/18053836298936336950 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.3.0/12548816621480535786 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.3.3/11081883392474770722 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.3.4/676973378459347183 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.3.5/16311176246009842383 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.5.7/1493622539551733492 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.5.7/6231957614044513175 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.5.7/9932762556785938009 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.6.0/11982804814124138945 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.6.0/12055761203849489982 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.6.2/1206147804896221174 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.6.4/1206147804896221174 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.6.5/1206147804896221174 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.6.7/3657366982708166874 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.6.9/285614542852677309 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.7.1/1024065805990144819 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.7.1/285614542852677309 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.7.3/16061516852537040135 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.8.4/16354268377385700367 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/0.9.3/13948373885254993391 +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/crackerjack/.ruff_cache/CACHEDIR.TAG +0 -0
- {crackerjack-0.11.4 → crackerjack-0.12.0}/tests/__init__.py +0 -0
@@ -0,0 +1,225 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: crackerjack
|
3
|
+
Version: 0.12.0
|
4
|
+
Summary: Default template for PDM package
|
5
|
+
Keywords: black,ruff,mypy,creosote,refurb
|
6
|
+
Author-Email: lesleslie <les@wedgwoodwebworks.com>
|
7
|
+
Maintainer-Email: lesleslie <les@wedgwoodwebworks.com>
|
8
|
+
License: BSD-3-CLAUSE
|
9
|
+
Classifier: Environment :: Console
|
10
|
+
Classifier: Operating System :: POSIX
|
11
|
+
Classifier: Programming Language :: Python
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
16
|
+
Classifier: Topic :: Software Development :: Testing
|
17
|
+
Classifier: Topic :: Utilities
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
19
|
+
Classifier: License :: OSI Approved :: BSD License
|
20
|
+
Classifier: Typing :: Typed
|
21
|
+
Project-URL: homepage, https://github.com/lesleslie/crackerjack
|
22
|
+
Project-URL: documentation, https://github.com/lesleslie/crackerjack
|
23
|
+
Project-URL: repository, https://github.com/lesleslie/crackerjack
|
24
|
+
Requires-Python: >=3.13
|
25
|
+
Requires-Dist: autotyping>=24.9.0
|
26
|
+
Requires-Dist: pre-commit>=4.1.0
|
27
|
+
Requires-Dist: pytest>=8.3.5
|
28
|
+
Requires-Dist: pydantic>=2.10.6
|
29
|
+
Requires-Dist: pdm-bump>=0.9.10
|
30
|
+
Requires-Dist: pdm>=2.22.4
|
31
|
+
Requires-Dist: uv>=0.6.5
|
32
|
+
Requires-Dist: pytest-cov>=6.0.0
|
33
|
+
Requires-Dist: pytest-mock>=3.14.0
|
34
|
+
Requires-Dist: tomli-w>=1.2.0
|
35
|
+
Requires-Dist: pytest-asyncio>=0.25.3
|
36
|
+
Requires-Dist: rich>=13.9.4
|
37
|
+
Requires-Dist: typer>=0.15.2
|
38
|
+
Description-Content-Type: text/markdown
|
39
|
+
|
40
|
+
# Crackerjack: Elevate Your Python Development
|
41
|
+
|
42
|
+
[](https://github.com/lesleslie/crackerjack)
|
43
|
+
[](https://www.python.org/downloads/)
|
44
|
+
[](https://github.com/astral-sh/ruff)
|
45
|
+
[](https://github.com/astral-sh/uv)
|
46
|
+
[](https://microsoft.github.io/pyright/)
|
47
|
+
[](https://pdm.fming.dev)
|
48
|
+
[](https://github.com/PyCQA/bandit)
|
49
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
50
|
+
|
51
|
+
**Crackerjack** (`ˈkra-kər-ˌjak`): *a person or thing of marked excellence.*
|
52
|
+
|
53
|
+
Crackerjack is an opinionated Python project management tool designed to help you create, maintain, and publish high-quality Python projects with ease. It combines best-in-class tools and a streamlined workflow to ensure code quality, consistency, and reliability.
|
54
|
+
|
55
|
+
## The Crackerjack Philosophy
|
56
|
+
|
57
|
+
Crackerjack is built on the following core principles:
|
58
|
+
|
59
|
+
- **Code Clarity:** Code should be easy to read, understand, and maintain.
|
60
|
+
- **Automation:** Tedious tasks should be automated, allowing developers to focus on solving problems.
|
61
|
+
- **Consistency:** Code style, formatting, and project structure should be consistent across projects.
|
62
|
+
- **Reliability:** Tests are essential, and code should be checked rigorously.
|
63
|
+
- **Tool Integration:** Leverage powerful existing tools instead of reinventing the wheel.
|
64
|
+
- **Static Typing:** Static typing is essential for all development.
|
65
|
+
|
66
|
+
## Key Features
|
67
|
+
|
68
|
+
Crackerjack provides:
|
69
|
+
|
70
|
+
- **Effortless Project Setup:** Initializes new Python projects with a standard directory structure, `pyproject.toml`, and essential configuration files.
|
71
|
+
- **PDM Integration:** Manages dependencies and virtual environments using [PDM](https://pdm.fming.dev/) (with [uv](https://github.com/astral-sh/uv) enabled for speed).
|
72
|
+
- **Automated Code Cleaning:** Removes unnecessary docstrings, line comments, and trailing whitespace.
|
73
|
+
- **Consistent Code Formatting:** Enforces a consistent style using [Ruff](https://github.com/astral-sh/ruff), the lightning-fast Python linter and formatter.
|
74
|
+
- **Comprehensive Pre-commit Hooks:** Installs and manages a robust suite of pre-commit hooks to ensure code quality (see the "Pre-commit Hooks" section below).
|
75
|
+
- **Interactive Checks:** Supports interactive pre-commit hooks (like `refurb`, `bandit`, and `pyright`) to allow you to fix issues in real-time.
|
76
|
+
- **Built-in Testing:** Automatically runs tests using `pytest`.
|
77
|
+
- **Easy Version Bumping:** Provides commands to bump the project version (micro, minor, or major).
|
78
|
+
- **Simplified Publishing:** Automates publishing to PyPI via PDM.
|
79
|
+
- **Commit and Push:** Commits and pushes your changes.
|
80
|
+
|
81
|
+
## Pre-commit Hooks
|
82
|
+
|
83
|
+
Crackerjack automatically installs and manages these pre-commit hooks:
|
84
|
+
|
85
|
+
1. **pdm-lock-check:** Ensures the `pdm.lock` file is up to date.
|
86
|
+
2. **Core pre-commit-hooks:** Essential hooks from [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks) (e.g., `trailing-whitespace`, `end-of-file-fixer`).
|
87
|
+
3. **Ruff:** [Ruff](https://github.com/astral-sh/ruff) for linting, code formatting, and general code style enforcement.
|
88
|
+
4. **Vulture:** [Vulture](https://github.com/jendrikseipp/vulture) to identify dead code.
|
89
|
+
5. **Creosote:** [Creosote](https://github.com/fredrikaverpil/creosote) to detect unused dependencies.
|
90
|
+
6. **Flynt:** [Flynt](https://github.com/ikamensh/flynt/) for converting string formatting to f-strings.
|
91
|
+
7. **Codespell:** [Codespell](https://github.com/codespell-project/codespell) for correcting typos in the code.
|
92
|
+
8. **Autotyping:** [Autotyping](https://github.com/JelleZijlstra/autotyping) for adding type hints.
|
93
|
+
9. **Refurb:** [Refurb](https://github.com/dosisod/refurb) to suggest code improvements.
|
94
|
+
10. **Bandit:** [Bandit](https://github.com/PyCQA/bandit) to identify potential security vulnerabilities.
|
95
|
+
11. **Pyright:** [Pyright](https://github.com/RobertCraigie/pyright-python) for static type checking.
|
96
|
+
12. **Ruff (again):** A final Ruff pass to ensure all changes comply with the enforced style.
|
97
|
+
|
98
|
+
## The Crackerjack Style Guide
|
99
|
+
|
100
|
+
Crackerjack projects adhere to these guidelines:
|
101
|
+
|
102
|
+
- **Static Typing:** Use type hints consistently throughout your code.
|
103
|
+
- **Explicit Naming:** Choose clear, descriptive names for classes, functions, variables, and other identifiers.
|
104
|
+
- **Markdown for Documentation:** Use Markdown (`.md`) for all documentation, including docstrings, READMEs, etc.
|
105
|
+
- **Pathlib:** Use `pathlib.Path` for handling file and directory paths instead of `os.path`.
|
106
|
+
- **Consistent Imports:** Use `import typing as t` for type hinting.
|
107
|
+
- **Constants and Config:** Do not use all-caps for constants or configuration settings.
|
108
|
+
- **Path Parameters:** Functions that handle file operations should accept `pathlib.Path` objects as parameters.
|
109
|
+
- **Dependency Management:** Use PDM for dependency management, package building, and publishing.
|
110
|
+
- **Testing:** Use pytest as your testing framework.
|
111
|
+
- **Python Version:** Crackerjack projects support the latest Python versions.
|
112
|
+
- **Clear Code:** Avoid overly complex code.
|
113
|
+
- **Modular:** Functions should do one thing well.
|
114
|
+
|
115
|
+
## Installation
|
116
|
+
|
117
|
+
1. **Python:** Ensure you have Python 3.13 installed.
|
118
|
+
2. **PDM:** Install [PDM](https://pdm.fming.dev/) using `pipx`:
|
119
|
+
|
120
|
+
```
|
121
|
+
pipx install pdm
|
122
|
+
```
|
123
|
+
|
124
|
+
3. **Crackerjack:** Install Crackerjack and initialize in your project root using:
|
125
|
+
```
|
126
|
+
pip install crackerjack
|
127
|
+
cd your_project_root
|
128
|
+
python -m crackerjack
|
129
|
+
```
|
130
|
+
|
131
|
+
## Usage
|
132
|
+
|
133
|
+
Run Crackerjack from the root of your Python project using:
|
134
|
+
|
135
|
+
python -m crackerjack
|
136
|
+
|
137
|
+
|
138
|
+
### Command-Line Options
|
139
|
+
|
140
|
+
- `-c`, `--commit`: Commit changes to Git.
|
141
|
+
- `-i`, `--interactive`: Run pre-commit hooks interactively when possible.
|
142
|
+
- `-n`, `--no-config-updates`: Skip updating configuration files (e.g., `pyproject.toml`).
|
143
|
+
- `-u`, `--update-precommit`: Update pre-commit hooks to the latest versions.
|
144
|
+
- `-v`, `--verbose`: Enable verbose output.
|
145
|
+
- `-p`, `--publish <micro|minor|major>`: Bump the project version and publish to PyPI using PDM.
|
146
|
+
- `-b`, `--bump <micro|minor|major>`: Bump the project version without publishing.
|
147
|
+
- `-x`, `--clean`: Clean code by removing docstrings, line comments, and extra whitespace.
|
148
|
+
- `-t`, `--test`: Run tests using `pytest`.
|
149
|
+
- `-h`, `--help`: Display help.
|
150
|
+
|
151
|
+
### Example Workflows
|
152
|
+
|
153
|
+
- **Run checks, bump version, publish, then commit:**
|
154
|
+
```
|
155
|
+
python -m crackerjack -p minor -c
|
156
|
+
```
|
157
|
+
|
158
|
+
- **Clean code, run checks, run tests, then commit:**
|
159
|
+
````
|
160
|
+
python -m crackerjack -c -x -t
|
161
|
+
```
|
162
|
+
|
163
|
+
- **Run checks skipping config updates:**
|
164
|
+
```
|
165
|
+
python -m crackerjack -n
|
166
|
+
```
|
167
|
+
|
168
|
+
- **Bump the version and publish to PyPI:**
|
169
|
+
```
|
170
|
+
python -m crackerjack -p micro
|
171
|
+
```
|
172
|
+
|
173
|
+
- **Bump the version without publishing:**
|
174
|
+
```
|
175
|
+
python -m crackerjack -b major
|
176
|
+
```
|
177
|
+
- **Update pre-commit hooks:**
|
178
|
+
```
|
179
|
+
python -m crackerjack -u
|
180
|
+
```
|
181
|
+
- **Get help:**
|
182
|
+
```
|
183
|
+
python -m crackerjack -h
|
184
|
+
```
|
185
|
+
|
186
|
+
## Contributing
|
187
|
+
|
188
|
+
Crackerjack is an evolving project. Contributions are welcome! Please open a pull request or issue.
|
189
|
+
|
190
|
+
To contribute:
|
191
|
+
|
192
|
+
1. Add Crackerjack as a development dependency to your project:
|
193
|
+
```
|
194
|
+
pdm add -G dev crackerjack
|
195
|
+
```
|
196
|
+
|
197
|
+
2. Run checks and tests before submitting:
|
198
|
+
```
|
199
|
+
python -m crackerjack -x -t
|
200
|
+
```
|
201
|
+
|
202
|
+
This ensures your code meets all quality standards before submission.
|
203
|
+
|
204
|
+
## License
|
205
|
+
|
206
|
+
This project is licensed under the terms of the BSD 3-Clause license.
|
207
|
+
|
208
|
+
## Acknowledgments
|
209
|
+
|
210
|
+
- **PDM:** For excellent dependency and virtual environment management.
|
211
|
+
- **Ruff:** For lightning-fast linting and code formatting.
|
212
|
+
- **pre-commit:** For the robust hook management system.
|
213
|
+
- **pytest:** For the flexible and powerful testing framework.
|
214
|
+
- **uv:** For greatly improving PDM speeds.
|
215
|
+
- **bandit:** For finding security vulnerabilities.
|
216
|
+
- **vulture:** for dead code detection.
|
217
|
+
- **creosote:** For unused dependency detection.
|
218
|
+
- **flynt:** For f-string conversion.
|
219
|
+
- **codespell:** For spelling correction.
|
220
|
+
- **autotyping:** For automatically adding type hints.
|
221
|
+
- **refurb:** For code improvement suggestions.
|
222
|
+
- **pyright:** For static type checking.
|
223
|
+
- **Typer:** For the creation of the CLI.
|
224
|
+
|
225
|
+
---
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# Crackerjack: Elevate Your Python Development
|
2
|
+
|
3
|
+
[](https://github.com/lesleslie/crackerjack)
|
4
|
+
[](https://www.python.org/downloads/)
|
5
|
+
[](https://github.com/astral-sh/ruff)
|
6
|
+
[](https://github.com/astral-sh/uv)
|
7
|
+
[](https://microsoft.github.io/pyright/)
|
8
|
+
[](https://pdm.fming.dev)
|
9
|
+
[](https://github.com/PyCQA/bandit)
|
10
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
11
|
+
|
12
|
+
**Crackerjack** (`ˈkra-kər-ˌjak`): *a person or thing of marked excellence.*
|
13
|
+
|
14
|
+
Crackerjack is an opinionated Python project management tool designed to help you create, maintain, and publish high-quality Python projects with ease. It combines best-in-class tools and a streamlined workflow to ensure code quality, consistency, and reliability.
|
15
|
+
|
16
|
+
## The Crackerjack Philosophy
|
17
|
+
|
18
|
+
Crackerjack is built on the following core principles:
|
19
|
+
|
20
|
+
- **Code Clarity:** Code should be easy to read, understand, and maintain.
|
21
|
+
- **Automation:** Tedious tasks should be automated, allowing developers to focus on solving problems.
|
22
|
+
- **Consistency:** Code style, formatting, and project structure should be consistent across projects.
|
23
|
+
- **Reliability:** Tests are essential, and code should be checked rigorously.
|
24
|
+
- **Tool Integration:** Leverage powerful existing tools instead of reinventing the wheel.
|
25
|
+
- **Static Typing:** Static typing is essential for all development.
|
26
|
+
|
27
|
+
## Key Features
|
28
|
+
|
29
|
+
Crackerjack provides:
|
30
|
+
|
31
|
+
- **Effortless Project Setup:** Initializes new Python projects with a standard directory structure, `pyproject.toml`, and essential configuration files.
|
32
|
+
- **PDM Integration:** Manages dependencies and virtual environments using [PDM](https://pdm.fming.dev/) (with [uv](https://github.com/astral-sh/uv) enabled for speed).
|
33
|
+
- **Automated Code Cleaning:** Removes unnecessary docstrings, line comments, and trailing whitespace.
|
34
|
+
- **Consistent Code Formatting:** Enforces a consistent style using [Ruff](https://github.com/astral-sh/ruff), the lightning-fast Python linter and formatter.
|
35
|
+
- **Comprehensive Pre-commit Hooks:** Installs and manages a robust suite of pre-commit hooks to ensure code quality (see the "Pre-commit Hooks" section below).
|
36
|
+
- **Interactive Checks:** Supports interactive pre-commit hooks (like `refurb`, `bandit`, and `pyright`) to allow you to fix issues in real-time.
|
37
|
+
- **Built-in Testing:** Automatically runs tests using `pytest`.
|
38
|
+
- **Easy Version Bumping:** Provides commands to bump the project version (micro, minor, or major).
|
39
|
+
- **Simplified Publishing:** Automates publishing to PyPI via PDM.
|
40
|
+
- **Commit and Push:** Commits and pushes your changes.
|
41
|
+
|
42
|
+
## Pre-commit Hooks
|
43
|
+
|
44
|
+
Crackerjack automatically installs and manages these pre-commit hooks:
|
45
|
+
|
46
|
+
1. **pdm-lock-check:** Ensures the `pdm.lock` file is up to date.
|
47
|
+
2. **Core pre-commit-hooks:** Essential hooks from [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks) (e.g., `trailing-whitespace`, `end-of-file-fixer`).
|
48
|
+
3. **Ruff:** [Ruff](https://github.com/astral-sh/ruff) for linting, code formatting, and general code style enforcement.
|
49
|
+
4. **Vulture:** [Vulture](https://github.com/jendrikseipp/vulture) to identify dead code.
|
50
|
+
5. **Creosote:** [Creosote](https://github.com/fredrikaverpil/creosote) to detect unused dependencies.
|
51
|
+
6. **Flynt:** [Flynt](https://github.com/ikamensh/flynt/) for converting string formatting to f-strings.
|
52
|
+
7. **Codespell:** [Codespell](https://github.com/codespell-project/codespell) for correcting typos in the code.
|
53
|
+
8. **Autotyping:** [Autotyping](https://github.com/JelleZijlstra/autotyping) for adding type hints.
|
54
|
+
9. **Refurb:** [Refurb](https://github.com/dosisod/refurb) to suggest code improvements.
|
55
|
+
10. **Bandit:** [Bandit](https://github.com/PyCQA/bandit) to identify potential security vulnerabilities.
|
56
|
+
11. **Pyright:** [Pyright](https://github.com/RobertCraigie/pyright-python) for static type checking.
|
57
|
+
12. **Ruff (again):** A final Ruff pass to ensure all changes comply with the enforced style.
|
58
|
+
|
59
|
+
## The Crackerjack Style Guide
|
60
|
+
|
61
|
+
Crackerjack projects adhere to these guidelines:
|
62
|
+
|
63
|
+
- **Static Typing:** Use type hints consistently throughout your code.
|
64
|
+
- **Explicit Naming:** Choose clear, descriptive names for classes, functions, variables, and other identifiers.
|
65
|
+
- **Markdown for Documentation:** Use Markdown (`.md`) for all documentation, including docstrings, READMEs, etc.
|
66
|
+
- **Pathlib:** Use `pathlib.Path` for handling file and directory paths instead of `os.path`.
|
67
|
+
- **Consistent Imports:** Use `import typing as t` for type hinting.
|
68
|
+
- **Constants and Config:** Do not use all-caps for constants or configuration settings.
|
69
|
+
- **Path Parameters:** Functions that handle file operations should accept `pathlib.Path` objects as parameters.
|
70
|
+
- **Dependency Management:** Use PDM for dependency management, package building, and publishing.
|
71
|
+
- **Testing:** Use pytest as your testing framework.
|
72
|
+
- **Python Version:** Crackerjack projects support the latest Python versions.
|
73
|
+
- **Clear Code:** Avoid overly complex code.
|
74
|
+
- **Modular:** Functions should do one thing well.
|
75
|
+
|
76
|
+
## Installation
|
77
|
+
|
78
|
+
1. **Python:** Ensure you have Python 3.13 installed.
|
79
|
+
2. **PDM:** Install [PDM](https://pdm.fming.dev/) using `pipx`:
|
80
|
+
|
81
|
+
```
|
82
|
+
pipx install pdm
|
83
|
+
```
|
84
|
+
|
85
|
+
3. **Crackerjack:** Install Crackerjack and initialize in your project root using:
|
86
|
+
```
|
87
|
+
pip install crackerjack
|
88
|
+
cd your_project_root
|
89
|
+
python -m crackerjack
|
90
|
+
```
|
91
|
+
|
92
|
+
## Usage
|
93
|
+
|
94
|
+
Run Crackerjack from the root of your Python project using:
|
95
|
+
|
96
|
+
python -m crackerjack
|
97
|
+
|
98
|
+
|
99
|
+
### Command-Line Options
|
100
|
+
|
101
|
+
- `-c`, `--commit`: Commit changes to Git.
|
102
|
+
- `-i`, `--interactive`: Run pre-commit hooks interactively when possible.
|
103
|
+
- `-n`, `--no-config-updates`: Skip updating configuration files (e.g., `pyproject.toml`).
|
104
|
+
- `-u`, `--update-precommit`: Update pre-commit hooks to the latest versions.
|
105
|
+
- `-v`, `--verbose`: Enable verbose output.
|
106
|
+
- `-p`, `--publish <micro|minor|major>`: Bump the project version and publish to PyPI using PDM.
|
107
|
+
- `-b`, `--bump <micro|minor|major>`: Bump the project version without publishing.
|
108
|
+
- `-x`, `--clean`: Clean code by removing docstrings, line comments, and extra whitespace.
|
109
|
+
- `-t`, `--test`: Run tests using `pytest`.
|
110
|
+
- `-h`, `--help`: Display help.
|
111
|
+
|
112
|
+
### Example Workflows
|
113
|
+
|
114
|
+
- **Run checks, bump version, publish, then commit:**
|
115
|
+
```
|
116
|
+
python -m crackerjack -p minor -c
|
117
|
+
```
|
118
|
+
|
119
|
+
- **Clean code, run checks, run tests, then commit:**
|
120
|
+
````
|
121
|
+
python -m crackerjack -c -x -t
|
122
|
+
```
|
123
|
+
|
124
|
+
- **Run checks skipping config updates:**
|
125
|
+
```
|
126
|
+
python -m crackerjack -n
|
127
|
+
```
|
128
|
+
|
129
|
+
- **Bump the version and publish to PyPI:**
|
130
|
+
```
|
131
|
+
python -m crackerjack -p micro
|
132
|
+
```
|
133
|
+
|
134
|
+
- **Bump the version without publishing:**
|
135
|
+
```
|
136
|
+
python -m crackerjack -b major
|
137
|
+
```
|
138
|
+
- **Update pre-commit hooks:**
|
139
|
+
```
|
140
|
+
python -m crackerjack -u
|
141
|
+
```
|
142
|
+
- **Get help:**
|
143
|
+
```
|
144
|
+
python -m crackerjack -h
|
145
|
+
```
|
146
|
+
|
147
|
+
## Contributing
|
148
|
+
|
149
|
+
Crackerjack is an evolving project. Contributions are welcome! Please open a pull request or issue.
|
150
|
+
|
151
|
+
To contribute:
|
152
|
+
|
153
|
+
1. Add Crackerjack as a development dependency to your project:
|
154
|
+
```
|
155
|
+
pdm add -G dev crackerjack
|
156
|
+
```
|
157
|
+
|
158
|
+
2. Run checks and tests before submitting:
|
159
|
+
```
|
160
|
+
python -m crackerjack -x -t
|
161
|
+
```
|
162
|
+
|
163
|
+
This ensures your code meets all quality standards before submission.
|
164
|
+
|
165
|
+
## License
|
166
|
+
|
167
|
+
This project is licensed under the terms of the BSD 3-Clause license.
|
168
|
+
|
169
|
+
## Acknowledgments
|
170
|
+
|
171
|
+
- **PDM:** For excellent dependency and virtual environment management.
|
172
|
+
- **Ruff:** For lightning-fast linting and code formatting.
|
173
|
+
- **pre-commit:** For the robust hook management system.
|
174
|
+
- **pytest:** For the flexible and powerful testing framework.
|
175
|
+
- **uv:** For greatly improving PDM speeds.
|
176
|
+
- **bandit:** For finding security vulnerabilities.
|
177
|
+
- **vulture:** for dead code detection.
|
178
|
+
- **creosote:** For unused dependency detection.
|
179
|
+
- **flynt:** For f-string conversion.
|
180
|
+
- **codespell:** For spelling correction.
|
181
|
+
- **autotyping:** For automatically adding type hints.
|
182
|
+
- **refurb:** For code improvement suggestions.
|
183
|
+
- **pyright:** For static type checking.
|
184
|
+
- **Typer:** For the creation of the CLI.
|
185
|
+
|
186
|
+
---
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
repos:
|
2
2
|
- repo: https://github.com/pdm-project/pdm
|
3
|
-
rev: 2.22.
|
3
|
+
rev: 2.22.4 # 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
|
@@ -17,7 +17,7 @@ repos:
|
|
17
17
|
- id: check-added-large-files
|
18
18
|
name: check-added-large-files
|
19
19
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
20
|
-
rev: v0.9.
|
20
|
+
rev: v0.9.10
|
21
21
|
hooks:
|
22
22
|
- id: ruff-format
|
23
23
|
- id: ruff
|
@@ -69,7 +69,7 @@ repos:
|
|
69
69
|
hooks:
|
70
70
|
- id: pyright
|
71
71
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
72
|
-
rev: v0.9.
|
72
|
+
rev: v0.9.10
|
73
73
|
hooks:
|
74
74
|
- id: ruff
|
75
75
|
- id: ruff-format
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# pytest cache directory #
|
2
|
+
|
3
|
+
This directory contains data from the pytest's cache plugin,
|
4
|
+
which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
|
5
|
+
|
6
|
+
**Do not** commit this to version control.
|
7
|
+
|
8
|
+
See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
|
@@ -0,0 +1 @@
|
|
1
|
+
[]
|
@@ -0,0 +1 @@
|
|
1
|
+
[]
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,119 @@
|
|
1
|
+
import typing as t
|
2
|
+
from enum import Enum
|
3
|
+
import typer
|
4
|
+
from pydantic import BaseModel, field_validator
|
5
|
+
from rich.console import Console
|
6
|
+
from crackerjack import crackerjack_it
|
7
|
+
|
8
|
+
console = Console(force_terminal=True)
|
9
|
+
app = typer.Typer(
|
10
|
+
help="Crackerjack: Your Python project setup and style enforcement tool."
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
class BumpOption(str, Enum):
|
15
|
+
micro = "micro"
|
16
|
+
minor = "minor"
|
17
|
+
major = "major"
|
18
|
+
|
19
|
+
def __str__(self) -> str:
|
20
|
+
return self.value
|
21
|
+
|
22
|
+
|
23
|
+
class Options(BaseModel):
|
24
|
+
commit: bool = False
|
25
|
+
interactive: bool = False
|
26
|
+
doc: bool = False
|
27
|
+
no_config_updates: bool = False
|
28
|
+
publish: t.Optional[BumpOption] = None
|
29
|
+
bump: t.Optional[BumpOption] = None
|
30
|
+
verbose: bool = False
|
31
|
+
update_precommit: bool = False
|
32
|
+
clean: bool = False
|
33
|
+
test: bool = False
|
34
|
+
|
35
|
+
@classmethod
|
36
|
+
@field_validator("publish", "bump", mode="before")
|
37
|
+
def validate_bump_options(cls, value: t.Optional[str]) -> t.Optional[BumpOption]:
|
38
|
+
if value is None:
|
39
|
+
return None
|
40
|
+
try:
|
41
|
+
return BumpOption(value.lower())
|
42
|
+
except ValueError:
|
43
|
+
valid_options = ", ".join([o.value for o in BumpOption])
|
44
|
+
raise ValueError(
|
45
|
+
f"Invalid bump option: {value}. Must be one of: {valid_options}"
|
46
|
+
)
|
47
|
+
|
48
|
+
|
49
|
+
cli_options = {
|
50
|
+
"commit": typer.Option(False, "-c", "--commit", help="Commit changes to Git."),
|
51
|
+
"interactive": typer.Option(
|
52
|
+
False, "-i", "--interactive", help="Run pre-commit hooks interactively."
|
53
|
+
),
|
54
|
+
"doc": typer.Option(False, "-d", "--doc", help="Generate documentation."),
|
55
|
+
"no_config_updates": typer.Option(
|
56
|
+
False, "-n", "--no-config-updates", help="Do not update configuration files."
|
57
|
+
),
|
58
|
+
"update_precommit": typer.Option(
|
59
|
+
False, "-u", "--update-precommit", help="Update pre-commit hooks."
|
60
|
+
),
|
61
|
+
"verbose": typer.Option(False, "-v", "--verbose", help="Enable verbose output."),
|
62
|
+
"publish": typer.Option(
|
63
|
+
None,
|
64
|
+
"-p",
|
65
|
+
"--publish",
|
66
|
+
help="Bump version and publish to PyPI (micro, minor, major).",
|
67
|
+
case_sensitive=False,
|
68
|
+
),
|
69
|
+
"bump": typer.Option(
|
70
|
+
None,
|
71
|
+
"-b",
|
72
|
+
"--bump",
|
73
|
+
help="Bump version (micro, minor, major).",
|
74
|
+
case_sensitive=False,
|
75
|
+
),
|
76
|
+
"clean": typer.Option(
|
77
|
+
False,
|
78
|
+
"-x",
|
79
|
+
"--clean",
|
80
|
+
help="Remove docstrings, line comments, and unnecessary whitespace.",
|
81
|
+
),
|
82
|
+
"test": typer.Option(False, "-t", "--test", help="Run tests."),
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
def create_options(**kwargs: t.Any) -> Options:
|
87
|
+
return Options(**kwargs)
|
88
|
+
|
89
|
+
|
90
|
+
@app.command()
|
91
|
+
def main(
|
92
|
+
commit: bool = cli_options["commit"],
|
93
|
+
interactive: bool = cli_options["interactive"],
|
94
|
+
doc: bool = cli_options["doc"],
|
95
|
+
no_config_updates: bool = cli_options["no_config_updates"],
|
96
|
+
update_precommit: bool = cli_options["update_precommit"],
|
97
|
+
verbose: bool = cli_options["verbose"],
|
98
|
+
publish: t.Optional[BumpOption] = cli_options["publish"],
|
99
|
+
bump: t.Optional[BumpOption] = cli_options["bump"],
|
100
|
+
clean: bool = cli_options["clean"],
|
101
|
+
test: bool = cli_options["test"],
|
102
|
+
) -> None:
|
103
|
+
options = create_options(
|
104
|
+
commit=commit,
|
105
|
+
interactive=interactive,
|
106
|
+
doc=doc,
|
107
|
+
no_config_updates=no_config_updates,
|
108
|
+
update_precommit=update_precommit,
|
109
|
+
verbose=verbose,
|
110
|
+
publish=publish,
|
111
|
+
bump=bump,
|
112
|
+
clean=clean,
|
113
|
+
test=test,
|
114
|
+
)
|
115
|
+
crackerjack_it(options)
|
116
|
+
|
117
|
+
|
118
|
+
if __name__ == "__main__":
|
119
|
+
app()
|