(source: str)
| 143 | |
| 144 | |
| 145 | def 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 | |
| 164 | def parse_mypy_primer_revision(pyproject: str) -> str: |
no test coverage detected