def bump_version(version):
    'Update the version number in setup.py, docs config, changelog,\n    and root module.\n    '
    version_parts = [int(p) for p in version.split('.')]
    assert (len(version_parts) == 3), 'invalid version number'
    minor = '{}.{}'.format(*version_parts)
    major = '{}'.format(*version_parts)
    for (filename, locations) in VERSION_LOCS:
        out_lines = []
        with open(filename) as f:
            found = False
            for line in f:
                for (pattern, template) in locations:
                    match = re.match(pattern, line)
                    if match:
                        old_version = match.group(1)
                        old_parts = [int(p) for p in old_version.split('.')]
                        assert (version_parts > old_parts), 'version must be newer than {}'.format(old_version)
                        out_lines.append((template.format(version=version, major=major, minor=minor) + '\n'))
                        found = True
                        break
                else:
                    out_lines.append(line)
            if (not found):
                print(f'No pattern found in {filename}')
        with open(filename, 'w') as f:
            f.write(''.join(out_lines))
    header_line = f'{version} (in development)'
    header = (((('\n\n' + header_line) + '\n') + ('-' * len(header_line))) + '\n\n')
    header += 'Changelog goes here!\n'
    with open(CHANGELOG) as f:
        contents = f.read()
    location = contents.find('\n\n')
    contents = ((contents[:location] + header) + contents[location:])
    with open(CHANGELOG, 'w') as f:
        f.write(contents)
Update the version number in setup.py, docs config, changelog,
and root module.
def bump_version(version):
    'Update the version number in setup.py, docs config, changelog,\n    and root module.\n    '
    version_parts = [int(p) for p in version.split('.')]
    assert (len(version_parts) == 3), 'invalid version number'
    minor = '{}.{}'.format(*version_parts)
    major = '{}'.format(*version_parts)
    for (filename, locations) in VERSION_LOCS:
        out_lines = []
        with open(filename) as f:
            found = False
            for line in f:
                for (pattern, template) in locations:
                    match = re.match(pattern, line)
                    if match:
                        old_version = match.group(1)
                        old_parts = [int(p) for p in old_version.split('.')]
                        assert (version_parts > old_parts), 'version must be newer than {}'.format(old_version)
                        out_lines.append((template.format(version=version, major=major, minor=minor) + '\n'))
                        found = True
                        break
                else:
                    out_lines.append(line)
            if (not found):
                print(f'No pattern found in {filename}')
        with open(filename, 'w') as f:
            f.write(.join(out_lines))
    header_line = f'{version} (in development)'
    header = (((('\n\n' + header_line) + '\n') + ('-' * len(header_line))) + '\n\n')
    header += 'Changelog goes here!\n'
    with open(CHANGELOG) as f:
        contents = f.read()
    location = contents.find('\n\n')
    contents = ((contents[:location] + header) + contents[location:])
    with open(CHANGELOG, 'w') as f:
        f.write(contents)