- Fix infinite retry loop in ai_responder.py that caused test_fix1 to hang - Add missing picture_edit parameter to all AIResponse constructor calls - Set up complete development toolchain with Black, isort, Bandit, and MyPy - Create comprehensive Makefile for development workflows - Add pre-commit hooks with formatting, linting, security, and type checking - Update test mocking to provide contextual responses for different scenarios - Configure all tools for 140 character line length and strict type checking - Add DEVELOPMENT.md with setup instructions and workflow documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
4.1 KiB
4.1 KiB
Fjerkroa Bot Development Guide
This document outlines the development setup and workflows for the Fjerkroa Bot project.
Development Tools Setup
Prerequisites
- Python 3.11 (required - use
python3.11andpip3.11explicitly) - Git
Quick Start
# Install development dependencies
make install-dev
# Or manually:
pip3.11 install -r requirements.txt
pip3.11 install -e .
pre-commit install
Available Development Commands
Use the Makefile for all development tasks. Run make help to see all available commands:
Installation
make install- Install production dependenciesmake install-dev- Install development dependencies and pre-commit hooks
Code Quality
make lint- Run linter (flake8)make format- Format code with black and isortmake format-check- Check if code is properly formattedmake type-check- Run type checker (mypy)make security-check- Run security scanner (bandit)
Testing
make test- Run testsmake test-fast- Run tests without slow testsmake test-cov- Run tests with coverage report
Combined Operations
make all-checks- Run all code quality checks and testsmake pre-commit- Run all pre-commit checks (format, then check)make ci- Full CI pipeline (install deps and run all checks)
Utility
make clean- Clean up temporary files and cachesmake run- Run the bot (requires config.toml)make run-dev- Run the bot in development mode with auto-reload
Tool Configuration
All development tools are configured via pyproject.toml and .flake8:
Code Formatting (Black + isort)
- Line length: 140 characters
- Target Python version: 3.8+
- Imports sorted and formatted consistently
Linting (Flake8)
- Max line length: 140
- Max complexity: 10
- Ignores: E203, E266, E501, W503, E306 (for Black compatibility)
Type Checking (MyPy)
- Strict type checking enabled
- Checks both
fjerkroa_botandtestsdirectories - Ignores missing imports for external libraries
Security Scanning (Bandit)
- Scans for security issues
- Skips known safe patterns (pickle, random) for this application
Testing (Pytest)
- Configured for async tests
- Coverage reporting available
- Markers for slow tests
Pre-commit Hooks
Pre-commit hooks are automatically installed with make install-dev. They run:
- Built-in checks (trailing whitespace, file endings, etc.)
- Black code formatter
- isort import sorter
- Flake8 linter
- Bandit security scanner
- MyPy type checker
- Fast tests
To run pre-commit manually:
pre-commit run --all-files
Development Workflow
- Setup: Run
make install-dev - Development: Make your changes
- Check: Run
make pre-committo format and check code - Test: Run
make testormake test-covfor coverage - Commit: Git will automatically run pre-commit hooks
Continuous Integration
The make ci command runs the complete CI pipeline:
- Installs all dependencies
- Runs linting (flake8)
- Checks formatting (black, isort)
- Runs type checking (mypy)
- Runs security scanning (bandit)
- Runs all tests
File Structure
fjerkroa_bot/
├── fjerkroa_bot/ # Main package
├── tests/ # Test files
├── requirements.txt # Production dependencies
├── pyproject.toml # Tool configuration
├── .flake8 # Flake8 configuration
├── .pre-commit-config.yaml # Pre-commit configuration
├── Makefile # Development commands
└── setup.py # Package setup
Adding Dependencies
- Add to
requirements.txtfor production dependencies - Add to
pyproject.tomlfor development dependencies - Run
make install-devto install
Troubleshooting
Pre-commit Issues
# Reset pre-commit
pre-commit clean
pre-commit install
Tool Not Found Errors
Ensure you're using python3.11 and pip3.11 explicitly, and that all dependencies are installed:
make install-dev
Type Check Errors
Install missing type stubs:
pip3.11 install types-requests types-toml