-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate Assigned Types #342
Comments
yes it should but unfortunately unless we require types to derive from the root tosca types (like tosca.interfaces.Root or tosca.nodes.Root) it would be hard to check that. I'm thinking maybe issue a warning if the type isn't derived from one of those and do the validation check when they are. import tosca
from tosca import ArtifactEntity, Interface, Node
class my_interface_type(tosca.interfaces.Root):
pass
my_app: Node = my_interface_type(
"my_app",
)
__my_app_my_artifact: ArtifactEntity = my_interface_type(
"my_artifact",
file="my_artifact_file",
)
my_app.my_artifact = __my_app_my_artifact # type: ignore[attr-defined] Running mypy on that will find all the validation errors and if you open it in an IDE VS-Code it will highlight the errors as you type them. I think it's a much better experience than writing in YAML. |
Interesting that the Python DSL would catch this.
I don't think that is even required. |
Good point -- that does make validation a lot easier! So yeah, I'll add it soon... |
…entity type (fixes #342 but disabled for now unless UNFURL_VALIDATION_MODE env var includes "types"). Enable this in unit tests.
Following #341, it would be great if there is a validation that, e.g., an interface type can not be assigned to a node template or artifact definition.
The following simple example does not throw a validation error even tho an interface type is assigned to a node template and artifact definition.
I tried this on Unfurl v1.0.0 and v1.1.0.
Best regards
Miles
The text was updated successfully, but these errors were encountered: