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

Function get_current_version

mirror.py:48–58  ·  view source on GitHub ↗
(pyproject: dict)

Source from the content-addressed store, hash-verified

46
47
48def get_current_version(pyproject: dict) -> Version:
49 requirements = [Requirement(d) for d in pyproject["project"]["dependencies"]]
50 requirement = next((r for r in requirements if r.name == "ruff"), None)
51 assert requirement is not None, "pyproject.toml does not have ruff requirement"
52
53 specifiers = list(requirement.specifier)
54 assert (
55 len(specifiers) == 1 and specifiers[0].operator == "=="
56 ), f"ruff's specifier should be exact matching, but `{requirement}`"
57
58 return Version(specifiers[0].version)
59
60
61def process_version(version: Version) -> typing.Sequence[str]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected