Add classes for Python function arguments

This commit is contained in:
jakob.scheid committed 2026-04-11 13:33:42 +02:00
1 parent d0e4ae54c3
commit 91cecae230
6 files changed
+508 -2

No files matched your search

+33 -1
View File
@@ -28,4 +28,36 @@ class NamespaceError(ValueError):
class InvalidNamespaceError(NamespaceError): ...
class NamespaceNotFoundError(NamespaceError): ...
class NamespaceExistsError(NamespaceError): ...
class NamespaceExistsError(NamespaceError): ...
class PythonIdentifierError(ValueError):
'''
Base class for Python identifier errors.
'''
def __init__(self, *args: object, identifier: str = '') -> None:
super().__init__(*args)
self.identifier = identifier
def __str__(self):
if not self.args:
return ''
else:
return f'{self.args[0]}{": " if self.identifier and self.args[0] else ""}{self.identifier if self.args[0] else ""}'
class InvalidPythonIdentifierError(PythonIdentifierError): ...
class PythonAnnotationError(ValueError):
'''
Base class for Python annotation errors.
'''
def __init__(self, *args: object, annotation: str = '') -> None:
super().__init__(*args)
self.annotation = annotation
def __str__(self):
if not self.args:
return ''
else:
return f'{self.args[0]}{": " if self.annotation and self.args[0] else ""}{self.annotation if self.args[0] else ""}'
class InvalidPythonAnnotationError(PythonAnnotationError): ...