@@ -163,11 +163,6 @@ def get_libzim_value(self) -> bytes: ...
163163# Alias for convenience when function accept any metadata
164164AnyMetadata = MetadataBase [Any ]
165165
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-
171166
172167def clean_str (value : str ) -> str :
173168 """Clean a string value for unwanted control characters and strip white chars"""
@@ -179,47 +174,47 @@ def nb_grapheme_for(value: str) -> int:
179174 return len (regex .findall (r"\X" , value ))
180175
181176
182- def mandatory (cls : type [U ]):
177+ def mandatory [ U : AnyMetadata ] (cls : type [U ]):
183178 """Marks a Metadata mandatory: must be set to please Creator and cannot be empty"""
184179 cls .is_required = True
185180 cls .empty_allowed = False
186181 return cls
187182
188183
189- def allow_empty (cls : type [U ]):
184+ def allow_empty [ U : AnyMetadata ] (cls : type [U ]):
190185 """Whether input can be blank"""
191186 cls .empty_allowed = True
192187 return cls
193188
194189
195- def allow_duplicates (cls : type [U ]):
190+ def allow_duplicates [ U : AnyMetadata ] (cls : type [U ]):
196191 """Whether list input can accept duplicate values"""
197192 cls .duplicates_allowed = True
198193 return cls
199194
200195
201- def deduplicate (cls : type [U ]):
196+ def deduplicate [ U : AnyMetadata ] (cls : type [U ]):
202197 """Whether duplicates in list inputs should be reduced"""
203198 cls .duplicates_allowed = True
204199 cls .require_deduplication = True
205200 return cls
206201
207202
208- def only_lang_codes (cls : type [U ]):
203+ def only_lang_codes [ U : AnyMetadata ] (cls : type [U ]):
209204 """Whether list input should be checked to only accept ISO-639-1 codes"""
210205 cls .oz_only_iso636_3_allowed = True
211206 return cls
212207
213208
214- def x_protected (cls : type [U ]):
209+ def x_protected [ U : AnyMetadata ] (cls : type [U ]):
215210 """Whether metadata name should be checked for collision with reserved names
216211
217212 when applying recommendations"""
218213 cls .oz_x_protected = True
219214 return cls
220215
221216
222- def x_prefixed (cls : type [U ]):
217+ def x_prefixed [ U : AnyMetadata ] (cls : type [U ]):
223218 """Whether metadata names should be automatically X-Prefixed"""
224219 cls .oz_x_protected = False
225220 cls .oz_x_prefixed = True
0 commit comments