Handling ua.UaError exceptions #1059
-
I was going to submit a bug, but wasn't sure if it is. It looks like a bug to me, but maybe not others. If I understand correctly ua.UaError is the base class for all errors/exceptions, one problem I noted is that if you use ua.UaError you'll get a linter error saying code doesn't exist and rightly so since the base class is empty. class UaError(RuntimeError):
pass
class ServiceError(UaError):
def __init__(self, code):
super().__init__('UA Service Error')
self.code = code Shouldn't UaError base class have a dunder init with code, and subclasses use super init? Or is this design deliberate for some other reason? class UaError(RuntimeError):
def __init__(self, code):
self.code = code
class ServiceError(UaError):
def __init__(self, code):
super().__init__(code) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
It is a error from the linter. When you don't specify a init method, the init from the parent class will be called. In this case the init from RuntimeError is called. RuntimeError init accepts a str as arguments. |
Beta Was this translation helpful? Give feedback.
-
These errors are the errors defined by spec. If you can show that the spec says we should raise an UaError in some situations then we should allow it. |
Beta Was this translation helpful? Give feedback.
It is a error from the linter. When you don't specify a init method, the init from the parent class will be called. In this case the init from RuntimeError is called. RuntimeError init accepts a str as arguments.