@@ -244,12 +244,14 @@ class Arg(Field):
244244 the default value for the field, by default it is NO_DEFAULT
245245 help: str
246246 A short description of the input field.
247- allowed_values: list, optional
248- List of allowed values for the field.
249247 requires: list, optional
250248 Names of the inputs that are required together with the field.
251- xor: list[str], optional
252- Names of the inputs that are mutually exclusive with the field.
249+ allowed_values: Sequence, optional
250+ List of allowed values for the field.
251+ xor: Sequence[str | None], optional
252+ Names of args that are exclusive mutually exclusive, which must include
253+ the name of the current field. If this list includes None, then none of the
254+ fields need to be set.
253255 copy_mode: File.CopyMode, optional
254256 The mode of copying the file, by default it is File.CopyMode.any
255257 copy_collation: File.CopyCollation, optional
@@ -263,15 +265,20 @@ class Arg(Field):
263265 it is False
264266 """
265267
266- allowed_values : tuple = attrs .field (default = (), converter = tuple )
267- xor : tuple [str ] = attrs .field (default = (), converter = tuple )
268+ allowed_values : frozenset = attrs .field (default = (), converter = frozenset )
269+ xor : frozenset [str | None ] = attrs .field (default = (), converter = frozenset )
268270 copy_mode : File .CopyMode = File .CopyMode .any
269271 copy_collation : File .CopyCollation = File .CopyCollation .any
270272 copy_ext_decomp : File .ExtensionDecomposition = File .ExtensionDecomposition .single
271273 readonly : bool = False
272274
273275 @xor .validator
274276 def _xor_validator (self , _ , value ):
277+ for v in value :
278+ if not isinstance (v , (str , type (None ))):
279+ raise ValueError (
280+ f"xor values must be strings or None, not { v } ({ self !r} )"
281+ )
275282 if value and self .type not in (ty .Any , bool ) and not is_optional (self .type ):
276283 raise ValueError (
277284 f"Fields that have 'xor' must be of boolean or optional type, "
0 commit comments