Skip to content

Development

Commands and workflows for developing with Reflex.

๐Ÿ› ๏ธ Development Commands

make dev          # Start with hot reload
make dev-build    # Rebuild and start
make dev-down     # Stop containers
make logs         # Follow app logs
make shell        # Shell into app container
make db-shell     # psql into PostgreSQL
# Start PostgreSQL
docker compose up db -d

# Run the app with hot reload
uv run uvicorn reflex.api.app:app --reload

# Run the demo
make demo

๐Ÿงช Testing

make test         # Run all tests in Docker
make test-cov     # Run with coverage report

Running Tests Locally

pytest tests/
pytest tests/test_file.py::test_name
# No database required
pytest tests/ -m "not asyncio"
# Requires DATABASE_URL
DATABASE_URL="postgresql://..." pytest tests/test_store.py

Test Fixtures

Tests use mock fixtures from tests/conftest.py:

def test_something(mock_store, mock_deps):
    # mock_store: AsyncMock with publish/subscribe/ack/nack
    # mock_deps: ReflexDeps with all mocked dependencies
    pass

Integration tests use real fixtures:

@pytest.mark.asyncio
async def test_integration(store, real_deps):
    # store: Real EventStore connected to PostgreSQL
    # real_deps: ReflexDeps with real dependencies
    pass

โœ… Code Quality

make lint         # ruff check
make lint-fix     # Auto-fix lint issues
make format       # ruff format
make type-check   # pyright
make ci           # Run full CI pipeline locally

CI Pipeline

The make ci command runs the same checks as GitHub Actions:

  1. Lint check (ruff check)
  2. Format check (ruff format --check)
  3. Type check (pyright)
  4. Tests (pytest)

๐Ÿ“ Code Style

Style Guidelines

  • Python 3.11+
  • Strict pyright type checking
  • ruff for linting (includes async, security, bugbear rules)
  • Line length: 100 characters

Import Conventions

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    # Type-only imports to avoid circular dependencies
    from reflex.core.deps import ReflexDeps

๐Ÿ“š Documentation

make docs         # Serve docs locally at http://localhost:8000
make docs-build   # Build static docs site