You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
running main
in if
items:
- namespace: default_namespace
3. What did you see instead (Required)
running main
In if
In if
In if
default_namespace
default_namespace
items:
- namespace: default_namespace
It feels like the program goes multiple times in the if 🤔 ? Adding the print(_namespace) and _items = [{"namespace": _namespace}] brought 2 more "In if". Accessing more the _namespace variable (using print or otherwise) would not add more "In if"...
The end result of the execution is correct, but this is confusing when trying to debug things.
Maybe something I am not doing right? Please advise.
Thx!
4. What is your KCL components version? (Required)
kcl version 0.11.0
The text was updated successfully, but these errors were encountered:
Here's my example where this behavior affects not only prints but also the rendered data:
import manifests
schema ThingsMixin:
enable: bool = False
things: [str] = []
if enable:
print("enabled")
things += ["default_thing"]
print("checking for java")
if language == "java":
things += ["java_thing"]
print("added java thing")
print("checking for python")
if language.startswith("python"):
things += ["python_thing"]
print("added python thing")
schema Things:
mixin [ThingsMixin]
language: str = "other"
_res: [str] = []
_res += things
res: [str] = _res
t = Things {
enable = True
language = "java"
}
renders to
enabled
enabled
enabled
checking for java
checking for java
added java thing
checking for python
enabled
checking for java
added java thing
checking for python
t:
language: java
res:
- default_thing
- java_thing
- java_thing
enable: true
things:
- default_thing
- java_thing
Double java_thing in res shouldn't be there I guess.
If I use ternary to fill things, the result is correct.
(I use this ternary: (things: [str] = (["default_thing"] + (["java_thing"] if language == "java" else []) + (["python_thing"] if language.startswith("python") else [])) if enable else [])
Bug Report
1. Minimal reproduce step (Required)
2. What did you expect to see?
I would expect to see in the terminal:
3. What did you see instead (Required)
It feels like the program goes multiple times in the if 🤔 ? Adding the print(_namespace) and _items = [{"namespace": _namespace}] brought 2 more "In if". Accessing more the _namespace variable (using print or otherwise) would not add more "In if"...
The end result of the execution is correct, but this is confusing when trying to debug things.
Maybe something I am not doing right? Please advise.
Thx!
4. What is your KCL components version? (Required)
kcl version 0.11.0
The text was updated successfully, but these errors were encountered: