File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,13 @@ def metadata_converter(obj: Union[Dict, Instance]) -> dict:
3333 raise ValueError ("Can only convert dict or Instance" )
3434
3535
36+ def metadata_validator (instance , attribute , value ):
37+ if attribute .name == "metadata" and isinstance (instance , Chunk ):
38+ for k , _ in value .items ():
39+ if not isinstance (k , str ):
40+ raise TypeError ("metadata keys must be string" )
41+
42+
3643@attr .define (frozen = True )
3744class Task :
3845 path : Path
@@ -100,7 +107,9 @@ class ValidChunk(Chunk):
100107
101108 handler : "Handler" = attr .ib (init = False , eq = False )
102109 is_encrypted : bool = attr .ib (default = False )
103- metadata : dict = attr .ib (factory = dict , converter = metadata_converter )
110+ metadata : dict = attr .ib (
111+ factory = dict , converter = metadata_converter , validator = metadata_validator
112+ )
104113
105114 def extract (self , inpath : Path , outdir : Path ):
106115 if self .is_encrypted :
You can’t perform that action at this time.
0 commit comments