# Copyright 2017 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

require github [ user="python" ]
require pypi
require setup-py [ import=setuptools blacklist=2 ]

SUMMARY="Optional static typing for Python"
DESCRIPTION="
Add type annotations to your Python programs, and use mypy to type
check them.  Mypy is essentially a Python linter on steroids, and it
can catch many programming errors by analyzing your program, without
actually having to run it.  Mypy has a powerful type system with
features such as type inference, gradual typing, generics and union
types.
"
HOMEPAGE="http://www.mypy-lang.org ${HOMEPAGE}"

LICENCES="MIT"
SLOT="0"
PLATFORMS="~amd64 ~x86"
MYOPTIONS=""

DEPENDENCIES="
    build+run:
        dev-python/typed-ast[>=1.1.0&<1.2.0][python_abis:*(-)?]
        dev-python/mypy_extensions[>=0.4.0&<0.5.0][python_abis:*(-)?]
        python_abis:3.4? (
            dev-python/typing[>=3.5.3][python_abis:3.4]
        )
    test:
        dev-python/py[>=1.5.2][python_abis:*(-)?]
        dev-python/pytest[>=3.0][python_abis:*(-)?]
        dev-python/pytest-cov[>=2.4.0][python_abis:*(-)?]
        dev-python/pytest-xdist[>=1.18][python_abis:*(-)?]
        dev-python/virtualenv[python_abis:*(-)?]
    suggestion:
        dev-python/psutil[>=5.4.0&<5.5.0][python_abis:*(-)?] [[
            description = [ Show memory stats in 'dmypy status -v' ] ]]
"

BUGS_TO="hasufell@posteo.de"

# Require upstream release with https://github.com/python/mypy/pull/5191 included
# Require unpackaged: flake8-bugbear, flake8-pyi
RESTRICT="test"

prepare_one_multibuild() {
    edo sed -i \
            -e "/target = /s|lib|$(exhost --target)/lib|" \
            setup.py

    setup-py_prepare_one_multibuild
}

test_one_multibuild() {
    PYTHONPATH="${PWD}" edo ${PYTHON} -B runtests.py -x lint
}