Development Setup Summary

This document summarizes the development tools and configuration that have been added to the SMW Reader project.

βœ… What’s Working

Core Development Tools

  • duties.py - Comprehensive development task runner using duty

  • Taskfile.yaml - Convenient wrapper around duties for use with Task runner

  • ruff.toml - Code formatting and linting configuration

  • mypy.ini - Type checking configuration (available for manual use)

  • .pre-commit-config.yaml - Git hooks for automated quality checks

  • Updated pyproject.toml - Added comprehensive dev dependencies

Pre-commit Hooks (Active)

  • βœ… Trailing whitespace removal

  • βœ… End of file fixes

  • βœ… YAML/TOML/JSON validation

  • βœ… Merge conflict detection

  • βœ… Large file detection

  • βœ… Ruff linting (with security checks properly configured)

  • βœ… Ruff formatting (automated code formatting)

Available Tasks

Using Duty directly:

uv run python -m duty format
uv run python -m duty test
uv run python -m duty check_all

πŸ”§ Temporarily Disabled (but available manually)

MyPy Type Checking

  • Status: Disabled in pre-commit due to existing type annotation issues

  • Manual use: task type-check or uv run python -m duty type_check

  • Issues: 6 type annotation errors in source code that need to be addressed

Bandit Security Scanning

  • Status: Disabled in pre-commit due to false positives with urllib usage

  • Manual use: task security or uv run python -m duty security

  • Issues: Reports expected urllib.request.urlopen usage as security concern

πŸ› οΈ Configuration Files Created

  1. duties.py - Task definitions for development workflows

  2. Taskfile.yaml - Task runner wrapper for convenient CLI usage

  3. ruff.toml - Linting and formatting rules (100 char line length)

  4. mypy.ini - Type checking configuration (strict mode)

  5. .pre-commit-config.yaml - Git hooks configuration

  6. .bandit - Security scanning configuration

πŸš€ Getting Started

First Time Setup

# Install all development dependencies
task dev-setup

# Or manually:
uv sync --all-extras
uv run pre-commit install

Daily Development Workflow

# Format and check code
task format
task lint
task test

# Or run all checks at once
task check

# Before committing (runs automatically with pre-commit)
task ci

πŸ“‹ Future Tasks

To fully enable type checking:

  1. Fix the 6 MyPy errors in source files:

    • src/smw_reader/exceptions.py:11 - Add type parameters for dict

    • src/smw_reader/http_client.py:111 - Fix Any return type

    • src/smw_reader/endpoints/ask.py - Fix string to int assignment issues

    • src/smw_reader/__init__.py:48 - Add function type annotation

  2. Re-enable MyPy in .pre-commit-config.yaml

To enable security scanning:

  1. Review and document urllib usage in HTTP client as safe

  2. Configure bandit to allow expected urllib patterns

  3. Re-enable bandit in .pre-commit-config.yaml

🎯 Benefits Achieved

  1. Automated Code Quality: Pre-commit hooks ensure consistent formatting and catch issues early

  2. Easy Task Management: Simple commands for common development tasks

  3. Flexible Architecture: Can use either Task or Duty directly based on preference

  4. Comprehensive Testing: Full test suite with coverage options

  5. Modern Python Practices: Follows best practices outlined in AGENTS.md

  6. Developer Experience: Quick setup and intuitive commands

The development environment is now ready for productive Python development with modern tooling and quality assurance measures in place.