MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / __class_getitem__

Method __class_getitem__

24-class-metaprog/hours/hours.py:76–83  ·  view source on GitHub ↗
(cls, parts: Union[slice, float])

Source from the content-addressed store, hash-verified

74 _s: float
75
76 def __class_getitem__(cls, parts: Union[slice, float]) -> 'Hours':
77 if isinstance(parts, slice):
78 h = parts.start or 0
79 m = valid_base_60(parts.stop or 0, 'minutes')
80 s = valid_base_60(parts.step or 0, 'seconds')
81 else:
82 h, m, s = normalize(parts * 3600)
83 return Hours(h, m, s)
84
85 def __init__(self, h: float = 0, m: float = 0, s: float = 0):
86 if h < 0 or m < 0 or s < 0:

Callers

nothing calls this directly

Calls 3

valid_base_60Function · 0.85
normalizeFunction · 0.85
HoursClass · 0.85

Tested by

no test coverage detected