Skip to content
Snippets Groups Projects
Commit 0b284c1f authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

more type safety

parent 7edb1fdb
No related branches found
No related tags found
No related merge requests found
......@@ -100,14 +100,16 @@ class TimeBasedHeap(object):
"""
self.heap = []
@typed(None, (float, int), None)
def put(self, timestamp, item):
"""
Put an item of heap
:param timestamp: timestamp for this item - float
:param timestamp: timestamp for this item
:param item: object
"""
heapq.heappush(self.heap, (timestamp, item))
@typed(None, (float, int))
def pop_less_than(self, timestamp):
"""
Return a list of items with timestamps less than your value.
......
......@@ -267,7 +267,6 @@ def typed(*t_args, **t_kwargs):
else:
cargs = args
for argument, typedescr in zip(cargs, t_args):
if typedescr is not None:
if not isinstance(argument, typedescr):
......
......@@ -69,6 +69,7 @@ class Instrument(object):
self.detail = detail
@typed(returns=InstrumentList)
def get_children(self):
""""
Get all DIRECT descendenta of this instrument.
......@@ -98,7 +99,7 @@ class Manager(Monitor):
def __contains__(self, instrument):
return instrument.name in self.instruments
@typed(object, six.string_types, six.string_types, int)
@typed(object, six.string_types, six.string_types, int, returns=Instrument)
@Monitor.synchronized
def getInstrument(self, name, description=u'', detail=RUNTIME):
if name in self.instruments:
......@@ -111,6 +112,6 @@ class Manager(Monitor):
manager = Manager()
@typed(six.string_types, six.string_types, int)
@typed(six.string_types, six.string_types, int, returns=Instrument)
def getInstrument(name, description=u'', detail=RUNTIME):
return manager.getInstrument(name, description, detail)
......@@ -93,7 +93,6 @@ class CounterMetric(Metric):
super(CounterMetric, self).__init__(*args, **kwargs)
self.value = 0
self.items = 0
self.sum = 0
@typed(returns=tuple)
def view(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment