class WaitService:
_instance = None
def __new__(cls, name: str = "Default"):
if not cls._instance:
cls._instance = super(WaitService, cls).__new__(cls)
cls._instance.name = name
return cls._instance
if __name__ == '__main__':
w = WaitService("at till 9pm")
print(w.name)
I have a python singleton class above. It runs as expected but when I validate it with Mypy
, I get the errors below. Any ideas on how to resolve this
error: "WaitService" has no attribute "name" [attr-defined]
error: Function is missing a return type annotation [no-untyped-def]