AttributeError: type object 'type' has no attribute '__annotations__'
erhosen opened this issue · 2 comments
erhosen commented
Hi!
Im trying to initialize my config via load method:
class Config:
SECRET: 'opitem:"Secret key" opvault:vault_id opfield:.password' = None
onepasswordconnectsdk.load(client, Config)
But I have the error on this line
Traceback (most recent call last):
File "/usr/local/lib/python3.9/code.py", line 90, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/onepasswordconnectsdk/config.py", line 110, in load
annotations = config.__class__.__annotations__
AttributeError: type object 'type' has no attribute '__annotations__'
The correct way of getting annotations is
annotations = config.__annotations__
Python 3.9
onepasswordconnectsdk==1.0.1
jpcoenen commented
Hi 👋
Thank you for giving the Connect Python SDK a try! We greatly appreciate your feedback.
It looks like the documentation for the loading into an objects using annotations is a little outdated and needs some work. But for now, it's good to know that load()
needs a reference to an object. In your specific example, this can be done by instantiating the object before passing it to load()
:
class Config:
SECRET: 'opitem:"Secret key" opvault:vault_id opfield:.password' = None
config = Config()
onepasswordconnectsdk.load(client, config)
Could you let me know if that fixes the issues?
erhosen commented
Thank you for your response. I will definitely try it soon!