-
Couldn't load subscription status.
- Fork 152
Open
Description
Bug Report
I am very confused, how the scope/context is applied resp. how _default_config is resolved.
My naive understanding was (before I moved the definitions to the module) that the scope/context is created at "init-time" and is somehow passed/"shining" from module level through the deeper schema tree... but now this issue confuses my a lot...
1. Minimal reproduce step (Required)
If I move schema/mixin/protocol definitions to a module a context var is not found: the working example is here
# INFO: this is in schemata.foo
protocol LoginProtocol:
a_url: str
b_url: str
mixin DefaultLoginMixin for LoginProtocol:
# INFO: If no a_url, b_url is defined in the final schema, we apply the
# value from _default_login
a_url: str = a_url or _default_login.a_url
b_url: str = b_url or _default_login.b_url
schema Config:
mixin [
DefaultLoginMixin
]
schema Stage:
[...str]: Config
_default_login: LoginProtocol
import schemata.foo
ci00 = foo.Stage {
# FIXME: how is _default_login reaching the mixin, when defined in one script,
# but not if the mixin is imported from a module?
_default_login = foo.LoginProtocol {
a_url = "https://default.a_url"
b_url = "https://default.b_url"
}
provider_1 = foo.Config {}
provider_2 = foo.Config {
# INFO: override the default
a_url = "https://custom.a_url"
b_url = "https://custom.b_url"
}
}
2. What did you expect to see? (Required)
ci00:
provider_1:
a_url: https://default.a_url
b_url: https://default.b_url
provider_2:
a_url: https://custom.a_url
b_url: https://custom.b_url
3. What did you see instead (Required)
EvaluationError
--> /home/olli/code/bm/integration-config/schemata/foo.k:8:1
|
8 | a_url: str = a_url or _default_login.a_url
| invalid value 'UndefinedType' to load attribute 'a_url'
|
4. What is your KCL components version? (Required)
❯ kcl --version
kcl version v0.10.8
Metadata
Metadata
Assignees
Labels
No labels