-
Notifications
You must be signed in to change notification settings - Fork 175
Description
Description
The databricks.sdk.Config class uses the get_annotations function from the inspect module together with checking for the classes __dict__ to resolve a lot of its attributes. This happens in the attributes property of the aforementioned Config class, that is later called when loading stuff from the environment, and in a bunch more other places.
The problem is that get_annotations does not check for inherited annotations, like the docs say:
Ignores inherited annotations on classes. If a class doesn’t have its own annotations dict, returns an empty dict.
Similarly, the attributes classmethod is checking the class' __dict__, which doesn't resolve class attributes from the parent class.
This means that any attempts to subclass the Config class are likely to be met with an AttributeError as none of the ConfigAttributes are properly initialized. Depending on where this error is raised, it may be re-raised as something else.
Reproduction
from databricks.sdk.core import Config
class MyConfig(Config):
pass
MyConfig(host="my-host", client_id="my-id", client_secret="my-secret")
I'm using fake credentials here for security reasons, but replacing these with valid credentials leads to a ValueError: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method..
Expected behavior
If a subclass is not overriding any of the Config methods it should just work. I can also make this work by just passing the attributes I need to the MyConfig class, but it means the MyConfig class cannot load them from the environment, like it should.
Is it a regression?
Did this work in a previous version of the SDK? If so, which versions did you try?
Tried latest 0.67.0. Not sure if it happens before.
Debug Logs
No logs at the moment.
Other Information
- OS: Linux.
- Version: Latest kernel.
Additional context
Add any other context about the problem here.