crackerjack 0.24.9__tar.gz → 0.25.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.
Potentially problematic release.
This version of crackerjack might be problematic. Click here for more details.
- {crackerjack-0.24.9 → crackerjack-0.25.0}/CLAUDE.md +48 -9
- {crackerjack-0.24.9 → crackerjack-0.25.0}/PKG-INFO +47 -15
- {crackerjack-0.24.9 → crackerjack-0.25.0}/README.md +46 -14
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/crackerjack.py +5 -5
- {crackerjack-0.24.9 → crackerjack-0.25.0/crackerjack}/pyproject.toml +1 -1
- {crackerjack-0.24.9/crackerjack → crackerjack-0.25.0}/pyproject.toml +1 -1
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_crackerjack.py +28 -4
- {crackerjack-0.24.9 → crackerjack-0.25.0}/uv.lock +1 -1
- crackerjack-0.24.9/.windsurfrules +0 -188
- {crackerjack-0.24.9 → crackerjack-0.25.0}/.envrc +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/.github/FUNDING.yml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/.gitignore +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/.libcst.codemod.yaml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/.pre-commit-config-ai.yaml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/.pre-commit-config.yaml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/LICENSE +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/README-AI-AGENT.md +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/RULES.md +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/.gitignore +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/.libcst.codemod.yaml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/.pdm.toml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/.pre-commit-config-ai.yaml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/.pre-commit-config.yaml +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/__init__.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/__main__.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/errors.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/interactive.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/crackerjack/py313.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/TESTING.md +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/__init__.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/conftest.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/data/comments_sample.txt +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/data/docstrings_sample.txt +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/data/expected_comments_sample.txt +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/data/init.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_crackerjack_runner.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_errors.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_interactive.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_interactive_run.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_main.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_multiline_functions.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_py313_advanced.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_py313_features.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_pytest_features.py +0 -0
- {crackerjack-0.24.9 → crackerjack-0.25.0}/tests/test_structured_errors.py +0 -0
|
@@ -16,6 +16,12 @@ pipx install uv
|
|
|
16
16
|
|
|
17
17
|
# Install project dependencies
|
|
18
18
|
uv sync
|
|
19
|
+
|
|
20
|
+
# Run individual tools through UV (ensures proper environment isolation)
|
|
21
|
+
uv run pytest
|
|
22
|
+
uv run pyright
|
|
23
|
+
uv run ruff check
|
|
24
|
+
uv run pre-commit run --all-files
|
|
19
25
|
```
|
|
20
26
|
|
|
21
27
|
### Running Crackerjack
|
|
@@ -120,25 +126,34 @@ Crackerjack is designed with modern Python principles and consists of several ke
|
|
|
120
126
|
1. **Crackerjack** (`crackerjack.py`): Main class that orchestrates the entire workflow
|
|
121
127
|
- Manages configuration updates
|
|
122
128
|
- Runs pre-commit hooks
|
|
123
|
-
- Handles code cleaning
|
|
124
|
-
- Executes tests
|
|
129
|
+
- Handles code cleaning (with enhanced error handling)
|
|
130
|
+
- Executes tests with dynamic parallelization
|
|
125
131
|
- Manages version bumping and publishing
|
|
126
132
|
- Handles Git operations
|
|
133
|
+
- Integrates with Rich console for status output
|
|
127
134
|
|
|
128
135
|
2. **CodeCleaner**: Responsible for cleaning code
|
|
129
|
-
- Removes docstrings
|
|
136
|
+
- Removes docstrings (with syntax-aware pass statement insertion)
|
|
130
137
|
- Removes line comments
|
|
131
138
|
- Removes extra whitespace
|
|
132
139
|
- Reformats code using Ruff
|
|
140
|
+
- Handles file encoding issues gracefully
|
|
133
141
|
|
|
134
142
|
3. **ConfigManager**: Handles configuration file management
|
|
135
143
|
- Updates pyproject.toml settings
|
|
136
144
|
- Manages configuration files (.gitignore, .pre-commit-config.yaml)
|
|
145
|
+
- Supports dynamic configuration based on project size
|
|
137
146
|
|
|
138
147
|
4. **ProjectManager**: Manages project-level operations
|
|
139
148
|
- Runs pre-commit hooks
|
|
140
149
|
- Updates package configurations
|
|
141
150
|
- Runs interactive hooks
|
|
151
|
+
- Detects project size for optimization
|
|
152
|
+
|
|
153
|
+
5. **ErrorHandler** (`errors.py`): Structured error handling system
|
|
154
|
+
- Provides consistent error codes and messages
|
|
155
|
+
- Handles graceful degradation on failures
|
|
156
|
+
- Supports both fatal and non-fatal error patterns
|
|
142
157
|
|
|
143
158
|
### Key Design Patterns
|
|
144
159
|
|
|
@@ -150,14 +165,15 @@ Crackerjack is designed with modern Python principles and consists of several ke
|
|
|
150
165
|
|
|
151
166
|
Crackerjack has a robust testing setup with:
|
|
152
167
|
|
|
153
|
-
- **Test Configuration**: Customizes pytest through conftest.py
|
|
154
|
-
- **Benchmark Support**: Special handling for benchmark tests
|
|
168
|
+
- **Test Configuration**: Customizes pytest through conftest.py with asyncio_mode="auto"
|
|
169
|
+
- **Benchmark Support**: Special handling for benchmark tests (disabled in parallel execution)
|
|
155
170
|
- **Smart Parallelization**: Adjusts the number of workers based on project size
|
|
156
171
|
- **Project Size Detection**: Automatically detects project size to optimize test execution
|
|
157
|
-
- **Timeout Protection**: Tests have dynamic timeouts based on project size
|
|
172
|
+
- **Timeout Protection**: Tests have dynamic timeouts based on project size (default 300s)
|
|
158
173
|
- **Deadlock Prevention**: Advanced threading techniques to prevent deadlocks
|
|
159
174
|
- **Progress Tracking**: Shows periodic heartbeat messages for long-running tests
|
|
160
175
|
- **AI Agent Integration**: Generates structured output files (JUnit XML, JSON coverage, benchmark JSON) when `--ai-agent` flag is used
|
|
176
|
+
- **Async Testing**: Configured for asyncio-based tests with automatic mode detection
|
|
161
177
|
|
|
162
178
|
### Interactive Mode
|
|
163
179
|
|
|
@@ -181,6 +197,24 @@ The interactive mode runs a predefined workflow with tasks:
|
|
|
181
197
|
|
|
182
198
|
Access interactive mode with: `python -m crackerjack -i`
|
|
183
199
|
|
|
200
|
+
## Module Organization
|
|
201
|
+
|
|
202
|
+
Crackerjack follows a single-file architecture for simplicity and maintainability:
|
|
203
|
+
|
|
204
|
+
### File Structure
|
|
205
|
+
- `crackerjack.py` - Main module (~3000 lines) containing all core functionality
|
|
206
|
+
- `errors.py` - Structured error handling system
|
|
207
|
+
- `interactive.py` - Rich-based interactive UI implementation
|
|
208
|
+
- `py313.py` - Python 3.13+ specific feature detection
|
|
209
|
+
- `__main__.py` - Entry point for `python -m crackerjack`
|
|
210
|
+
|
|
211
|
+
### Key Implementation Details
|
|
212
|
+
- **Single-file Design**: Most functionality concentrated in `crackerjack.py` for easier maintenance
|
|
213
|
+
- **Type Safety**: Extensive use of protocols and type hints throughout
|
|
214
|
+
- **Error Handling**: Comprehensive error handling with structured error codes
|
|
215
|
+
- **Dynamic Configuration**: Project size detection affects worker count, timeouts, and other settings
|
|
216
|
+
- **Rich Integration**: All console output uses Rich for enhanced terminal UI
|
|
217
|
+
|
|
184
218
|
## CLI Reference
|
|
185
219
|
|
|
186
220
|
### Core Options
|
|
@@ -218,22 +252,27 @@ Access interactive mode with: `python -m crackerjack -i`
|
|
|
218
252
|
|
|
219
253
|
## Development Guidelines
|
|
220
254
|
|
|
221
|
-
1. **Code Style**: Follow the Crackerjack style guide:
|
|
255
|
+
1. **Code Style**: Follow the Crackerjack style guide (see RULES.md):
|
|
222
256
|
- **Target Python 3.13+** - Use latest Python features
|
|
223
|
-
- Use static typing throughout with modern syntax
|
|
257
|
+
- Use static typing throughout with modern syntax (import typing as `t`)
|
|
224
258
|
- Use pathlib for file operations
|
|
225
259
|
- Prefer Protocol over ABC
|
|
260
|
+
- Use built-in collection types (`list[str]`, `dict[str, int]`) instead of typing equivalents
|
|
226
261
|
- Leverage Python 3.13+ performance and language improvements
|
|
227
262
|
|
|
228
263
|
2. **Testing Approach**:
|
|
229
264
|
- Write unit tests for all functionality
|
|
230
265
|
- Add benchmark tests for performance-critical code
|
|
231
266
|
- Tests are run in parallel by default
|
|
267
|
+
- **CRITICAL**: Use tempfile module for temporary files in tests (never create files directly on filesystem)
|
|
268
|
+
- Use pytest's `tmp_path` and `tmp_path_factory` fixtures
|
|
269
|
+
- Tests should be isolated and not affect the surrounding environment
|
|
232
270
|
|
|
233
271
|
3. **Dependencies**:
|
|
234
|
-
- UV for dependency management
|
|
272
|
+
- UV for dependency management and tool execution
|
|
235
273
|
- Ruff for linting and formatting
|
|
236
274
|
- Pytest for testing
|
|
275
|
+
- All tools should be run through UV for environment isolation
|
|
237
276
|
|
|
238
277
|
4. **Python Version**:
|
|
239
278
|
- **Target: Python 3.13+** - Crackerjack requires Python 3.13 or newer
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crackerjack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.25.0
|
|
4
4
|
Summary: Crackerjack: code quality toolkit
|
|
5
5
|
Project-URL: documentation, https://github.com/lesleslie/crackerjack
|
|
6
6
|
Project-URL: homepage, https://github.com/lesleslie/crackerjack
|
|
@@ -595,19 +595,51 @@ Crackerjack is designed with modern Python principles in mind:
|
|
|
595
595
|
|
|
596
596
|
## Acknowledgments
|
|
597
597
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
-
|
|
602
|
-
-
|
|
603
|
-
-
|
|
604
|
-
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
-
|
|
608
|
-
-
|
|
609
|
-
-
|
|
610
|
-
-
|
|
611
|
-
-
|
|
598
|
+
Crackerjack stands on the shoulders of giants. We're grateful to the maintainers and contributors of these outstanding tools that make modern Python development possible:
|
|
599
|
+
|
|
600
|
+
### Core Development Tools
|
|
601
|
+
- **[UV](https://docs.astral.sh/uv/)** - Next-generation Python package and project management
|
|
602
|
+
- **[Ruff](https://docs.astral.sh/ruff/)** - Lightning-fast Python linter and formatter written in Rust
|
|
603
|
+
- **[pyright](https://microsoft.github.io/pyright/)** - Fast, feature-rich static type checker for Python
|
|
604
|
+
- **[pytest](https://pytest.org/)** - Flexible and powerful testing framework
|
|
605
|
+
|
|
606
|
+
### Code Quality & Security
|
|
607
|
+
- **[pre-commit](https://pre-commit.com/)** - Multi-language pre-commit hooks framework
|
|
608
|
+
- **[bandit](https://bandit.readthedocs.io/)** - Security vulnerability scanner for Python
|
|
609
|
+
- **[vulture](https://github.com/jendrikseipp/vulture)** - Dead code detection tool
|
|
610
|
+
- **[refurb](https://github.com/dosisod/refurb)** - Code modernization and improvement suggestions
|
|
611
|
+
- **[codespell](https://github.com/codespell-project/codespell)** - Spelling mistake detection and correction
|
|
612
|
+
- **[detect-secrets](https://github.com/Yelp/detect-secrets)** - Prevention of secrets in repositories
|
|
613
|
+
|
|
614
|
+
### Dependencies & Project Management
|
|
615
|
+
- **[creosote](https://github.com/fredrikaverpil/creosote)** - Unused dependency detection
|
|
616
|
+
- **[autotyping](https://github.com/JelleZijlstra/autotyping)** - Automatic type hint generation
|
|
617
|
+
- **[complexipy](https://github.com/rohaquinlop/complexipy)** - Code complexity analysis
|
|
618
|
+
|
|
619
|
+
### CLI & User Interface
|
|
620
|
+
- **[Typer](https://typer.tiangolo.com/)** - Modern CLI framework for building command-line interfaces
|
|
621
|
+
- **[Rich](https://rich.readthedocs.io/)** - Rich text and beautiful formatting in the terminal
|
|
622
|
+
- **[click](https://click.palletsprojects.com/)** - Python package for creating command line interfaces
|
|
623
|
+
|
|
624
|
+
### Performance & Development Tools
|
|
625
|
+
- **[icecream](https://github.com/gruns/icecream)** - Sweet and creamy print debugging
|
|
626
|
+
- **[bevy](https://github.com/ZeroIntensity/bevy)** - Lightweight dependency injection framework
|
|
627
|
+
- **[msgspec](https://github.com/jcrist/msgspec)** - High-performance message serialization
|
|
628
|
+
- **[attrs](https://github.com/python-attrs/attrs)** - Classes without boilerplate
|
|
629
|
+
|
|
630
|
+
### Development Environment
|
|
631
|
+
- **[PyCharm](https://www.jetbrains.com/pycharm/)** - The premier Python IDE that powered the development of Crackerjack
|
|
632
|
+
- **[Claude Code](https://claude.ai/code)** - AI-powered development assistant that accelerated development and ensured code quality
|
|
633
|
+
|
|
634
|
+
### Legacy Inspiration
|
|
635
|
+
- **[PDM](https://pdm.fming.dev/)** - Original inspiration for modern Python dependency management patterns
|
|
636
|
+
|
|
637
|
+
### Special Recognition
|
|
638
|
+
|
|
639
|
+
We extend special thanks to the **Astral team** for their groundbreaking work on UV and Ruff, which have revolutionized Python tooling. Their commitment to performance, reliability, and developer experience has set new standards for the Python ecosystem.
|
|
640
|
+
|
|
641
|
+
The integration of these tools into Crackerjack's unified workflow demonstrates the power of the modern Python toolchain when thoughtfully combined. Each tool excels in its domain, and together they create a development experience that is both powerful and delightful.
|
|
642
|
+
|
|
643
|
+
We're honored to build upon this foundation and contribute to the Python community's continued evolution toward better development practices and tools.
|
|
612
644
|
|
|
613
645
|
---
|
|
@@ -551,19 +551,51 @@ Crackerjack is designed with modern Python principles in mind:
|
|
|
551
551
|
|
|
552
552
|
## Acknowledgments
|
|
553
553
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
-
|
|
558
|
-
-
|
|
559
|
-
-
|
|
560
|
-
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
-
|
|
564
|
-
-
|
|
565
|
-
-
|
|
566
|
-
-
|
|
567
|
-
-
|
|
554
|
+
Crackerjack stands on the shoulders of giants. We're grateful to the maintainers and contributors of these outstanding tools that make modern Python development possible:
|
|
555
|
+
|
|
556
|
+
### Core Development Tools
|
|
557
|
+
- **[UV](https://docs.astral.sh/uv/)** - Next-generation Python package and project management
|
|
558
|
+
- **[Ruff](https://docs.astral.sh/ruff/)** - Lightning-fast Python linter and formatter written in Rust
|
|
559
|
+
- **[pyright](https://microsoft.github.io/pyright/)** - Fast, feature-rich static type checker for Python
|
|
560
|
+
- **[pytest](https://pytest.org/)** - Flexible and powerful testing framework
|
|
561
|
+
|
|
562
|
+
### Code Quality & Security
|
|
563
|
+
- **[pre-commit](https://pre-commit.com/)** - Multi-language pre-commit hooks framework
|
|
564
|
+
- **[bandit](https://bandit.readthedocs.io/)** - Security vulnerability scanner for Python
|
|
565
|
+
- **[vulture](https://github.com/jendrikseipp/vulture)** - Dead code detection tool
|
|
566
|
+
- **[refurb](https://github.com/dosisod/refurb)** - Code modernization and improvement suggestions
|
|
567
|
+
- **[codespell](https://github.com/codespell-project/codespell)** - Spelling mistake detection and correction
|
|
568
|
+
- **[detect-secrets](https://github.com/Yelp/detect-secrets)** - Prevention of secrets in repositories
|
|
569
|
+
|
|
570
|
+
### Dependencies & Project Management
|
|
571
|
+
- **[creosote](https://github.com/fredrikaverpil/creosote)** - Unused dependency detection
|
|
572
|
+
- **[autotyping](https://github.com/JelleZijlstra/autotyping)** - Automatic type hint generation
|
|
573
|
+
- **[complexipy](https://github.com/rohaquinlop/complexipy)** - Code complexity analysis
|
|
574
|
+
|
|
575
|
+
### CLI & User Interface
|
|
576
|
+
- **[Typer](https://typer.tiangolo.com/)** - Modern CLI framework for building command-line interfaces
|
|
577
|
+
- **[Rich](https://rich.readthedocs.io/)** - Rich text and beautiful formatting in the terminal
|
|
578
|
+
- **[click](https://click.palletsprojects.com/)** - Python package for creating command line interfaces
|
|
579
|
+
|
|
580
|
+
### Performance & Development Tools
|
|
581
|
+
- **[icecream](https://github.com/gruns/icecream)** - Sweet and creamy print debugging
|
|
582
|
+
- **[bevy](https://github.com/ZeroIntensity/bevy)** - Lightweight dependency injection framework
|
|
583
|
+
- **[msgspec](https://github.com/jcrist/msgspec)** - High-performance message serialization
|
|
584
|
+
- **[attrs](https://github.com/python-attrs/attrs)** - Classes without boilerplate
|
|
585
|
+
|
|
586
|
+
### Development Environment
|
|
587
|
+
- **[PyCharm](https://www.jetbrains.com/pycharm/)** - The premier Python IDE that powered the development of Crackerjack
|
|
588
|
+
- **[Claude Code](https://claude.ai/code)** - AI-powered development assistant that accelerated development and ensured code quality
|
|
589
|
+
|
|
590
|
+
### Legacy Inspiration
|
|
591
|
+
- **[PDM](https://pdm.fming.dev/)** - Original inspiration for modern Python dependency management patterns
|
|
592
|
+
|
|
593
|
+
### Special Recognition
|
|
594
|
+
|
|
595
|
+
We extend special thanks to the **Astral team** for their groundbreaking work on UV and Ruff, which have revolutionized Python tooling. Their commitment to performance, reliability, and developer experience has set new standards for the Python ecosystem.
|
|
596
|
+
|
|
597
|
+
The integration of these tools into Crackerjack's unified workflow demonstrates the power of the modern Python toolchain when thoughtfully combined. Each tool excels in its domain, and together they create a development experience that is both powerful and delightful.
|
|
598
|
+
|
|
599
|
+
We're honored to build upon this foundation and contribute to the Python community's continued evolution toward better development practices and tools.
|
|
568
600
|
|
|
569
601
|
---
|
|
@@ -634,7 +634,7 @@ class CodeCleaner(BaseModel, arbitrary_types_allowed=True):
|
|
|
634
634
|
temp_path.write_text(code)
|
|
635
635
|
try:
|
|
636
636
|
result = subprocess.run(
|
|
637
|
-
["ruff", "format", str(temp_path)],
|
|
637
|
+
["uv", "run", "ruff", "format", str(temp_path)],
|
|
638
638
|
check=False,
|
|
639
639
|
capture_output=True,
|
|
640
640
|
text=True,
|
|
@@ -887,7 +887,7 @@ class ProjectManager(BaseModel, arbitrary_types_allowed=True):
|
|
|
887
887
|
self.execute_command(["git", "branch", "-m", "main"])
|
|
888
888
|
self.execute_command(["git", "add", "pyproject.toml", "uv.lock"])
|
|
889
889
|
self.execute_command(["git", "config", "advice.addIgnoredFile", "false"])
|
|
890
|
-
install_cmd = ["pre-commit", "install"]
|
|
890
|
+
install_cmd = ["uv", "run", "pre-commit", "install"]
|
|
891
891
|
if hasattr(self, "options") and getattr(self.options, "ai_agent", False):
|
|
892
892
|
install_cmd.extend(["-c", ".pre-commit-config-ai.yaml"])
|
|
893
893
|
self.execute_command(install_cmd)
|
|
@@ -899,7 +899,7 @@ class ProjectManager(BaseModel, arbitrary_types_allowed=True):
|
|
|
899
899
|
"[bold bright_cyan]🔍 HOOKS[/bold bright_cyan] [bold bright_white]Running code quality checks[/bold bright_white]"
|
|
900
900
|
)
|
|
901
901
|
self.console.print("-" * 60 + "\n")
|
|
902
|
-
cmd = ["pre-commit", "run", "--all-files"]
|
|
902
|
+
cmd = ["uv", "run", "pre-commit", "run", "--all-files"]
|
|
903
903
|
if hasattr(self, "options") and getattr(self.options, "ai_agent", False):
|
|
904
904
|
cmd.extend(["-c", ".pre-commit-config-ai.yaml"])
|
|
905
905
|
check_all = self.execute_command(cmd)
|
|
@@ -990,7 +990,7 @@ class Crackerjack(BaseModel, arbitrary_types_allowed=True):
|
|
|
990
990
|
|
|
991
991
|
def _update_precommit(self, options: t.Any) -> None:
|
|
992
992
|
if self.pkg_path.stem == "crackerjack" and options.update_precommit:
|
|
993
|
-
update_cmd = ["pre-commit", "autoupdate"]
|
|
993
|
+
update_cmd = ["uv", "run", "pre-commit", "autoupdate"]
|
|
994
994
|
if options.ai_agent:
|
|
995
995
|
update_cmd.extend(["-c", ".pre-commit-config-ai.yaml"])
|
|
996
996
|
self.execute_command(update_cmd)
|
|
@@ -1076,7 +1076,7 @@ class Crackerjack(BaseModel, arbitrary_types_allowed=True):
|
|
|
1076
1076
|
test.append("-xvs")
|
|
1077
1077
|
|
|
1078
1078
|
def _prepare_pytest_command(self, options: OptionsProtocol) -> list[str]:
|
|
1079
|
-
test = ["pytest"]
|
|
1079
|
+
test = ["uv", "run", "pytest"]
|
|
1080
1080
|
project_size = self._detect_project_size()
|
|
1081
1081
|
test_timeout = self._get_test_timeout(options, project_size)
|
|
1082
1082
|
if getattr(options, "ai_agent", False):
|
|
@@ -909,7 +909,9 @@ class TestCrackerjackProcess:
|
|
|
909
909
|
with patch.object(cj, "_setup_package"):
|
|
910
910
|
with patch.object(cj, "_update_project"):
|
|
911
911
|
cj.process(options)
|
|
912
|
-
mock_cj_execute.assert_any_call(
|
|
912
|
+
mock_cj_execute.assert_any_call(
|
|
913
|
+
["uv", "run", "pre-commit", "autoupdate"]
|
|
914
|
+
)
|
|
913
915
|
|
|
914
916
|
def test_update_precommit_ai_agent(
|
|
915
917
|
self,
|
|
@@ -927,7 +929,14 @@ class TestCrackerjackProcess:
|
|
|
927
929
|
with patch.object(cj, "_update_project"):
|
|
928
930
|
cj.process(options)
|
|
929
931
|
mock_cj_execute.assert_any_call(
|
|
930
|
-
[
|
|
932
|
+
[
|
|
933
|
+
"uv",
|
|
934
|
+
"run",
|
|
935
|
+
"pre-commit",
|
|
936
|
+
"autoupdate",
|
|
937
|
+
"-c",
|
|
938
|
+
".pre-commit-config-ai.yaml",
|
|
939
|
+
]
|
|
931
940
|
)
|
|
932
941
|
|
|
933
942
|
def test_run_pre_commit_ai_agent(
|
|
@@ -943,7 +952,15 @@ class TestCrackerjackProcess:
|
|
|
943
952
|
mock_project.execute_command.return_value = MagicMock(returncode=0)
|
|
944
953
|
ProjectManager.run_pre_commit(mock_project)
|
|
945
954
|
mock_project.execute_command.assert_called_with(
|
|
946
|
-
[
|
|
955
|
+
[
|
|
956
|
+
"uv",
|
|
957
|
+
"run",
|
|
958
|
+
"pre-commit",
|
|
959
|
+
"run",
|
|
960
|
+
"--all-files",
|
|
961
|
+
"-c",
|
|
962
|
+
".pre-commit-config-ai.yaml",
|
|
963
|
+
]
|
|
947
964
|
)
|
|
948
965
|
|
|
949
966
|
def test_pre_commit_install_ai_agent(
|
|
@@ -965,7 +982,14 @@ class TestCrackerjackProcess:
|
|
|
965
982
|
original_method = ProjectManager.update_pkg_configs
|
|
966
983
|
original_method(mock_project)
|
|
967
984
|
mock_execute.assert_any_call(
|
|
968
|
-
[
|
|
985
|
+
[
|
|
986
|
+
"uv",
|
|
987
|
+
"run",
|
|
988
|
+
"pre-commit",
|
|
989
|
+
"install",
|
|
990
|
+
"-c",
|
|
991
|
+
".pre-commit-config-ai.yaml",
|
|
992
|
+
]
|
|
969
993
|
)
|
|
970
994
|
|
|
971
995
|
def test_process_with_precommit_failure(
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# Windsurf AI Rules for Crackerjack Projects
|
|
2
|
-
|
|
3
|
-
## Project Context
|
|
4
|
-
This is a Crackerjack project - an opinionated Python project management tool that streamlines development workflow by combining best-in-class tools. When working on this codebase or projects that use Crackerjack, follow these rules strictly.
|
|
5
|
-
|
|
6
|
-
## Code Quality & Style
|
|
7
|
-
|
|
8
|
-
### Static Typing Requirements
|
|
9
|
-
- Always include comprehensive type hints for all functions, methods, and variables
|
|
10
|
-
- Import typing as `import typing as t` and prefix all typing references with `t.`
|
|
11
|
-
- Never import individual types directly from typing (avoid `from typing import List, Dict, Optional`)
|
|
12
|
-
- Use modern typing syntax with pipe operator (`|`) for unions instead of `Optional[T]`
|
|
13
|
-
- Use built-in collection types: `list[str]` not `t.List[str]`, `dict[str, int]` not `t.Dict[str, int]`
|
|
14
|
-
- Use `t.Protocol` instead of abstract base classes
|
|
15
|
-
- Apply `@t.runtime_checkable` decorator to protocols when runtime checking is needed
|
|
16
|
-
|
|
17
|
-
### Modern Python Standards
|
|
18
|
-
- Target Python 3.13+ features and syntax exclusively
|
|
19
|
-
- Use f-strings for all string formatting
|
|
20
|
-
- Prefer `pathlib.Path` over `os.path` for file operations
|
|
21
|
-
- Use dataclasses for structured data
|
|
22
|
-
- Adopt latest language features immediately
|
|
23
|
-
|
|
24
|
-
### Code Architecture
|
|
25
|
-
- Write modular functions that do one thing well
|
|
26
|
-
- Avoid unnecessary docstrings and line comments unless they explain "why" not "what"
|
|
27
|
-
- Choose clear, descriptive variable and function names
|
|
28
|
-
- Group related functionality into well-defined classes
|
|
29
|
-
- Structure projects with clear separation of concerns
|
|
30
|
-
|
|
31
|
-
## Tool Integration & Commands
|
|
32
|
-
|
|
33
|
-
### PDM Usage
|
|
34
|
-
- Always use `pdm run` to execute tools within the project's virtual environment
|
|
35
|
-
- Run pytest with `pdm run pytest` instead of calling pytest directly
|
|
36
|
-
- Execute all tools through PDM: `pdm run pyright`, `pdm run ruff`, `pdm run crackerjack`
|
|
37
|
-
- Install dependencies with `pdm install`
|
|
38
|
-
|
|
39
|
-
### Crackerjack Commands
|
|
40
|
-
- Run basic process: `python -m crackerjack`
|
|
41
|
-
- Clean, test, and commit: `python -m crackerjack -x -t -c`
|
|
42
|
-
- Auto bump and commit: `python -m crackerjack -a micro`
|
|
43
|
-
- Interactive mode: `python -m crackerjack -i`
|
|
44
|
-
- Test only: `python -m crackerjack -t`
|
|
45
|
-
- Skip pre-commit during testing: `python -m crackerjack -t -s`
|
|
46
|
-
- Optimize for large projects: `python -m crackerjack -t --test-workers=2 --test-timeout=300`
|
|
47
|
-
|
|
48
|
-
### Quality Validation
|
|
49
|
-
- Code is incomplete until it passes: `python -m crackerjack -x -t`
|
|
50
|
-
- This validates typing, formatting, linting, and test success
|
|
51
|
-
- Run `pre-commit run --all-files` during development
|
|
52
|
-
- All code must pass pre-commit checks before submission
|
|
53
|
-
|
|
54
|
-
## Testing Standards
|
|
55
|
-
|
|
56
|
-
### Test Environment
|
|
57
|
-
- Use pytest with asyncio_mode="auto" for async testing
|
|
58
|
-
- Never create files directly on filesystem in tests
|
|
59
|
-
- Always use `tempfile` module or pytest's `tmp_path` fixtures
|
|
60
|
-
- Tests must be isolated and not affect surrounding environment
|
|
61
|
-
- Avoid hard-coded paths pointing to real filesystem
|
|
62
|
-
|
|
63
|
-
### Test Configuration
|
|
64
|
-
- Write tests for behavior, not implementation details
|
|
65
|
-
- Focus on testing public interfaces rather than private functions
|
|
66
|
-
- Use parallel test execution when appropriate
|
|
67
|
-
- Add timeouts to prevent hanging tests
|
|
68
|
-
- Separate unit tests, integration tests, and benchmarks
|
|
69
|
-
- Aim for complete coverage of critical paths
|
|
70
|
-
|
|
71
|
-
### Benchmark Testing
|
|
72
|
-
- Run benchmarks: `python -m crackerjack -t --benchmark`
|
|
73
|
-
- Regression detection: `python -m crackerjack -t --benchmark-regression`
|
|
74
|
-
- Custom threshold: `python -m crackerjack -t --benchmark-regression --benchmark-regression-threshold=10.0`
|
|
75
|
-
|
|
76
|
-
## Error Handling & Output
|
|
77
|
-
|
|
78
|
-
### Exception Management
|
|
79
|
-
- Use structured exception handling with specific exception types
|
|
80
|
-
- Provide meaningful error messages with context
|
|
81
|
-
- Handle errors gracefully and provide actionable feedback
|
|
82
|
-
|
|
83
|
-
### Console Output
|
|
84
|
-
- Use Rich library for all console output
|
|
85
|
-
- Provide clear status indicators for operations
|
|
86
|
-
- Format output for readability and user experience
|
|
87
|
-
|
|
88
|
-
## Development Workflow
|
|
89
|
-
|
|
90
|
-
### Pre-commit Hooks
|
|
91
|
-
Configure comprehensive pre-commit hooks:
|
|
92
|
-
- Pyright for static type checking
|
|
93
|
-
- Ruff for linting and formatting
|
|
94
|
-
- Vulture for detecting unused code
|
|
95
|
-
- Creosote for identifying large files
|
|
96
|
-
- Flynt for string formatting conversion
|
|
97
|
-
- Codespell for spell checking
|
|
98
|
-
- Autotyping for type annotation
|
|
99
|
-
- Refurb for Python code modernization
|
|
100
|
-
- Bandit for security vulnerabilities
|
|
101
|
-
|
|
102
|
-
### Version Management
|
|
103
|
-
- Use semantic versioning
|
|
104
|
-
- Bump versions through Crackerjack: `-b micro|minor|major`
|
|
105
|
-
- Publish to PyPI: `-p micro|minor|major`
|
|
106
|
-
- Version bumping handled through PDM
|
|
107
|
-
|
|
108
|
-
### Git Operations
|
|
109
|
-
- Commit after pre-commit: `python -m crackerjack -c`
|
|
110
|
-
- Create pull requests: `python -m crackerjack -r`
|
|
111
|
-
- Never commit changes unless explicitly requested
|
|
112
|
-
|
|
113
|
-
## Dependency Management
|
|
114
|
-
|
|
115
|
-
### Package Management
|
|
116
|
-
- Use PDM with uv for dependency management
|
|
117
|
-
- Keep external dependencies minimal
|
|
118
|
-
- Pin exact versions in lockfiles
|
|
119
|
-
- Use range specifications in pyproject.toml
|
|
120
|
-
- Regularly audit dependencies for security
|
|
121
|
-
- Prefer standard library solutions when reasonable
|
|
122
|
-
|
|
123
|
-
### Configuration
|
|
124
|
-
- Use pyproject.toml for all project configuration
|
|
125
|
-
- Follow standard package layout conventions
|
|
126
|
-
- Configure all tools through pyproject.toml when possible
|
|
127
|
-
|
|
128
|
-
## Performance & Optimization
|
|
129
|
-
|
|
130
|
-
### Code Performance
|
|
131
|
-
- Use profiling tools for critical code paths
|
|
132
|
-
- Benchmark alternative implementations
|
|
133
|
-
- Favor readability over micro-optimizations
|
|
134
|
-
- Document non-obvious optimizations with rationale
|
|
135
|
-
|
|
136
|
-
### Test Performance
|
|
137
|
-
- Adjust test workers based on project size
|
|
138
|
-
- Use appropriate timeouts for test execution
|
|
139
|
-
- Implement deadlock prevention for threading
|
|
140
|
-
- Show progress tracking for long-running tests
|
|
141
|
-
|
|
142
|
-
## Documentation Philosophy
|
|
143
|
-
|
|
144
|
-
### Minimalist Approach
|
|
145
|
-
- Focus documentation on "why" rather than "what"
|
|
146
|
-
- Document APIs at module/class level, not individual functions
|
|
147
|
-
- Use type hints to replace parameter documentation
|
|
148
|
-
- Create examples for complex functionality
|
|
149
|
-
- Avoid verbose explanations
|
|
150
|
-
|
|
151
|
-
## Security & Best Practices
|
|
152
|
-
|
|
153
|
-
### Security Standards
|
|
154
|
-
- Never expose or log secrets and keys
|
|
155
|
-
- Never commit secrets to repository
|
|
156
|
-
- Use Bandit for security vulnerability scanning
|
|
157
|
-
- Follow security best practices consistently
|
|
158
|
-
|
|
159
|
-
### Code Review
|
|
160
|
-
- All code must be reviewed before merging
|
|
161
|
-
- Automate style checks to focus reviews on substance
|
|
162
|
-
- Look for edge cases and error handling
|
|
163
|
-
- Ensure tests adequately cover changes
|
|
164
|
-
|
|
165
|
-
## Project-Specific Guidelines
|
|
166
|
-
|
|
167
|
-
### For Crackerjack Core Development
|
|
168
|
-
- Maintain the opinionated nature of the tool
|
|
169
|
-
- Enforce single correct way to accomplish tasks
|
|
170
|
-
- Remove unnecessary flexibility that leads to inconsistency
|
|
171
|
-
- Value clarity over brevity
|
|
172
|
-
|
|
173
|
-
### For Projects Using Crackerjack
|
|
174
|
-
- Follow all Crackerjack style rules
|
|
175
|
-
- Use Crackerjack for all development workflow tasks
|
|
176
|
-
- Configure projects to pass `python -m crackerjack -x -t`
|
|
177
|
-
- Adopt Crackerjack's opinionated choices consistently
|
|
178
|
-
|
|
179
|
-
## AI Assistant Instructions
|
|
180
|
-
|
|
181
|
-
When working on Crackerjack or projects using Crackerjack:
|
|
182
|
-
1. Always check code against these rules before suggesting changes
|
|
183
|
-
2. Run appropriate Crackerjack commands to validate changes
|
|
184
|
-
3. Ensure all code follows the typing and style guidelines
|
|
185
|
-
4. Use PDM for all tool execution
|
|
186
|
-
5. Test changes thoroughly with appropriate timeouts
|
|
187
|
-
6. Never compromise on code quality standards
|
|
188
|
-
7. Maintain the opinionated, high-quality nature of the project
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|