-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Hack in SimpleNamespace-like functionality to Options #7347
Conversation
This is an awful hack to support various SimpleNamespace-like operations that qiskit-dynamics are using. We need to transition downstream packages to the new Options API, but in the meantime, this makes the Options class behave as much like a SimpleNamespace as it can, while still keeping the new instance attributes and methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, thanks for figuring all these hairy things out. Before we tag it automerge
and put it in the merge queue though we should verify it works for qiskit-experiments. @eggerdj @nkanazawa1989 @chriseclectic if you could test this that would be great.
Pull Request Test Coverage Report for Build 1532598027
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran qiskit-experiments tests locally with this branch and had no failures
I was surprised at how little pylint complained about the actual implementation, but it complains about the usage. This could conceivably be called a pylint bug; because we override `__setattr__`, pylint should perhaps recognise that general attribute setting might be allowed.
d6ab60f
It's possible that |
Summary
This is an awful hack to support various SimpleNamespace-like operations
that qiskit-experiments are using. We need to transition downstream
packages to the new Options API, but in the meantime, this makes the
Options class behave as much like a SimpleNamespace as it can, while
still keeping the new instance attributes and methods.
Details and comments
This passes the
qiskit-experiments
tests on my machine. The real problem is howqiskit-experiments
accessesoptions.__dict__
, so this involves some terrible behaviour to make that work as expected.It's an absolutely horrific hack, and I regret ever learning Python.
@eggerdj - this passes the tests on my machine, but could you check it does everything you need as well?