Skip to content
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

Use strict marshmallow schemas, add custom exception #1695

Merged
merged 4 commits into from Jan 18, 2019

Conversation

diego-plan9
Copy link
Member

Summary

As a spiritual successor of sorts to #1642, this PR:

  • makes the parent qiskit.validation.base.BaseSchema "strict" (in practice, it raises an Exception directly when dumping/loading/validating), silencing that particular ChangedInMarshmallow3Warning.
  • introduces a custom exception for the qiskit.validation module, ModelValidationError. This brings the module in line with the project's philosophy, raising exceptions that inherit from QiskitError.
  • for the public interface, intercepts the exceptions raised due to the new strict parameter, and re-raises them as ModelValidationError.

Details and comments

In practice, it helps removing the ChangedInMarshmallow3Warning that could still appear under some conditions even after #1642 (such as importing the models without passing through qiskit._util), and the new exception helps third-party not having to add a dependency on marshmallow just for catching that exception

Add `strict=True` (as a `Meta` attribute) to the validation schemas,
avoiding the marshmallow deprecation warning.
Add custom Exception class to `qiskit.validation.exceptions`, for
conforming to qiskit convention that only subclasses of `QiskitError`
should be raised by the library.
@jaygambetta jaygambetta merged commit bc71082 into Qiskit:master Jan 18, 2019
@diego-plan9 diego-plan9 deleted the fix/marshmallow-strict branch January 18, 2019 13:59
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Use strict schemas for validation

Add `strict=True` (as a `Meta` attribute) to the validation schemas,
avoiding the marshmallow deprecation warning.

* Add custom Exception to qiskit.validation

Add custom Exception class to `qiskit.validation.exceptions`, for
conforming to qiskit convention that only subclasses of `QiskitError`
should be raised by the library.

* Rename exception to ModelValidationError

* Update CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants