harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
37 stars 30 forks source link

Change simple instance methods to getters where appropriate #1865

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

This is a minor cleanup but touches on something I'll use in #1860.

For the method get_slug(self) in models where it appears, replace it with a @property decorator.

There are a lot more instances of def get_something_easily_computable(self) that could be switched to a property, and even more cases like:

@property
def get_something(self)

which is surprising—I would not expect a property to be prepended by get_, and some of these methods do more computation than is recommended for properties. See https://realpython.com/python-getter-setter/ for best practices if you're curious!

Also removes one seemingly unused property: LegalDocument.get_title()