structurize 2.16.6__py3-none-any.whl → 2.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
avrotize/common.py CHANGED
@@ -5,6 +5,7 @@ Common utility functions for Avrotize.
5
5
  # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-statements, line-too-long
6
6
 
7
7
  from collections import defaultdict
8
+ import copy
8
9
  import os
9
10
  import re
10
11
  import hashlib
@@ -698,6 +699,9 @@ def inline_avro_references(avro_schema, type_dict, current_namespace, tracker=No
698
699
  if 'type' in avro_schema and avro_schema['type'] in ['record', 'enum', 'fixed']:
699
700
  namespace = avro_schema.get('namespace', current_namespace)
700
701
  qualified_name = (namespace + '.' if namespace else '') + avro_schema['name']
702
+ # If this named type is already defined, return just the reference string
703
+ if qualified_name in defined_types:
704
+ return qualified_name
701
705
  defined_types.add(qualified_name)
702
706
 
703
707
  # Process record types
@@ -731,7 +735,8 @@ def inline_avro_references(avro_schema, type_dict, current_namespace, tracker=No
731
735
 
732
736
  elif avro_schema in type_dict and avro_schema not in tracker and avro_schema not in defined_types:
733
737
  # Inline the referenced schema if not already tracked and not defined in the current schema
734
- inlined_schema = type_dict[avro_schema].copy()
738
+ # Use deepcopy to avoid mutating the original type_dict entries when modifying nested structures
739
+ inlined_schema = copy.deepcopy(type_dict[avro_schema])
735
740
  if isinstance(inlined_schema, dict) and not inlined_schema.get('namespace', None):
736
741
  inlined_schema['namespace'] = '.'.join(avro_schema.split('.')[:-1])
737
742
  inlined_schema = inline_avro_references(