Skip to content

Code Style

Coding standards for Flux contributions.

Formatting

We use: - Black for code formatting - Ruff for linting - mypy for type checking

# Format code
black .

# Check linting
ruff check .

# Fix auto-fixable issues
ruff check --fix .

# Type check
mypy flux/

Python Style

Type Hints

# Good
def process(items: list[str], count: int = 10) -> dict[str, int]:
    ...

# Bad
def process(items, count=10):
    ...

Docstrings

def compute_reward(
    trajectory: Trajectory,
    threshold: float = 0.5,
) -> RewardOutput:
    """Compute reward for trajectory.

    Args:
        trajectory: Input trajectory.
        threshold: Minimum score threshold.

    Returns:
        RewardOutput with computed reward.

    Raises:
        ValueError: If trajectory is invalid.
    """

Naming

  • Classes: PascalCase
  • Functions: snake_case
  • Constants: UPPER_SNAKE_CASE
  • Private: _leading_underscore

Pre-commit

All checks run automatically on commit:

pre-commit run --all-files

See Also