Skip to content

Commit 16cde52

Browse files
committed
Use rtype to clarify types returned because of __get__()
`UnaryStruct` uses __get__() to return a different type, but this is unclear currently because now that these variable have type annotations, class variable utilizing ot are automatically typed as `UnaryStruct`. While one option is to manually document the class variables, I think it's preferable to use an attached docstring so the documentation and code don't ever get split up if one is removed for some reason. Using Sphinx `rtype` seems to be the best way to document it then.
1 parent 23a4c2b commit 16cde52

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

adafruit_as7341.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,20 @@ class AS7341: # pylint:disable=too-many-instance-attributes, no-member
325325
_all_channels: Struct = Struct(_AS7341_ASTATUS, "<BHHHHHH")
326326
_led_current_bits: RWBits = RWBits(7, _AS7341_LED, 0)
327327
_led_enabled = RWBit(_AS7341_LED, 7)
328+
328329
atime: UnaryStruct = UnaryStruct(_AS7341_ATIME, "<B")
329330
"""The integration time step count.
330331
Total integration time will be ``(ATIME + 1) * (ASTEP + 1) * 2.78µS``
332+
333+
:rtype: int
331334
"""
335+
332336
astep: UnaryStruct = UnaryStruct(_AS7341_ASTEP_L, "<H")
333-
""" The integration time step size in 2.78 microsecond increments"""
337+
"""The integration time step size in 2.78 microsecond increments
338+
339+
:rtype: int
340+
"""
341+
334342
_gain: UnaryStruct = UnaryStruct(_AS7341_CFG1, "<B")
335343
_data_ready_bit: RWBit = RWBit(_AS7341_STATUS2, 6)
336344
"""

0 commit comments

Comments
 (0)