<commit_before>
"""
A simple package with utils to check whether versions number match PEP 440.

https://www.python.org/dev/peps/pep-0440/


Example

>>> from pep440 import is_valid
>>> is_valid('4.1.0')
True

>>> is_valid('4.2.1.beta2')  # 4.2.1b2 is correct
False

"""


__version__ = '0.0.1'

import re


pep440re = re.compile('^([1-9]\d*!)?'        # [N!]
                      '([1-9]\d*)'           # N
                      '(.[1-9]\d*)*'         # (.N)*
                      '((a|b|rc)[0-9]\d*)?' # [{a|b|rc}N]
                      '(\.post[1-9]\d*)?'         # [.postN]
                      '(\.dev[1-9]\d*)?$'         # [.devN]
                      )

def is_valid(version):
    return pep440re.match(version) is not None

def assert_valid(version):
    if not is_valid(version):
        raise ValueError("Version string {!r} does not match PEP 440 specification".format(version))
        <commit_msg>Name things after T. Kluyver comment: `is_canonical`<commit_after>
"""
A simple package with utils to check whether versions number match PEP 440.

https://www.python.org/dev/peps/pep-0440/


Example

>>> from pep440 import is_valid
>>> is_valid('4.1.0')
True

>>> is_valid('4.2.1.beta2')  # 4.2.1b2 is correct
False

"""


__version__ = '0.0.1'

import re


pep440re = re.compile('^([1-9]\d*!)?'        # [N!]
                      '([1-9]\d*)'           # N
                      '(.[1-9]\d*)*'         # (.N)*
                      '((a|b|rc)[0-9]\d*)?' # [{a|b|rc}N]
                      '(\.post[1-9]\d*)?'         # [.postN]
                      '(\.dev[1-9]\d*)?$'         # [.devN]
                      )

def is_canonical(version)->bool:
    """
    Retunr wether or not the version string is canonical according to Pep 440
    """
    return pep440re.match(version) is not None

def assert_valid(version):
    if not is_canonical(version):
        raise AssertionError("Version string {!r} does not match PEP 440 specification".format(version))
        
{'fraction_non_alphanumeric': 0.17970721857647654, 'fraction_numerical': 0.046945986875315496, 'mean_word_length': 1.8153409090909092, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7276005', 'n_tokens_mistral': 752, 'n_tokens_neox': 689, 'n_words': 151}