@@ -35,8 +35,7 @@ class Instruments(UserDict[str, dict[Instrument, None]]):
3535 __slots__ = ()
3636
3737 def __init__ (self , incoming : Sequence [Instrument ]) -> None :
38- super ().__init__ ({})
39- self ["_all" ] = {}
38+ super ().__init__ ({"_all" : {}})
4039 for instrument in incoming :
4140 self .add_instrument (instrument )
4241
@@ -50,9 +49,9 @@ def add_instrument(self, instrument: Instrument) -> None:
5049 If ``instrument`` is already active, does nothing.
5150
5251 """
53- if instrument in self ["_all" ]:
52+ if instrument in self . data ["_all" ]:
5453 return
55- self ["_all" ][instrument ] = None
54+ self . data ["_all" ][instrument ] = None
5655 try :
5756 for name in dir (instrument ):
5857 if name .startswith ("_" ):
@@ -65,7 +64,7 @@ def add_instrument(self, instrument: Instrument) -> None:
6564 if isinstance (impl , types .MethodType ) and impl .__func__ is prototype :
6665 # Inherited unchanged from _abc.Instrument
6766 continue
68- self .setdefault (name , {})[instrument ] = None
67+ self .data . setdefault (name , {})[instrument ] = None
6968 except :
7069 self .remove_instrument (instrument )
7170 raise
@@ -85,12 +84,12 @@ def remove_instrument(self, instrument: Instrument) -> None:
8584
8685 """
8786 # If instrument isn't present, the KeyError propagates out
88- self ["_all" ].pop (instrument )
89- for hookname , instruments in list (self .items ()):
87+ self . data ["_all" ].pop (instrument )
88+ for hookname , instruments in list (self .data . items ()):
9089 if instrument in instruments :
9190 del instruments [instrument ]
9291 if not instruments :
93- del self [hookname ]
92+ del self . data [hookname ]
9493
9594 def call (
9695 self ,
@@ -105,7 +104,7 @@ def call(
105104 if "before_task_step" in instruments:
106105 instruments.call("before_task_step", task)
107106 """
108- for instrument in list (self [hookname ]):
107+ for instrument in list (self . data [hookname ]):
109108 try :
110109 getattr (instrument , hookname )(* args )
111110 except BaseException :
0 commit comments