MCPcopy Create free account
hub / github.com/astral-sh/ruff / parse_minimum_python

Function parse_minimum_python

scripts/collect_ty_ecosystem_run_metadata.py:127–143  ·  view source on GitHub ↗
(source: str)

Source from the content-addressed store, hash-verified

125
126
127def parse_minimum_python(source: str) -> tuple[int, int]:
128 tree = ast.parse(source)
129 for node in tree.body:
130 if not isinstance(node, ast.Assign):
131 continue
132 if not any(
133 isinstance(target, ast.Name) and target.id == "MINIMUM_PYTHON_VERSION"
134 for target in node.targets
135 ):
136 continue
137 value = ast.literal_eval(node.value)
138 if isinstance(value, tuple) and len(value) == 2:
139 major, minor = value
140 if isinstance(major, int) and isinstance(minor, int):
141 return (major, minor)
142 break
143 raise MetadataError("could not parse ecosystem-analyzer MINIMUM_PYTHON_VERSION")
144
145
146def parse_mypy_primer_revision(pyproject: str) -> str:

Callers 1

collect_metadataFunction · 0.85

Calls 5

isinstanceFunction · 0.85
lenFunction · 0.85
MetadataErrorClass · 0.85
anyFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected