def is_canonical(version, loosedev=False):  # type: (str, bool) -> bool
    """
    Return whether or not the version string is canonical according to Pep 440
    """
    if loosedev:
        return loose440re.match(version) is not None
    return pep440re.match(version) is not None