|
12 | 12 | from yaml.constructor import ConstructorError |
13 | 13 |
|
14 | 14 | from linkml_runtime.utils.context_utils import CONTEXTS_PARAM_TYPE, merge_contexts |
15 | | -from linkml_runtime.utils.formatutils import is_empty, items |
| 15 | +from linkml_runtime.utils.formatutils import is_empty |
16 | 16 |
|
17 | 17 | YAMLObjTypes = Union[JsonObjTypes, "YAMLRoot"] |
18 | 18 |
|
@@ -229,16 +229,20 @@ def _normalize_inlined_slot( |
229 | 229 | self.<slot> = [] |
230 | 230 | if not isinstance(self.<slot>, list): |
231 | 231 | self.extensions = [self.<slot>] |
232 | | - self._normalize_inlined_slot(slot_name="<slot>", slot_type=<type>, key_name="<key>", inlined_as_list=True, keyed=...) |
| 232 | + self._normalize_inlined_slot( |
| 233 | + slot_name="<slot>", slot_type=<type>, key_name="<key>", inlined_as_list=True, keyed=... |
| 234 | + ) |
233 | 235 | or |
234 | 236 | if self.<slot> is None: |
235 | 237 | self.<slot> = [] |
236 | 238 | if not isinstance(self.<slot>, (list, dict)): |
237 | 239 | self.local_names = [self.<slot>] |
238 | | - self._normalize_inlined_slot(slot_name="<slot>", slot_type=<type>, key_name="<key>", inlined_as_list=None, keyed=...) |
| 240 | + self._normalize_inlined_slot( |
| 241 | + slot_name="<slot>", slot_type=<type>, key_name="<key>", inlined_as_list=None, keyed=... |
| 242 | + ) |
239 | 243 |
|
240 | | - The above pattern broke when the new jsonasobj was introduced, which is why we have the normalization above. The code |
241 | | - below reverse engineers the above and invokes the new form |
| 244 | + The above pattern broke when the new jsonasobj was introduced, which is why we have the normalization above. |
| 245 | + The code below reverse engineers the above and invokes the new form |
242 | 246 |
|
243 | 247 | """ |
244 | 248 | if inlined_as_list: |
@@ -305,7 +309,8 @@ def _pformat(fields: dict, cls_name: str, indent: str = " ") -> str: |
305 | 309 | # pformat handles everything else that isn't a YAMLRoot object, but it sure does look ugly |
306 | 310 | # use it to split lines and as the thing of last resort, but otherwise indent = 0, we'll do that |
307 | 311 | val_str = pformat(val, indent=0, compact=True, sort_dicts=False) |
308 | | - # now we indent everything except the first line by indenting and then using regex to remove just the first indent |
| 312 | + # now we indent everything except the first line by indenting |
| 313 | + # and then using regex to remove just the first indent |
309 | 314 | val_str = re.sub(rf"\A{re.escape(indent)}", "", textwrap.indent(val_str, indent)) |
310 | 315 | # now recombine with the key in a format that can be re-eval'd into an object if indent is just whitespace |
311 | 316 | val_str = f"'{key}': " + val_str |
|
0 commit comments