PsiQ / qref

Quantum Resource Estimate Format
https://psiq.github.io/qref/
Apache License 2.0
34 stars 3 forks source link

Fix issues with connection validation #108

Closed dexter2206 closed 4 months ago

dexter2206 commented 4 months ago

Description

Currently, we use field_validator for validating if all endpoints in all connections exist. However, the problem with this approach is that it relies on children of a routine being successfully validated prior to validating connections. In a likely event that a child fails to validate, the "children" key will not be present in validation data, and the validator for connections will fail with a TypeError. This PR fixes this by reimplementing connection validator as model_validator that runs iff per-field builtin validators run successfully (otherwise validating connection endpoints is meaningless).

In addition, this PR fixes a hidden problem of incorrect loading of negative testcases for pydantic model validation. Currently, those tests passed trivially (!) because the loaded data consisted of tuples instead of dictionaries.

The documentation has not been updated because the changes are not user-facing, and modified internal parts are not described in the docs.

Please verify that you have completed the following steps