Add feature to get the signature representation of a Python function argument

This commit is contained in:
jakob.scheid committed 2026-04-13 12:19:08 +02:00
1 parent 10707d680d
commit a8626418da
4 files changed
+86 -8

No files matched your search

+17 -1
View File
@@ -60,4 +60,20 @@ class PythonAnnotationError(ValueError):
else:
return f'{self.args[0]}{": " if self.annotation and self.args[0] else ""}{self.annotation if self.args[0] else ""}'
class InvalidPythonAnnotationError(PythonAnnotationError): ...
class InvalidPythonAnnotationError(PythonAnnotationError): ...
class PythonDefinitionError(ValueError):
'''
Base class for Python definition errors.
'''
def __init__(self, *args: object, definition: str = '') -> None:
super().__init__(*args)
self.definition = definition
def __str__(self):
if not self.args:
return ''
else:
return f'{self.args[0]}{": " if self.definition and self.args[0] else ""}{self.definition if self.args[0] else ""}'
class PythonArgumentStructureError(PythonDefinitionError): ...