Skip to content

Commit

Permalink
update docstring for record
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatYYX committed Aug 22, 2018
1 parent 7f0161e commit 819d08e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rltk/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def id(self):

class cached_property(property):
"""
Decorator.
If a Record property is decorated, the final value of it will be pre-calculated.
"""
def __init__(self, func):
Expand Down Expand Up @@ -54,6 +55,7 @@ def __get__(self, obj, cls):

def remove_raw_object(cls):
"""
Decorator.
If a Record class is decorated, raw_object will be removed once all mark properties are cached.
"""
cls.remove_raw_object = True
Expand Down Expand Up @@ -83,16 +85,25 @@ def validate_record(obj):
Args:
obj (Record): Record instance.
Raises:
TypeError: if id is not valid
"""
if not isinstance(obj.id, str):
raise TypeError('Id in {} should be an utf-8 encoded string.'.format(obj.__class__.__name__))
if not re_record_id.match(obj.id):
raise ValueError('Id is not valid')


def get_property_names(cls):
def get_property_names(cls: type):
"""
Get keys of property and cached_property from a record class.
Args:
cls (type): Record class
Returns:
list: Property names in class
"""
keys = []
for prop_name, prop_type in cls.__dict__.items():
Expand Down

0 comments on commit 819d08e

Please sign in to comment.