Skip to content

Commit 24217cf

Browse files
author
Chaim-Leib Halbert
committed
improved and fixed docstrings for properties in About, Extensions, Result, Score, TypedList
1 parent 62f362b commit 24217cf

File tree

5 files changed

+81
-38
lines changed

5 files changed

+81
-38
lines changed

tincan/about.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818

1919

2020
class About(SerializableBase):
21+
22+
"""Stores info about this installation of `tincan`.
23+
24+
:param version: The versions supported. This attribute is required.
25+
:type version: list of unicode
26+
:param extensions: Custom user data. This attribute is optional.
27+
:type extensions: :class:`tincan.extensions.Extensions`
28+
"""
29+
2130
_props_req = [
2231
'version',
2332
]
@@ -31,9 +40,11 @@ class About(SerializableBase):
3140
def version(self):
3241
"""Version for About
3342
34-
:setter: Sets the version
35-
:setter type: list | tuple | str | unicode
36-
:rtype: unicode | list
43+
:setter: Sets the version. If None is provided, defaults to
44+
`[tincan.version.Version.latest]`. If a string is provided,
45+
makes a 1-element list containing the string.
46+
:setter type: list | tuple | str | unicode | None
47+
:rtype: list
3748
3849
"""
3950
return self._version
@@ -45,6 +56,7 @@ def check_version(v):
4556
if invalid.
4657
4758
:param v: the version string to check
59+
:type v: list of str or unicode | tuple of str or unicode
4860
:raises ValueError
4961
"""
5062
if v in Version.supported:
@@ -92,9 +104,10 @@ def check_version(v):
92104
def extensions(self):
93105
"""Extensions for About
94106
95-
:setter: Tries to convert to Extensions
96-
:setter type: :mod:`tincan.extensions`
97-
:rtype: :mod:`tincan.extensions`
107+
:setter: Tries to convert to Extensions. If None is provided,
108+
sets to an empty `tincan.extensions.Extensions` dict.
109+
:setter type: :class:`tincan.extensions.Extensions` | dict | None
110+
:rtype: :class:`tincan.extensions.Extensions`
98111
99112
"""
100113
return self._extensions

tincan/extensions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
# limitations under the License.
1414

1515
from tincan.serializable_base import SerializableBase
16-
from tincan.version import Version
1716

1817

1918
class Extensions(dict, SerializableBase):
2019
"""
2120
Contains domain-specific custom data.
2221
22+
Can be created from a dict, another Extensions, or from args and kwargs.
23+
2324
Use this like a regular Python dict.
2425
"""
2526
def __init__(self, *args, **kwargs):

tincan/result.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class Result(SerializableBase):
2626
2727
Can be created from a dict, another Result, or from kwargs.
2828
29+
All these attributes are optional and settable to None:
30+
2931
:param score: Contains the score and its scaling information
3032
:type score: Score
3133
:param success: Whether successful
@@ -37,7 +39,7 @@ class Result(SerializableBase):
3739
:param response: HTTPResponse data
3840
:type response: unicode
3941
:param extensions: Custom user data
40-
:type extensions: Extensions
42+
:type extensions: :class:`tincan.extensions.Extensions`
4143
"""
4244

