@@ -168,32 +168,37 @@ def __init__(self, **kwargs):
168
168
setattr (self , k , v )
169
169
170
170
def _set_random_id (self ):
171
+
172
+ if hasattr (self , "id" ):
173
+ return getattr (self , "id" )
174
+
175
+ kind = f"`{ self ._namespace } .{ self ._type } `" # pylint: disable=no-member
176
+
171
177
if getattr (self , "persistence" , False ):
172
178
raise RuntimeError (
173
- """
179
+ f """
174
180
Attempting to use an auto-generated ID with the `persistence` prop.
175
181
This is prohibited because persistence is tied to component IDs and
176
182
auto-generated IDs can easily change.
177
183
178
- Please assign an explicit ID to this component.
179
- """
184
+ Please assign an explicit ID to this { kind } component.
185
+ """
180
186
)
181
187
if "dash_snapshots" in sys .modules :
182
188
raise RuntimeError (
183
- """
189
+ f """
184
190
Attempting to use an auto-generated ID in an app with `dash_snapshots`.
185
191
This is prohibited because snapshots saves the whole app layout,
186
192
including component IDs, and auto-generated IDs can easily change.
187
- Callbacks referencing the new IDs will not work old snapshots.
193
+ Callbacks referencing the new IDs will not work with old snapshots.
188
194
189
- Please assign an explicit ID to this component.
190
- """
195
+ Please assign an explicit ID to this { kind } component.
196
+ """
191
197
)
192
198
193
- if not hasattr (self , "id" ):
194
- v = str (uuid .UUID (int = rd .randint (0 , 2 ** 128 )))
195
- setattr (self , "id" , v )
196
- return getattr (self , "id" )
199
+ v = str (uuid .UUID (int = rd .randint (0 , 2 ** 128 )))
200
+ setattr (self , "id" , v )
201
+ return v
197
202
198
203
def to_plotly_json (self ):
199
204
# Add normal properties
0 commit comments