(
annotation: ast.expr | None
)
| 1129 | |
| 1130 | @staticmethod |
| 1131 | def parse_converter( |
| 1132 | annotation: ast.expr | None |
| 1133 | ) -> tuple[str, bool, ConverterArgs]: |
| 1134 | match annotation: |
| 1135 | case ast.Constant(value=str() as value): |
| 1136 | return value, True, {} |
| 1137 | case ast.Name(name): |
| 1138 | return name, False, {} |
| 1139 | case ast.Call(func=ast.Name(name)): |
| 1140 | kwargs: ConverterArgs = {} |
| 1141 | for node in annotation.keywords: |
| 1142 | if not isinstance(node.arg, str): |
| 1143 | fail("Cannot use a kwarg splat in a function-call annotation") |
| 1144 | kwargs[node.arg] = eval_ast_expr(node.value) |
| 1145 | return name, False, kwargs |
| 1146 | case _: |
| 1147 | fail( |
| 1148 | "Annotations must be either a name, a function call, or a string." |
| 1149 | ) |
| 1150 | |
| 1151 | def parse_version(self, thenceforth: str) -> VersionTuple: |
| 1152 | """Parse Python version in `[from ...]` marker.""" |
no test coverage detected