4345
_props = [
@@ -53,9 +55,10 @@ class Result(SerializableBase):
5355
def score(self):
5456
"""Score for Result
5557
56-
:setter: Tries to convert to Score
57-
:setter type: :mod:`tincan.score`
58-
:rtype: :mod:`tincan.score`
58+
:setter: Tries to convert to :class:`tincan.score.Score`. If
59+
None is provided, this signifies the absence of this data.
60+
:setter type: :class:`tincan.score.Score` | dict | None
61+
:rtype: :class:`tincan.score.Score` | None
5962
6063
"""
6164
return self._score
@@ -85,9 +88,10 @@ def score(self):
8588
def success(self):
8689
"""Success for Result
8790
88-
:setter: Tries to convert to bool
89-
:setter type: bool
90-
:rtype: bool
91+
:setter: Tries to convert to bool. If None is provided,
92+
this signifies the absence of this data.
93+
:setter type: bool | None
94+
:rtype: bool | None
9195
9296
"""
9397
return self._success
@@ -105,9 +109,10 @@ def success(self):
105109
def completion(self):
106110
"""Completion for Result
107111
108-
:setter: Tries to convert to bool
109-
:setter type: bool
110-
:rtype: bool
112+
:setter: Tries to convert to bool. If None is provided,
113+
this signifies the absence of this data.
114+
:setter type: bool | None
115+
:rtype: bool | None
111116
112117
"""
113118
return self._completion
@@ -125,7 +130,8 @@ def completion(self):
125130
def duration(self):
126131
"""Duration for Result
127132
128-
:setter: Tries to convert to :class:`datetime.timedelta`.
133+
:setter: Tries to convert to :class:`datetime.timedelta`. If
134+
None is provided, this signifies the absence of this data.
129135
130136
Strings will be parsed as ISO 8601 durations.
131137
@@ -135,7 +141,7 @@ def duration(self):
135141
If a `dict` is provided, does `datetime.timedelta(**value)`.
136142
137143
:setter type: :class:`datetime.timedelta` | unicode | str | int | float | dict | None
138-
:rtype: :class:`datetime.timedelta`
144+
:rtype: :class:`datetime.timedelta` | None
139145
"""
140146
return self._duration
141147

@@ -167,9 +173,10 @@ def duration(self):
167173
def response(self):
168174
"""Response for Result
169175
170-
:setter: Tries to convert to unicode
171-
:setter type: unicode
172-
:rtype: unicode
176+
:setter: Tries to convert to unicode. If None is provided,
177+
this signifies the absence of this data.
178+
:setter type: unicode | str | None
179+
:rtype: unicode | None
173180
174181
"""
175182
return self._response
@@ -197,9 +204,10 @@ def response(self):
197204
def extensions(self):
198205
"""Extensions for Result
199206
200-
:setter: Tries to convert to Extensions
201-
:setter type: :mod:`tincan.extensions`
202-
:rtype: :mod:`tincan.extensions`
207+
:setter: Tries to convert to Extensions. If None is provided,
208+
this signifies the absence of this data.
209+
:setter type: :class:`tincan.extensions.Extensions` | dict | None
210+
:rtype: :class:`tincan.extensions.Extensions` | None
203211
204212
"""
205213
return self._extensions

tincan/score.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717

1818
class Score(SerializableBase):
1919

20+
"""Stores the scoring data for an activity.
21+
22+
Can be created from a dict, another Score, or from kwargs.
23+
24+
All these attributes are optional and settable to None:
25+
26+
:param scaled: Scaled score
27+
:type scaled: float
28+
:param raw: Raw score
29+
:type raw: float
30+
:param min: Minimum score possible
31+
:type min: float
32+
:param max: Maximum score possible
33+
:type max: float
34+
"""
35+
2036
_props = [
2137
'scaled',
2238
'raw',
@@ -28,9 +44,10 @@ class Score(SerializableBase):
2844
def scaled(self):
2945
"""Scaled for Score
3046
31-
:setter: Tries to convert to float
32-
:setter type: float
33-
:rtype: float
47+
:setter: Tries to convert to float. If None is provided,
48+
this signifies the absence of this data.
49+
:setter type: float | int | None
50+
:rtype: float | None
3451
3552
"""
3653
return self._scaled
@@ -60,9 +77,10 @@ def scaled(self):
6077
def raw(self):
6178
"""Raw for Score
6279
63-
:setter: Tries to convert to float
64-
:setter type: float
65-
:rtype: float
80+
:setter: Tries to convert to float. If None is provided,
81+
this signifies the absence of this data.
82+
:setter type: float | int | None
83+
:rtype: float | None
6684
6785
"""
6886
return self._raw
@@ -92,9 +110,10 @@ def raw(self):
92110
def min(self):
93111
"""Min for Score
94112
95-
:setter: Tries to convert to float
96-
:setter type: float
97-
:rtype: float
113+
:setter: Tries to convert to float. If None is provided,
114+
this signifies the absence of this data.
115+
:setter type: float | int | None
116+
:rtype: float | None
98117
99118
"""
100119
return self._min
@@ -123,9 +142,10 @@ def min(self):
123142
def max(self):
124143
"""Max for Score
125144
126-
:setter: Tries to convert to float
127-
:setter type: float
128-
:rtype: float
145+
:setter: Tries to convert to float. If None is provided,
146+
this signifies the absence of this data.
147+
:setter type: float | int | None
148+
:rtype: float | None
129149
130150
"""
131151
return self._max

tincan/typed_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ def _check_cls(self):
4444
raise ValueError("_cls has not been set")
4545

4646
def _make_cls(self, value):
47-
"""If value is instance of self._cls, converts and returns
47+
"""If value is not instance of self._cls, converts and returns
4848
it. Otherwise, returns value.
4949
50+
:param value: the thing to make a self._cls from
5051
:rtype self._cls
5152
"""
5253
if isinstance(value, self._cls):

0 commit comments

Comments
 (0)