@@ -163,11 +163,6 @@ def get_libzim_value(self) -> bytes: ...
163
163
# Alias for convenience when function accept any metadata
164
164
AnyMetadata = MetadataBase [Any ]
165
165
166
- # TypeVar bounded to subclasses of GenericMetadata, used by class decorators so that
167
- # they properly accommodate to the class they are used on while still knowing they have
168
- # access to all attributes of the MetadataBase class
169
- U = TypeVar ("U" , bound = AnyMetadata )
170
-
171
166
172
167
def clean_str (value : str ) -> str :
173
168
"""Clean a string value for unwanted control characters and strip white chars"""
@@ -179,47 +174,47 @@ def nb_grapheme_for(value: str) -> int:
179
174
return len (regex .findall (r"\X" , value ))
180
175
181
176
182
- def mandatory (cls : type [U ]):
177
+ def mandatory [ U : AnyMetadata ] (cls : type [U ]):
183
178
"""Marks a Metadata mandatory: must be set to please Creator and cannot be empty"""
184
179
cls .is_required = True
185
180
cls .empty_allowed = False
186
181
return cls
187
182
188
183
189
- def allow_empty (cls : type [U ]):
184
+ def allow_empty [ U : AnyMetadata ] (cls : type [U ]):
190
185
"""Whether input can be blank"""
191
186
cls .empty_allowed = True
192
187
return cls
193
188
194
189
195
- def allow_duplicates (cls : type [U ]):
190
+ def allow_duplicates [ U : AnyMetadata ] (cls : type [U ]):
196
191
"""Whether list input can accept duplicate values"""
197
192
cls .duplicates_allowed = True
198
193
return cls
199
194
200
195
201
- def deduplicate (cls : type [U ]):
196
+ def deduplicate [ U : AnyMetadata ] (cls : type [U ]):
202
197
"""Whether duplicates in list inputs should be reduced"""
203
198
cls .duplicates_allowed = True
204
199
cls .require_deduplication = True
205
200
return cls
206
201
207
202
208
- def only_lang_codes (cls : type [U ]):
203
+ def only_lang_codes [ U : AnyMetadata ] (cls : type [U ]):
209
204
"""Whether list input should be checked to only accept ISO-639-1 codes"""
210
205
cls .oz_only_iso636_3_allowed = True
211
206
return cls
212
207
213
208
214
- def x_protected (cls : type [U ]):
209
+ def x_protected [ U : AnyMetadata ] (cls : type [U ]):
215
210
"""Whether metadata name should be checked for collision with reserved names
216
211
217
212
when applying recommendations"""
218
213
cls .oz_x_protected = True
219
214
return cls
220
215
221
216
222
- def x_prefixed (cls : type [U ]):
217
+ def x_prefixed [ U : AnyMetadata ] (cls : type [U ]):
223
218
"""Whether metadata names should be automatically X-Prefixed"""
224
219
cls .oz_x_protected = False
225
220
cls .oz_x_prefixed = True
0 commit comments