@@ -154,13 +154,13 @@ def make_dict_unstructure_fn(
154154 kwargs [attr_name ] = override
155155
156156 if override .omit :
157- lines .append (f" res.pop(' { attr_name } ' , None)" )
157+ lines .append (f" res.pop({ attr_name !r } , None)" )
158158 continue
159159
160160 if override .rename is not None :
161161 # We also need to pop when renaming, since we're copying
162162 # the original.
163- lines .append (f" res.pop(' { attr_name } ' , None)" )
163+ lines .append (f" res.pop({ attr_name !r } , None)" )
164164 kn = attr_name if override .rename is None else override .rename
165165 attr_required = attr_name in req_keys
166166
@@ -192,20 +192,20 @@ def make_dict_unstructure_fn(
192192 unstruct_handler_name = f"__c_unstr_{ ix } "
193193 globs [unstruct_handler_name ] = handler
194194 internal_arg_parts [unstruct_handler_name ] = handler
195- invoke = f"{ unstruct_handler_name } (instance[' { attr_name } ' ])"
195+ invoke = f"{ unstruct_handler_name } (instance[{ attr_name !r } ])"
196196 elif override .rename is None :
197197 # We're not doing anything to this attribute, so
198198 # it'll already be present in the input dict.
199199 continue
200200 else :
201201 # Probably renamed, we just fetch it.
202- invoke = f"instance[' { attr_name } ' ]"
202+ invoke = f"instance[{ attr_name !r } ]"
203203
204204 if attr_required :
205205 # No default or no override.
206- lines .append (f" res[' { kn } ' ] = { invoke } " )
206+ lines .append (f" res[{ kn !r } ] = { invoke } " )
207207 else :
208- lines .append (f" if ' { attr_name } ' in instance: res[' { kn } ' ] = { invoke } " )
208+ lines .append (f" if { attr_name !r } in instance: res[{ kn !r } ] = { invoke } " )
209209
210210 internal_arg_line = ", " .join ([f"{ i } ={ i } " for i in internal_arg_parts ])
211211 if internal_arg_line :
@@ -373,7 +373,7 @@ def make_dict_structure_fn(
373373 allowed_fields .add (kn )
374374 i = " "
375375 if not attr_required :
376- lines .append (f"{ i } if ' { kn } ' in o:" )
376+ lines .append (f"{ i } if { kn !r } in o:" )
377377 i = f"{ i } "
378378 lines .append (f"{ i } try:" )
379379 i = f"{ i } "
@@ -383,16 +383,18 @@ def make_dict_structure_fn(
383383
384384 if handler == converter ._structure_call :
385385 internal_arg_parts [struct_handler_name ] = t
386- lines .append (f"{ i } res[' { an } ' ] = { struct_handler_name } (o[' { kn } ' ])" )
386+ lines .append (f"{ i } res[{ an !r } ] = { struct_handler_name } (o[{ kn !r } ])" )
387387 else :
388- lines .append (f"{ i } res[' { an } ' ] = { struct_handler_name } (o[' { kn } ' ], { tn } )" )
388+ lines .append (f"{ i } res[{ an !r } ] = { struct_handler_name } (o[{ kn !r } ], { tn } )" )
389389 if override .rename is not None :
390- lines .append (f"{ i } del res[' { kn } ' ]" )
390+ lines .append (f"{ i } del res[{ kn !r } ]" )
391391 i = i [:- 2 ]
392392 lines .append (f"{ i } except Exception as e:" )
393393 i = f"{ i } "
394+ note = f"Structuring typeddict { cl .__qualname__ } @ attribute { an } "
394395 lines .append (
395- f'{ i } e.__notes__ = [*getattr(e, \' __notes__\' , []), __c_avn("Structuring typeddict { cl .__qualname__ } @ attribute { an } ", "{ an } ", { tn } )]'
396+ f"{ i } e.__notes__ = [*getattr(e, '__notes__', []), "
397+ f"__c_avn({ note !r} , { an !r} , { tn } )]"
396398 )
397399 lines .append (f"{ i } errors.append(e)" )
398400
@@ -451,17 +453,17 @@ def make_dict_structure_fn(
451453 internal_arg_parts [struct_handler_name ] = handler
452454 if handler == converter ._structure_call :
453455 internal_arg_parts [struct_handler_name ] = t
454- invocation_line = f" res[' { an } ' ] = { struct_handler_name } (o[' { kn } ' ])"
456+ invocation_line = f" res[{ an !r } ] = { struct_handler_name } (o[{ kn !r } ])"
455457 else :
456458 tn = f"__c_type_{ ix } "
457459 internal_arg_parts [tn ] = t
458460 invocation_line = (
459- f" res[' { an } ' ] = { struct_handler_name } (o[' { kn } ' ], { tn } )"
461+ f" res[{ an !r } ] = { struct_handler_name } (o[{ kn !r } ], { tn } )"
460462 )
461463
462464 lines .append (invocation_line )
463465 if override .rename is not None :
464- lines .append (f" del res[' { override .rename } ' ]" )
466+ lines .append (f" del res[{ override .rename !r } ]" )
465467
466468 # The second loop is for optional args.
467469 if non_required :
@@ -498,20 +500,20 @@ def make_dict_structure_fn(
498500 ian = an
499501 kn = an if override .rename is None else override .rename
500502 allowed_fields .add (kn )
501- post_lines .append (f" if ' { kn } ' in o:" )
503+ post_lines .append (f" if { kn !r } in o:" )
502504 if handler == converter ._structure_call :
503505 internal_arg_parts [struct_handler_name ] = t
504506 post_lines .append (
505- f" res[' { ian } ' ] = { struct_handler_name } (o[' { kn } ' ])"
507+ f" res[{ ian !r } ] = { struct_handler_name } (o[{ kn !r } ])"
506508 )
507509 else :
508510 tn = f"__c_type_{ ix } "
509511 internal_arg_parts [tn ] = t
510512 post_lines .append (
511- f" res[' { ian } ' ] = { struct_handler_name } (o[' { kn } ' ], { tn } )"
513+ f" res[{ ian !r } ] = { struct_handler_name } (o[{ kn !r } ], { tn } )"
512514 )
513515 if override .rename is not None :
514- lines .append (f" res.pop(' { override .rename } ' , None)" )
516+ lines .append (f" res.pop({ override .rename !r } , None)" )
515517
516518 if _cattrs_forbid_extra_keys :
517519 post_lines += [
0 commit comments