#!/bin/bash

set -euo pipefail

# Run from repository root
REPOROOT=$(git rev-parse --show-toplevel)
cd "${REPOROOT}"

if [ "$(command -v mypy)" ]; then
    # Point mypy at the redwood package with type stub, see second option on
    # <https://mypy.readthedocs.io/en/stable/stubs.html#creating-a-stub>.
    export MYPYPATH="./redwood"
    mypy ./securedrop ./admin --namespace-packages --explicit-package-bases "$@"
elif [ -d "/opt/venvs/securedrop-app-code/" ]; then
    # Inside the dev container, but no mypy
    echo "Could not find mypy"
    exit 1
else
    SLIM_BUILD=1 ./securedrop/bin/dev-shell ./bin/run-mypy
fi
