Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: nix develop --command uv sync
run: nix develop --command poetry install

- name: Run linting
run: nix develop --command runLint
Expand Down
29 changes: 21 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@ repos:
rev: main
hooks:
- id: pyrefly-typecheck
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.9
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [ --fix ]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
types_or: [python, pyi]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
types_or: [python, pyi]
- repo: https://github.com/PyCQA/flake8
rev: 7.2.0
hooks:
- id: flake8
types_or: [python, pyi]
additional_dependencies:
- flake8-bugbear
- flake8-unused-arguments
- flake8-print
- flake8-type-checking
- flake8-pyproject
34 changes: 18 additions & 16 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Development Commands

This project uses `uv` (a fast Python package manager) and Nix for development. Here are the essential commands:
This project uses `poetry` for package management and Nix for development. Here are the essential commands:

**Note**: Always run `uv sync` first to ensure dependencies are installed.
**Note**: Always run `poetry install` first to ensure dependencies are installed.

### Running the Application
```bash
uv run pai
poetry run pai
```

### Testing
```bash
# Run all tests with coverage
runTests # (Nix command)
# or
uv run pytest --cov=pai --cov-report=term-missing --cov-report=html
poetry run pytest --cov=pai --cov-report=term-missing --cov-report=html

# Run a specific test
uv run pytest tests/pai/test_main.py::test_specific_function
poetry run pytest tests/pai/test_main.py::test_specific_function
```

### Linting and Formatting
Expand All @@ -30,18 +30,20 @@ uv run pytest tests/pai/test_main.py::test_specific_function
runLint

# Or individually:
uv run ruff format src # Format code
uv run ruff check --fix src # Lint and auto-fix
pyrefly check # Type checking
poetry run black src # Format code
poetry run isort src # Sort imports
poetry run flake8 src # Lint
poetry run pyrefly check # Type checking

# Run pre-commit hooks
pre-commit run --all-files
poetry run pre-commit run --all-files
```

### Dependency Management
```bash
uv sync # Install all dependencies
uv pip install -e . # Install package in editable mode
poetry install # Install all dependencies
poetry add <package> # Add a production dependency
poetry add --group dev <package> # Add a development dependency
```

### CI/CD
Expand All @@ -56,12 +58,12 @@ The project includes GitHub Actions workflow that automatically:
This is an AI-centric Python application with a clean, modular structure:

1. **Main Package**: `src/pai/` - The core application package ("Python AI")
- Entry point: `src/pai/main.py:main` (accessed via `uv run pai`)
- Entry point: `src/pai/main.py:main` (accessed via `poetry run pai`)
- The main function logs initialization and returns a boolean status

2. **Configuration**: Modern Python project using:
- `pyproject.toml` for all project metadata and dependencies
- `uv.lock` for reproducible dependency management
- `poetry.lock` for reproducible dependency management
- Nix flakes for development environment consistency

3. **Key Architectural Patterns**:
Expand All @@ -85,13 +87,13 @@ nix develop

The environment includes:
- Python 3.13
- All development tools (ruff, pytest, pyrefly, etc.)
- All development tools (black, isort, flake8, pytest, pyrefly, etc.)
- Pre-configured pre-commit hooks
- Environment file support (`.env`, `.test.env`, `.deploy.env`)

## Code Quality Standards

- **Line Length**: 120 characters (Ruff configuration)
- **Type Checking**: Both Basedpyright and Pyrefly must pass
- **Line Length**: 120 characters (black/flake8 configuration)
- **Type Checking**: Pyrefly must pass
- **Test Coverage**: Maintain test coverage with parallel structure in `tests/`
- **Pre-commit**: All hooks must pass before commits
51 changes: 20 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ A modern GitHub template for starting AI-centric Python projects with batteries
This template provides a complete development environment for AI/ML applications with:

- **AI/ML SDKs**: Pre-configured with Anthropic, OpenAI, Hugging Face, and MCP (Model Context Protocol) SDKs
- **Modern Python tooling**: Uses `uv` for blazing-fast package management
- **Modern Python tooling**: Uses `poetry` for package management
- **Type safety**: Pyrefly for type checking
- **Code quality**: Ruff for linting and formatting
- **Code quality**: Black, isort, and Flake8 for formatting and linting
- **HTTP client**: httpx for async HTTP operations
- **Development environment**: Optional Nix flakes for reproducible environments
- **Python 3.13**: Latest Python version support
Expand All @@ -21,7 +21,7 @@ This template provides a complete development environment for AI/ML applications
### Prerequisites

- Python 3.13+
- [uv](https://github.com/astral-sh/uv) (Python package manager)
- [Poetry](https://python-poetry.org/) (Python package manager)
- [Nix](https://nixos.org/download.html) (optional, for development environment)
- [direnv](https://direnv.net/) (optional, for automatic environment activation)

Expand All @@ -42,61 +42,50 @@ This template provides a complete development environment for AI/ML applications

3. The Nix environment will automatically provide:
- Python 3.13
- All development tools (uv, ruff, pyrefly, etc.)
- All development tools (poetry, black, isort, flake8, pyrefly, etc.)
- Pre-commit hooks

#### Option 2: Without Nix (You already have Python)

1. Ensure Python 3.13+ is installed
2. Install uv:
2. Install Poetry:
```bash
pip install uv
pip install poetry
```
3. Install dependencies:
```bash
uv sync
```

#### Option 3: Using uv

1. [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
2. Install Python using uv:
```bash
uv python install 3.13
```
3. Install dependencies:
```bash
uv sync
poetry install
```

### Development Commands

#### Running the Application
```bash
uv run pai
poetry run pai
```

#### Testing
```bash
# Using Nix command
runTests

