| 59 | |
| 60 | |
| 61 | def process_version(version: Version) -> typing.Sequence[str]: |
| 62 | def replace_pyproject_toml(content: str) -> str: |
| 63 | return re.sub(r'"ruff==.*"', f'"ruff=={version}"', content) |
| 64 | |
| 65 | def replace_readme_md(content: str) -> str: |
| 66 | content = re.sub(r"rev: v\d+\.\d+\.\d+", f"rev: v{version}", content) |
| 67 | content = re.sub(r'rev = "v\d+\.\d+\.\d+"', f'rev = "v{version}"', content) |
| 68 | return re.sub(r"/ruff/\d+\.\d+\.\d+\.svg", f"/ruff/{version}.svg", content) |
| 69 | |
| 70 | paths = { |
| 71 | "pyproject.toml": replace_pyproject_toml, |
| 72 | "README.md": replace_readme_md, |
| 73 | } |
| 74 | |
| 75 | for path, replacer in paths.items(): |
| 76 | with open(path) as f: |
| 77 | content = replacer(f.read()) |
| 78 | with open(path, mode="w") as f: |
| 79 | f.write(content) |
| 80 | |
| 81 | return tuple(paths.keys()) |
| 82 | |
| 83 | |
| 84 | if __name__ == "__main__": |