Closed diefans closed 2 months ago
Hello you can set the full_pkg
parameter to True
of the schema.instances to see all schema instances. e.g.,
print("# v1/main.k #####")
print("v1.Base instances in v1/main.k: ", Base.instances(True))
print("v1.Config instances in v1/main.k: ", Config.instances(True))
print("v1.FooConfig instances in v1/main.k: ", FooConfig.instances(True))
print("\n\n")
and
print("# foo/bar/test.k #####")
print("v1.Base instances in foo/bar/test.k ${len(v1.Base.instances())}:", v1.Base.instances(True))
print("\nv1.Config instances in foo/bar/test.k ${len(v1.Config.instances())}:", v1.Config.instances(True))
print("\nv1.FooConfig instances in foo/bar/test.k ${len(v1.FooConfig.instances())}:", v1.FooConfig.instances(True))
print("\n\n")
Because obtaining instances across packages is a side effect function, by default only schema instances from the main package will be obtained.
@Peefy ... so I guess then it is a documentation issue at https://www.kcl-lang.io/docs/reference/lang/spec/schema#members this parameter is never mentioned...
Thank you for your fast reply!
Thank you! I will add the lost document with this feature.
...so I tested with this parameter and confirm that it is working...
Bug Report
While testing
instances()
I observed a strange behavior, where instances are lost.1. Minimal reproduce step (Required)
I have prepared everything in https://github.com/bettermarks/klc-instances-issue
2. What did you expect to see? (Required)
ìnstances()
returns all instances of all sub schemas3. What did you see instead (Required)
Instances are lost, if they are derived from an imported module schema at the second inheritance level.
4. What is your KCL components version? (Required)
v0.10.0-beta.2