from pathlib import Path import tomlkit from packaging.version import Version c_file = Path(__file__) pyproject = c_file.parent.parent / "pyproject.toml" with pyproject.open("r") as f: data = tomlkit.load(f) version = Version(data["project"]["version"]) # type: ignore data["project"]["version"] = str( # type: ignore Version(f"{version.major}.{version.minor}.{version.micro + 1}") ) with pyproject.open("w") as f: tomlkit.dump(data, f)