# Or directly with uv
uv run pytest --cov=pai --cov-report=term-missing --cov-report=html
# Or directly with poetry
poetry run pytest --cov=pai --cov-report=term-missing --cov-report=html

# Run specific tests
uv run pytest tests/pai/test_main.py::test_specific_function
poetry run pytest tests/pai/test_main.py::test_specific_function
```

#### Linting and Formatting
```bash
# Using Nix command
runLint

# Or individually with uv
uv run ruff format src # Format code
uv run ruff check --fix src # Lint and auto-fix
pyrefly check # Type checking
# Or individually with poetry
poetry run black src # Format code
poetry run isort src # Sort imports
poetry run flake8 src # Lint
poetry run pyrefly check # Type checking
```

#### Pre-commit Hooks
Expand Down Expand Up @@ -129,18 +118,18 @@ Core dependencies included:

1. **Make changes** to code in `src/pai/`
2. **Write tests** in `tests/` mirroring the source structure
3. **Run linting** with `runLint` or `uv run ruff check src`
4. **Run tests** with `runTests` or `uv run pytest`
3. **Run linting** with `runLint` or `poetry run flake8 src`
4. **Run tests** with `runTests` or `poetry run pytest`
5. **Commit** - pre-commit hooks will run automatically

## Adding Dependencies

```bash
# Add a production dependency
uv add <package-name>
poetry add <package-name>

# Add a development dependency
uv add --dev <package-name>
poetry add --group dev <package-name>
```

## Type Checking
Expand Down
7 changes: 3 additions & 4 deletions devshell.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ package = "python313"

[devshell]
packages = [
"pyrefly",
"uv"
"poetry"
]

[[commands]]
name = "runLint"
category = "development"
help = "Run the linter and formatter"
command = """\
uv run ruff format src && uv run ruff check --fix src && pyrefly check
poetry run black src && poetry run isort src && poetry run flake8 src && poetry run pyrefly check
"""

[[commands]]
name = "runTests"
category = "development"
help = "Run the tests"
command = """\
uv run pytest --cov=pai --cov-report=term-missing --cov-report=html
poetry run pytest --cov=pai --cov-report=term-missing --cov-report=html
"""
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading