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

RecursionError in LocalFileStorage #380

Closed
lilyminium opened this issue Sep 18, 2021 · 2 comments · Fixed by #387
Closed

RecursionError in LocalFileStorage #380

lilyminium opened this issue Sep 18, 2021 · 2 comments · Fixed by #387

Comments

@lilyminium
Copy link
Contributor

@property
def root_directory(self):
"""str: Returns the directory in which all stored objects are located."""
return self.root_directory

This recursive call means the property is not really very helpful.

>>> from openff.evaluator.storage import LocalFileStorage
>>> lfs = LocalFileStorage()
>>> lfs.root_directory
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lily/anaconda3/envs/polymetrizer/lib/python3.9/site-packages/openff/evaluator/storage/localfile.py", line 21, in root_directory
    return self.root_directory
  File "/Users/lily/anaconda3/envs/polymetrizer/lib/python3.9/site-packages/openff/evaluator/storage/localfile.py", line 21, in root_directory
    return self.root_directory
  File "/Users/lily/anaconda3/envs/polymetrizer/lib/python3.9/site-packages/openff/evaluator/storage/localfile.py", line 21, in root_directory
    return self.root_directory
  [Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded

My suggestion would be to just not privatize attributes with getter/setters, as I think it adds burden to code maintenance and is liable to bugs such as the one reported here. (The actual attribute used is _root_directory.)

@SimonBoothroyd
Copy link
Contributor

My suggestion would be to just not privatize attributes with getter/setters, as I think it adds burden to code maintenance and is liable to bugs such as the one reported here. (The actual attribute used is _root_directory.)

This is a pretty common code pattern and gives a bit of safeguarding in case you later change the internal code to not be resilient to external changes of this variable - I think the main issue here is bad testing and not necessarily maintenance burden!

A PR containing the typo fix + test would be welcome 🙂

@lilyminium
Copy link
Contributor Author

lilyminium commented Sep 30, 2021

This is a pretty common code pattern and gives a bit of safeguarding in case you later change the internal code

Sure, I suppose I am a fervent follower of YAGNI and think it's fairly easy to change an attribute to a managed property -- if anything, this kind of code encourages me to use the "private" attribute because the public one can't really be used -- but we all have different styles :-)

I think the main issue here is bad testing and not necessarily maintenance burden!

I think of needing to write and maintain additional tests as maintenance burden!

SimonBoothroyd added a commit that referenced this issue Oct 5, 2021
@SimonBoothroyd SimonBoothroyd mentioned this issue Oct 5, 2021
1 task
SimonBoothroyd added a commit that referenced this issue Oct 5, 2021
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 a pull request may close this issue.

2 participants