(source: str)
| 125 | |
| 126 | |
| 127 | def 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 | |
| 146 | def parse_mypy_primer_revision(pyproject: str) -> str: |
no test coverage detected