@@ -153,9 +153,9 @@ def _on_db_relation_joined(self, event: ops.RelationJoinedEvent):
153
153
self ._stored .db_relation_joined_data = event .snapshot ()
154
154
155
155
def _on_mon_relation_changed (self , event : ops .RelationChangedEvent ):
156
- assert (
157
- event . app is not None
158
- ), 'application name cannot be None for a relation-changed event'
156
+ assert event . app is not None , (
157
+ 'application name cannot be None for a relation-changed event'
158
+ )
159
159
if os .environ .get ('JUJU_REMOTE_UNIT' ):
160
160
assert event .unit is not None , (
161
161
'a unit name cannot be None for a relation-changed event'
@@ -168,22 +168,22 @@ def _on_mon_relation_changed(self, event: ops.RelationChangedEvent):
168
168
self ._stored .mon_relation_changed_data = event .snapshot ()
169
169
170
170
def _on_mon_relation_departed (self , event : ops .RelationDepartedEvent ):
171
- assert (
172
- event . app is not None
173
- ), 'application name cannot be None for a relation-departed event'
171
+ assert event . app is not None , (
172
+ 'application name cannot be None for a relation-departed event'
173
+ )
174
174
assert event .relation .active , 'a departed relation is still active'
175
175
assert self .model .relations ['mon' ]
176
176
self ._stored .on_mon_relation_departed .append (type (event ).__name__ )
177
177
self ._stored .observed_event_types .append (type (event ).__name__ )
178
178
self ._stored .mon_relation_departed_data = event .snapshot ()
179
179
180
180
def _on_ha_relation_broken (self , event : ops .RelationBrokenEvent ):
181
- assert (
182
- event . app is None
183
- ), 'relation-broken events cannot have a reference to a remote application'
184
- assert (
185
- event . unit is None
186
- ), 'relation broken events cannot have a reference to a remote unit'
181
+ assert event . app is None , (
182
+ 'relation-broken events cannot have a reference to a remote application'
183
+ )
184
+ assert event . unit is None , (
185
+ 'relation broken events cannot have a reference to a remote unit'
186
+ )
187
187
assert not event .relation .active , 'relation broken events always have a broken relation'
188
188
assert not self .model .relations ['ha' ]
189
189
self ._stored .on_ha_relation_broken .append (type (event ).__name__ )
@@ -218,56 +218,56 @@ def _on_test_pebble_check_recovered(self, event: ops.PebbleCheckRecoveredEvent):
218
218
self ._stored .test_pebble_check_recovered_data = event .snapshot ()
219
219
220
220
def _on_start_action (self , event : ops .ActionEvent ):
221
- assert (
222
- event . handle . kind == 'start_action '
223
- ), 'event action name cannot be different from the one being handled'
221
+ assert event . handle . kind == 'start_action' , (
222
+ ' event action name cannot be different from the one being handled '
223
+ )
224
224
self ._stored .on_start_action .append (type (event ).__name__ )
225
225
self ._stored .observed_event_types .append (type (event ).__name__ )
226
226
227
227
def _on_secret_changed (self , event : ops .SecretChangedEvent ):
228
228
# subprocess and isinstance don't mix well
229
- assert (
230
- type (event .secret ). __name__ == 'Secret '
231
- ), f'SecretEvent.secret must be a Secret instance, not { type ( event . secret ) } '
229
+ assert type ( event . secret ). __name__ == 'Secret' , (
230
+ f'SecretEvent.secret must be a Secret instance, not { type (event .secret )} '
231
+ )
232
232
assert event .secret .id , 'secret must have an ID'
233
233
self ._stored .on_secret_changed .append (type (event ).__name__ )
234
234
self ._stored .observed_event_types .append (type (event ).__name__ )
235
235
self ._stored .secret_changed_data = event .snapshot ()
236
236
237
237
def _on_secret_remove (self , event : ops .SecretRemoveEvent ):
238
238
# subprocess and isinstance don't mix well
239
- assert (
240
- type (event .secret ). __name__ == 'Secret '
241
- ), f'SecretEvent.secret must be a Secret instance, not { type ( event . secret ) } '
239
+ assert type ( event . secret ). __name__ == 'Secret' , (
240
+ f'SecretEvent.secret must be a Secret instance, not { type (event .secret )} '
241
+ )
242
242
assert event .secret .id , 'secret must have an ID'
243
243
self ._stored .on_secret_remove .append (type (event ).__name__ )
244
244
self ._stored .observed_event_types .append (type (event ).__name__ )
245
245
self ._stored .secret_remove_data = event .snapshot ()
246
246
247
247
def _on_secret_rotate (self , event : ops .SecretRotateEvent ):
248
248
# subprocess and isinstance don't mix well
249
- assert (
250
- type (event .secret ). __name__ == 'Secret '
251
- ), f'SecretEvent.secret must be a Secret instance, not { type ( event . secret ) } '
249
+ assert type ( event . secret ). __name__ == 'Secret' , (
250
+ f'SecretEvent.secret must be a Secret instance, not { type (event .secret )} '
251
+ )
252
252
assert event .secret .id , 'secret must have an ID'
253
253
self ._stored .on_secret_rotate .append (type (event ).__name__ )
254
254
self ._stored .observed_event_types .append (type (event ).__name__ )
255
255
self ._stored .secret_rotate_data = event .snapshot ()
256
256
257
257
def _on_secret_expired (self , event : ops .SecretExpiredEvent ):
258
258
# subprocess and isinstance don't mix well
259
- assert (
260
- type (event .secret ). __name__ == 'Secret '
261
- ), f'SecretEvent.secret must be a Secret instance, not { type ( event . secret ) } '
259
+ assert type ( event . secret ). __name__ == 'Secret' , (
260
+ f'SecretEvent.secret must be a Secret instance, not { type (event .secret )} '
261
+ )
262
262
assert event .secret .id , 'secret must have an ID'
263
263
self ._stored .on_secret_expired .append (type (event ).__name__ )
264
264
self ._stored .observed_event_types .append (type (event ).__name__ )
265
265
self ._stored .secret_expired_data = event .snapshot ()
266
266
267
267
def _on_foo_bar_action (self , event : ops .ActionEvent ):
268
- assert (
269
- event . handle . kind == 'foo_bar_action '
270
- ), 'event action name cannot be different from the one being handled'
268
+ assert event . handle . kind == 'foo_bar_action' , (
269
+ ' event action name cannot be different from the one being handled '
270
+ )
271
271
self ._stored .on_foo_bar_action .append (type (event ).__name__ )
272
272
self ._stored .observed_event_types .append (type (event ).__name__ )
273
273
0 commit comments