MCPcopy
hub / github.com/astral-sh/ruff-pre-commit / process_version

Function process_version

mirror.py:61–81  ·  view source on GitHub ↗
(version: Version)

Source from the content-addressed store, hash-verified

59
60
61def 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
84if __name__ == "__main__":

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected