from typing import TypeVar

from ..math.mittagleffler import mlf


ArrayLike = TypeVar('ArrayLike')


def valid_function(expr: str, extra_namespace: dict = None):

    local = {'mlf': mlf}
    if extra_namespace is not None:
        local.update(extra_namespace)

    try:
        return ne.evaluate(expr, {}, local), True
    except:
        return None, False


def open_bug_report():
    form_entries = {
        'description': 'Please state the nature of the medical emergency.',
        'title': 'Everything is awesome?',
        'assign[0]': 'dominik',
        'subscribers[0]': 'dominik',
        'tag': 'nmreval',
        'priority': 'normal',
        'status': 'open',
    }
    full_url = 'https://chaos3.fkp.physik.tu-darmstadt.de/maniphest/task/edit/?'

    for k, v in form_entries.items():
        full_url += f'{k}={v}&'
    full_url.replace(' ', '+')

    import webbrowser
    webbrowser.open(full_url)
