generated from jCloud/repository-template
Add classes for Python function arguments
This commit is contained in:
6 files changed
+508
-2
No files matched your search
@@ -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): ...
|
||||
Reference in new issue
Block a user