| 969 | |
| 970 | @classmethod |
| 971 | def _from_str(cls, text): |
| 972 | orig = text |
| 973 | inline, sep, text = text.partition('|') |
| 974 | if not sep: |
| 975 | text = inline |
| 976 | inline = None |
| 977 | |
| 978 | isforward = False |
| 979 | if text.endswith(';'): |
| 980 | text = text[:-1] |
| 981 | isforward = True |
| 982 | elif text.endswith('{}'): |
| 983 | text = text[:-2] |
| 984 | |
| 985 | index = text.rindex('(') |
| 986 | if index < 0: |
| 987 | raise ValueError(f'bad signature text {orig!r}') |
| 988 | params = text[index:] |
| 989 | while params.count('(') <= params.count(')'): |
| 990 | index = text.rindex('(', 0, index) |
| 991 | if index < 0: |
| 992 | raise ValueError(f'bad signature text {orig!r}') |
| 993 | params = text[index:] |
| 994 | text = text[:index] |
| 995 | |
| 996 | returntype = VarType._from_str(text.rstrip()) |
| 997 | |
| 998 | return cls(params, returntype, inline, isforward) |
| 999 | |
| 1000 | def __str__(self): |
| 1001 | parts = [] |