File tree 1 file changed +21
-6
lines changed
1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -110,12 +110,27 @@ def setup_framework(
110
110
111
111
meta = CharmMeta .from_yaml (metadata , actions_metadata )
112
112
113
- # If we are in a RelationBroken event, we want to know which relation is
114
- # broken within the model, not only in the event's `.relation` attribute.
115
- broken_relation_id = (
116
- event .relation .relation_id if event .name .endswith ("_relation_broken" ) else None # type: ignore
117
- )
118
- model = ops .model .Model (meta , model_backend , broken_relation_id = broken_relation_id )
113
+ # ops >= 2.10
114
+ if inspect .signature (ops .model .Model ).parameters .get ("broken_relation_id" ):
115
+ # If we are in a RelationBroken event, we want to know which relation is
116
+ # broken within the model, not only in the event's `.relation` attribute.
117
+ broken_relation_id = (
118
+ event .relation .relation_id # type: ignore
119
+ if event .name .endswith ("_relation_broken" )
120
+ else None
121
+ )
122
+
123
+ model = ops .model .Model (
124
+ meta ,
125
+ model_backend ,
126
+ broken_relation_id = broken_relation_id ,
127
+ )
128
+ else :
129
+ ops_logger .warning (
130
+ "It looks like this charm is using an older `ops` version. "
131
+ "You may experience weirdness. Please update ops." ,
132
+ )
133
+ model = ops .model .Model (meta , model_backend )
119
134
120
135
charm_state_path = charm_dir / CHARM_STATE_FILE
121
136
You can’t perform that action at this time.
0 commit comments