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

ParameterAttribute does not implement __delete__ #1680

Open
mattwthompson opened this issue Aug 2, 2023 · 0 comments
Open

ParameterAttribute does not implement __delete__ #1680

mattwthompson opened this issue Aug 2, 2023 · 0 comments
Labels

Comments

@mattwthompson
Copy link
Member

Describe the bug

Class attributes are meant to be removed by __delete__, but this doesn't seem to be implemented. ParameterAttribute otherwise follows the descriptor pattern by defining __set__ and __get__.

To Reproduce

In [1]: from openff.toolkit.typing.engines.smirnoff.parameters import BondHandler

In [2]: handler = BondHandler(version=0.4)

In [3]: delattr(handler, "fractional_bondorder_method")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 delattr(handler, "fractional_bondorder_method")

AttributeError: __delete__

In [4]: del handler.fractional_bondorder_method
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[4], line 1
----> 1 del handler.fractional_bondorder_method

AttributeError: __delete__

Output

Additional context

We don't have much of a habit of deleting attributes; if they exist, it's usually for good reason. The existing up-converters are blind to this issue because they muck around with a keyword arguments dictionary before setting anything on an object. But there are cases in which one would want to change a handler in-memory, including deleting attributes.

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

No branches or pull requests

1 participant