1
-
2
1
"""
3
2
Trait definitions in the 'example' namespace.
4
3
5
4
Example namespace
6
5
"""
6
+ import warnings
7
7
8
8
# WARNING: This file is auto-generated by openassetio-traitgen, do not edit.
9
9
@@ -17,7 +17,8 @@ class DeprecatedTrait_v1:
17
17
An example.
18
18
Usage: entity, locale, relationship
19
19
"""
20
- kId = "openassetio-example:example.Deprecated.v001"
20
+
21
+ kId = "openassetio-example:example.Deprecated"
21
22
22
23
__deprecated__ = True # (Eventually use PEP 702)
23
24
@@ -67,16 +68,23 @@ def imbueTo(cls, traitsData):
67
68
traitsData .addTrait (cls .kId )
68
69
69
70
70
- # Alias for latest version.
71
- DeprecatedTrait = DeprecatedTrait_v1
72
-
71
+ # Alias for first version.
72
+ class DeprecatedTrait (DeprecatedTrait_v1 ):
73
+ def __init__ (self , traitsData ):
74
+ super ().__init__ (traitsData )
75
+ warnings .warn (
76
+ "Use of unversioned trait view classes is deprecated" ,
77
+ category = DeprecationWarning ,
78
+ stacklevel = 2 ,
79
+ )
73
80
74
81
class UpdatedTrait_v2 :
75
82
"""
76
83
An example.
77
84
Usage: entity, locale, relationship
78
85
"""
79
- kId = "openassetio-example:example.Updated.v002"
86
+
87
+ kId = "openassetio-example:example.Updated.v2"
80
88
81
89
def __init__ (self , traitsData ):
82
90
"""
@@ -123,7 +131,6 @@ def imbueTo(cls, traitsData):
123
131
"""
124
132
traitsData .addTrait (cls .kId )
125
133
126
-
127
134
def setPropertyThatWasAdded (self , propertyThatWasAdded : float ):
128
135
"""
129
136
Sets the propertyThatWasAdded property.
@@ -134,7 +141,7 @@ def setPropertyThatWasAdded(self, propertyThatWasAdded: float):
134
141
raise TypeError ("propertyThatWasAdded must be a 'float'." )
135
142
self .__data .setTraitProperty (self .kId , "propertyThatWasAdded" , propertyThatWasAdded )
136
143
137
- def getPropertyThatWasAdded (self , defaultValue : float = None ) -> Union [float , None ]:
144
+ def getPropertyThatWasAdded (self , defaultValue : float = None ) -> Union [float , None ]:
138
145
"""
139
146
Gets the value of the propertyThatWasAdded property or the supplied default.
140
147
@@ -146,7 +153,9 @@ def getPropertyThatWasAdded(self, defaultValue: float=None) -> Union[float, None
146
153
147
154
if not isinstance (value , float ):
148
155
if defaultValue is None :
149
- raise TypeError (f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'float'." )
156
+ raise TypeError (
157
+ f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'float'."
158
+ )
150
159
return defaultValue
151
160
return value
152
161
@@ -160,7 +169,7 @@ def setPropertyThatWasRenamed(self, propertyThatWasRenamed: bool):
160
169
raise TypeError ("propertyThatWasRenamed must be a 'bool'." )
161
170
self .__data .setTraitProperty (self .kId , "propertyThatWasRenamed" , propertyThatWasRenamed )
162
171
163
- def getPropertyThatWasRenamed (self , defaultValue : bool = None ) -> Union [bool , None ]:
172
+ def getPropertyThatWasRenamed (self , defaultValue : bool = None ) -> Union [bool , None ]:
164
173
"""
165
174
Gets the value of the propertyThatWasRenamed property or the supplied default.
166
175
@@ -172,7 +181,9 @@ def getPropertyThatWasRenamed(self, defaultValue: bool=None) -> Union[bool, None
172
181
173
182
if not isinstance (value , bool ):
174
183
if defaultValue is None :
175
- raise TypeError (f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'bool'." )
184
+ raise TypeError (
185
+ f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'bool'."
186
+ )
176
187
return defaultValue
177
188
return value
178
189
@@ -186,7 +197,7 @@ def setPropertyToKeep(self, propertyToKeep: str):
186
197
raise TypeError ("propertyToKeep must be a 'str'." )
187
198
self .__data .setTraitProperty (self .kId , "propertyToKeep" , propertyToKeep )
188
199
189
- def getPropertyToKeep (self , defaultValue : str = None ) -> Union [str , None ]:
200
+ def getPropertyToKeep (self , defaultValue : str = None ) -> Union [str , None ]:
190
201
"""
191
202
Gets the value of the propertyToKeep property or the supplied default.
192
203
@@ -198,21 +209,20 @@ def getPropertyToKeep(self, defaultValue: str=None) -> Union[str, None]:
198
209
199
210
if not isinstance (value , str ):
200
211
if defaultValue is None :
201
- raise TypeError (f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'str'." )
212
+ raise TypeError (
213
+ f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'str'."
214
+ )
202
215
return defaultValue
203
216
return value
204
217
205
218
206
- # Alias to latest version
207
- UpdatedTrait = UpdatedTrait_v2
208
-
209
-
210
219
class UpdatedTrait_v1 :
211
220
"""
212
221
An example.
213
222
Usage: entity, locale, relationship
214
223
"""
215
- kId = "openassetio-example:example.Updated.v001"
224
+
225
+ kId = "openassetio-example:example.Updated"
216
226
217
227
def __init__ (self , traitsData ):
218
228
"""
@@ -259,7 +269,6 @@ def imbueTo(cls, traitsData):
259
269
"""
260
270
traitsData .addTrait (cls .kId )
261
271
262
-
263
272
def setPropertyToKeep (self , propertyToKeep : str ):
264
273
"""
265
274
Sets the propertyToKeep property.
@@ -270,7 +279,7 @@ def setPropertyToKeep(self, propertyToKeep: str):
270
279
raise TypeError ("propertyToKeep must be a 'str'." )
271
280
self .__data .setTraitProperty (self .kId , "propertyToKeep" , propertyToKeep )
272
281
273
- def getPropertyToKeep (self , defaultValue : str = None ) -> Union [str , None ]:
282
+ def getPropertyToKeep (self , defaultValue : str = None ) -> Union [str , None ]:
274
283
"""
275
284
Gets the value of the propertyToKeep property or the supplied default.
276
285
@@ -282,7 +291,9 @@ def getPropertyToKeep(self, defaultValue: str=None) -> Union[str, None]:
282
291
283
292
if not isinstance (value , str ):
284
293
if defaultValue is None :
285
- raise TypeError (f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'str'." )
294
+ raise TypeError (
295
+ f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'str'."
296
+ )
286
297
return defaultValue
287
298
return value
288
299
@@ -296,7 +307,7 @@ def setPropertyToRemove(self, propertyToRemove: bool):
296
307
raise TypeError ("propertyToRemove must be a 'bool'." )
297
308
self .__data .setTraitProperty (self .kId , "propertyToRemove" , propertyToRemove )
298
309
299
- def getPropertyToRemove (self , defaultValue : bool = None ) -> Union [bool , None ]:
310
+ def getPropertyToRemove (self , defaultValue : bool = None ) -> Union [bool , None ]:
300
311
"""
301
312
Gets the value of the propertyToRemove property or the supplied default.
302
313
@@ -308,7 +319,9 @@ def getPropertyToRemove(self, defaultValue: bool=None) -> Union[bool, None]:
308
319
309
320
if not isinstance (value , bool ):
310
321
if defaultValue is None :
311
- raise TypeError (f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'bool'." )
322
+ raise TypeError (
323
+ f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'bool'."
324
+ )
312
325
return defaultValue
313
326
return value
314
327
@@ -323,7 +336,7 @@ def setPropertyToRename(self, propertyToRename: bool):
323
336
raise TypeError ("propertyToRename must be a 'bool'." )
324
337
self .__data .setTraitProperty (self .kId , "propertyToRename" , propertyToRename )
325
338
326
- def getPropertyToRename (self , defaultValue : bool = None ) -> Union [bool , None ]:
339
+ def getPropertyToRename (self , defaultValue : bool = None ) -> Union [bool , None ]:
327
340
"""
328
341
Gets the value of the propertyToRename property or the supplied default.
329
342
@@ -336,17 +349,30 @@ def getPropertyToRename(self, defaultValue: bool=None) -> Union[bool, None]:
336
349
337
350
if not isinstance (value , bool ):
338
351
if defaultValue is None :
339
- raise TypeError (f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'bool'." )
352
+ raise TypeError (
353
+ f"Invalid stored value type: '{ type (value ).__name__ } ' should be 'bool'."
354
+ )
340
355
return defaultValue
341
356
return value
342
357
343
358
359
+ # Alias to first version
360
+ class UpdatedTrait (UpdatedTrait_v1 ):
361
+ def __init__ (self , traitsData ):
362
+ super ().__init__ (traitsData )
363
+ warnings .warn (
364
+ "Use of unversioned trait view classes is deprecated" ,
365
+ category = DeprecationWarning ,
366
+ stacklevel = 2 ,
367
+ )
368
+
344
369
class AddedTrait_v1 :
345
370
"""
346
371
An example.
347
372
Usage: entity, locale, relationship
348
373
"""
349
- kId = "openassetio-example:example.Added.v001"
374
+
375
+ kId = "openassetio-example:example.Added"
350
376
351
377
def __init__ (self , traitsData ):
352
378
"""
@@ -394,5 +420,12 @@ def imbueTo(cls, traitsData):
394
420
traitsData .addTrait (cls .kId )
395
421
396
422
397
- # Alias to latest version
398
- AddedTrait = AddedTrait_v1
423
+ # Alias to first version
424
+ class AddedTrait (AddedTrait_v1 ):
425
+ def __init__ (self , traitsData ):
426
+ super ().__init__ (traitsData )
427
+ warnings .warn (
428
+ "Use of unversioned trait view classes is deprecated" ,
429
+ category = DeprecationWarning ,
430
+ stacklevel = 2 ,
431
+ )
0 commit comments