Skip to content

Commit 42fd4e7

Browse files
committed
fix formatting with ruff
1 parent 6d7c0f3 commit 42fd4e7

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

contentctl/input/yml_reader.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from typing import Dict, Any
2-
import yaml
3-
import sys
41
import pathlib
2+
import sys
3+
from typing import Any, Dict
4+
5+
import yaml
56

67

78
class YmlReader:
@@ -11,30 +12,29 @@ def load_file(
1112
add_fields: bool = True,
1213
STRICT_YML_CHECKING: bool = False,
1314
) -> Dict[str, Any]:
14-
try:
15+
try:
1516
file_handler = open(file_path, "r", encoding="utf-8")
1617
except OSError as exc:
17-
print(f"\nThere was an unrecoverable error when opening the file '{file_path}' - we will exit immediately:\n{str(exc)}")
18+
print(
19+
f"\nThere was an unrecoverable error when opening the file '{file_path}' - we will exit immediately:\n{str(exc)}"
20+
)
1821
sys.exit(1)
1922

20-
21-
2223
# The following code can help diagnose issues with duplicate keys or
2324
# poorly-formatted but still "compliant" YML. This code should be
2425
# enabled manually for debugging purposes. As such, strictyaml
2526
# library is intentionally excluded from the contentctl requirements
2627

27-
2828
try:
2929
if STRICT_YML_CHECKING:
3030
# This is an extra level of verbose parsing that can be
3131
# enabled for debugging purpose. It is intentionally done in
3232
# addition to the regular yml parsing
3333
import strictyaml
34+
3435
strictyaml.dirty_load(file_handler.read(), allow_flow_style=True)
3536
file_handler.seek(0)
3637

37-
3838
# Ideally we should use
3939
# from contentctl.actions.new_content import NewContent
4040
# and use NewContent.UPDATE_PREFIX,
@@ -49,10 +49,11 @@ def load_file(
4949
yml_obj = yaml.load(data, Loader=yaml.CSafeLoader)
5050

5151
except yaml.YAMLError as exc:
52-
print(f"\nThere was an unrecoverable YML Parsing error when reading or parsing the file '{file_path}' - we will exit immediately:\n{str(exc)}")
52+
print(
53+
f"\nThere was an unrecoverable YML Parsing error when reading or parsing the file '{file_path}' - we will exit immediately:\n{str(exc)}"
54+
)
5355
sys.exit(1)
5456

55-
5657
if add_fields is False:
5758
return yml_obj
5859

0 commit comments

Comments
 (0)