#!/usr/bin/env bash

# Cause the script to exit if a single command fails
set -e  # o pipefail -v

# Force isort to recognize modules as being part of the current python project.
# Defaults to modules of catalyst ecosystem.
PROJECT=${PROJECT:="catalyst,catalyst_codestyle,catalyst_rl,alchemy,reaction"}

# The max length of an import line (used for wrapping long imports).
# Defaults to 99 chars, suggested by PEP.
LINE_LENGTH=${LINE_LENGTH:=99}


isort --project "${PROJECT}" \
  --combine-as \
  --dont-order-by-type \
  --force-grid-wrap 0 \
  --force-sort-within-sections \
  --line-width "${LINE_LENGTH}" \
  --lines-between-types 0 \
  --multi-line 3 \
  --no-lines-before STDLIB,LOCALFOLDER \
  --reverse-relative \
  --section-default THIRDPARTY \
  --skip-glob "**/__init__.py" \
  --top typing \
  --trailing-comma \
  --use-parentheses \
  "$@"
