This commit is contained in:
Jev Kuznetsov
2025-09-15 09:09:40 +02:00
parent f6da3d9839
commit 27bb46e039
6 changed files with 33 additions and 75 deletions

View File

@@ -16,7 +16,7 @@ uv sync
### Code Quality ### Code Quality
- **Linting and formatting**: `uv run ruff check --fix` and `uv run ruff format` - **Linting and formatting**: `uv run ruff check --fix` and `uv run ruff format`
- **Type checking**: `uv run mypy .` - **Type checking**: `uv run mypy .`
- **Combined linting**: `uv run invoke lint` (runs ruff check, ruff format --check, and mypy) - **Combined linting**: `uv run invoke lint`
### Testing ### Testing
- **Run tests**: `uv run pytest` - **Run tests**: `uv run pytest`
@@ -26,18 +26,7 @@ uv sync
- **Clean untracked files**: `uv run invoke clean` (interactive) - **Clean untracked files**: `uv run invoke clean` (interactive)
- **Version bumping**: `uv run bump-my-version bump [patch|minor|major]` - **Version bumping**: `uv run bump-my-version bump [patch|minor|major]`
## Code Architecture ## Project Structure
### Core Components (`src/{{ cookiecutter.package_name }}/core.py`)
The library implements the main functionality in the core module. Update this section with:
1. **Key Classes**: Describe main classes and their responsibilities
2. **Core Functions**: Document important functions and their purpose
3. **Data Flow**: Explain how data flows through the system
4. **Dependencies**: List and explain key dependencies
### Project Structure
``` ```
src/{{ cookiecutter.package_name }}/ src/{{ cookiecutter.package_name }}/
@@ -54,16 +43,7 @@ tests/
## Development Notes ## Development Notes
- Uses Python {{ cookiecutter.python_version }}+ with modern type hints (PEP 604) - Uses Python {{ cookiecutter.python_version }}+ with modern type hints
- Configured with ruff for linting/formatting and mypy for type checking - Configured with ruff for linting/formatting and mypy for type checking
- Built with uv for dependency management - Built with uv for dependency management
- Includes invoke tasks for common operations - Includes invoke tasks for common operations
- Version {{ cookiecutter.version }} ({{ cookiecutter.year }})
## Implementation Guidelines
- Follow test-driven development practices
- Use descriptive function names and one-liner docstrings for non-trivial functions
- Keep files between 300500 lines where possible
- Don't duplicate code; build upon existing implementations
- Always use type hints as supported by Python {{ cookiecutter.python_version }}+

View File

@@ -45,9 +45,10 @@ uv run pytest
## Usage ## Usage
```python ```python
from {{ cookiecutter.package_name }} import hello from {{ cookiecutter.package_name }}.core import say_hello
print(hello()) say_hello() # prints: Hello, World!
say_hello("Alice") # prints: Hello, Alice!
``` ```
## License ## License

View File

@@ -1,21 +1,15 @@
"""Basic usage example for {{ cookiecutter.project_name }}.""" """Basic usage example for {{ cookiecutter.project_name }}."""
from {{ cookiecutter.package_name }} import hello from {{ cookiecutter.package_name }}.core import say_hello
from {{ cookiecutter.package_name }}.core import process_data, {{ cookiecutter.project_name.replace(' ', '').replace('-', '') }}
def main(): def main():
"""Demonstrate basic usage.""" """Demonstrate basic usage."""
# Basic hello # Basic hello
print(hello()) say_hello()
# Process some data # Hello with a name
result = process_data("example data") say_hello("{{ cookiecutter.project_name }}")
print(result)
# Use main class
instance = {{ cookiecutter.project_name.replace(' ', '').replace('-', '') }}("example")
print(instance.run())
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -1,8 +1,3 @@
"""{{ cookiecutter.project_name }} - {{ cookiecutter.description }}""" """{{ cookiecutter.project_name }} - {{ cookiecutter.description }}"""
__version__ = "{{ cookiecutter.version }}" __version__ = "{{ cookiecutter.version }}"
def hello() -> str:
"""Return a hello message."""
return "Hello from {{ cookiecutter.project_name }}!"

View File

@@ -1,17 +1,6 @@
"""Core functionality for {{ cookiecutter.project_name }}.""" """Core functionality for {{ cookiecutter.project_name }}."""
def process_data(data: str) -> str: def say_hello(name: str = "World") -> None:
"""Process input data and return result.""" """Print a hello message."""
return f"Processed: {data}" print(f"Hello, {name}!")
class {{ cookiecutter.project_name.replace(' ', '').replace('-', '') }}:
"""Main class for {{ cookiecutter.project_name }}."""
def __init__(self, name: str = "default") -> None:
self.name = name
def run(self) -> str:
"""Run the main functionality."""
return f"Running {{ cookiecutter.project_name }} with {self.name}"

View File

@@ -1,25 +1,24 @@
"""Tests for {{ cookiecutter.package_name }}.""" """Tests for {{ cookiecutter.package_name }}."""
import pytest from io import StringIO
import sys
from {{ cookiecutter.package_name }} import hello from {{ cookiecutter.package_name }}.core import say_hello
from {{ cookiecutter.package_name }}.core import process_data, {{ cookiecutter.project_name.replace(' ', '').replace('-', '') }}
def test_hello(): def test_say_hello():
"""Test hello function.""" """Test say_hello function."""
result = hello() captured_output = StringIO()
assert "Hello from {{ cookiecutter.project_name }}" in result sys.stdout = captured_output
say_hello()
sys.stdout = sys.__stdout__
assert captured_output.getvalue() == "Hello, World!\n"
def test_process_data(): def test_say_hello_with_name():
"""Test process_data function.""" """Test say_hello function with custom name."""
result = process_data("test") captured_output = StringIO()
assert result == "Processed: test" sys.stdout = captured_output
say_hello("Alice")
sys.stdout = sys.__stdout__
def test_main_class(): assert captured_output.getvalue() == "Hello, Alice!\n"
"""Test main class."""
instance = {{ cookiecutter.project_name.replace(' ', '').replace('-', '') }}("test")
result = instance.run()
assert "Running {{ cookiecutter.project_name }} with test" in result