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

Function parse_minimum_python

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

Source from the content-addressed store, hash-verified

143
144
145def parse_minimum_python(source: str) -> tuple[int, int]:
146 tree = ast.parse(source)
147 for node in tree.body:
148 if not isinstance(node, ast.Assign):
149 continue
150 if not any(
151 isinstance(target, ast.Name) and target.id == "MINIMUM_PYTHON_VERSION"
152 for target in node.targets
153 ):
154 continue
155 value = ast.literal_eval(node.value)
156 if isinstance(value, tuple) and len(value) == 2:
157 major, minor = value
158 if isinstance(major, int) and isinstance(minor, int):
159 return (major, minor)
160 break
161 raise MetadataError("could not parse ecosystem-analyzer MINIMUM_PYTHON_VERSION")
162
163
164def 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