@@ -74,7 +74,7 @@ class ManifestNormalizer:
7474 - removing duplicated definitions
7575 - replacing them with references.
7676
77- To extend the functionality, use the `normilize()` method to include any additional processing steps.
77+ To extend the functionality, use the `normilize()` method to include any additional processing steps.
7878 """
7979
8080 def __init__ (
@@ -117,8 +117,9 @@ def _get_manifest_streams(self) -> Iterable[Dict[str, Any]]:
117117 Get the streams from the manifest.
118118
119119 Returns:
120- A list of streams
120+ An Iterable of streams.
121121 """
122+
122123 if STREAMS_TAG in self ._normalized_manifest .keys ():
123124 for stream in self ._normalized_manifest [STREAMS_TAG ]:
124125 yield stream
@@ -128,14 +129,8 @@ def _get_manifest_streams(self) -> Iterable[Dict[str, Any]]:
128129 def _deduplicate_minifest (self ) -> None :
129130 """
130131 Find commonalities in the input JSON structure and refactor it to avoid redundancy.
131-
132- Args:
133- resolved_manifest: A dictionary representing a JSON structure to be analyzed.
134-
135- Returns:
136- A refactored JSON structure with common properties extracted to `definitions.shared`,
137- the duplicated properties replaced with references
138132 """
133+
139134 try :
140135 # prepare the `definitions` tag
141136 self ._prepare_definitions ()
@@ -148,10 +143,8 @@ def _prepare_definitions(self) -> None:
148143 """
149144 Clean the definitions in the manifest by removing unnecessary properties.
150145 This function modifies the manifest in place.
151-
152- Args:
153- manifest: The manifest to clean
154146 """
147+
155148 # Check if the definitions tag exists
156149 if not DEF_TAG in self ._normalized_manifest :
157150 self ._normalized_manifest [DEF_TAG ] = {}
@@ -169,9 +162,6 @@ def _reference_schemas(self) -> None:
169162 """
170163 Process the definitions in the manifest to move streams from definitions to the main stream list.
171164 This function modifies the manifest in place.
172-
173- Args:
174- manifest: The manifest to process
175165 """
176166
177167 # reference the stream schema for the stream to where it's stored
@@ -191,8 +181,9 @@ def _replace_duplicates_with_refs(self, duplicates: DuplicatesType) -> None:
191181 Process duplicate objects and replace them with references.
192182
193183 Args:
194- definitions : The definitions dictionary to modify
184+ duplicates : The duplicates dictionary collected from the given manifest.
195185 """
186+
196187 for _ , occurrences in duplicates .items ():
197188 type_key , key , value = self ._get_occurance_samples (occurrences )
198189 is_shared_def = self ._is_shared_definition (type_key , key )
@@ -214,7 +205,7 @@ def _handle_duplicates(self, duplicates: DuplicatesType) -> None:
214205 Process the duplicates and replace them with references.
215206
216207 Args:
217- duplicates: Dictionary of duplicate objects
208+ duplicates: The duplicates dictionary collected from the given manifest.
218209 """
219210
220211 if len (duplicates ) > 0 :
@@ -242,6 +233,7 @@ def _add_duplicate(
242233 value (Any): The value to be hashed and used for identifying duplicates.
243234 key (Optional[str]): An optional key that, if provided, wraps the value in a dictionary before hashing.
244235 """
236+
245237 # create hash for each duplicate observed
246238 value_to_hash = value if key is None else {key : value }
247239 duplicates [self ._hash_object (value_to_hash )].append ((current_path , obj , value ))
@@ -334,7 +326,7 @@ def _clean_and_sort_duplicates(self, duplicates: DuplicatesType) -> DuplicatesTy
334326 duplicates: The duplicates dictionary to sort
335327
336328 Returns:
337- A sorted duplicates dictionary
329+ A sorted duplicates dictionary.
338330 """
339331
340332 # clean non-duplicates
@@ -432,6 +424,7 @@ def _create_shared_definition_ref(self, type_key: str, key: str) -> Dict[str, st
432424 Returns:
433425 A reference object in the proper format
434426 """
427+
435428 return {"$ref" : f"#/{ DEF_TAG } /{ SHARED_TAG } /{ type_key } /{ key } " }
436429
437430 def _create_schema_ref (self , ref_key : str ) -> Dict [str , str ]:
@@ -444,4 +437,5 @@ def _create_schema_ref(self, ref_key: str) -> Dict[str, str]:
444437 Returns:
445438 A reference object in the proper format
446439 """
440+
447441 return {"$ref" : f"#/{ SCHEMAS_TAG } /{ ref_key } " }
0 commit comments