Skip to content

Commit c40a57e

Browse files
author
octavia-squidington-iii
committed
Auto-fix lint and format issues
1 parent e79545c commit c40a57e

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

bin/fix_acceptance_tests_yml.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
tests:
77
spec: [...]
88
connection: [...]
9-
9+
1010
To the new format:
1111
acceptance_tests:
1212
spec:
@@ -15,10 +15,11 @@
1515
tests: [...]
1616
"""
1717

18-
import yaml
1918
import sys
2019
from pathlib import Path
21-
from typing import Dict, Any
20+
from typing import Any, Dict
21+
22+
import yaml
2223

2324

2425
class FixingListIndentationDumper(yaml.Dumper):
@@ -38,53 +39,59 @@ class FixingListIndentationDumper(yaml.Dumper):
3839
```
3940
4041
"""
42+
4143
def increase_indent(self, flow=False, indentless=False):
4244
return super(FixingListIndentationDumper, self).increase_indent(flow, False)
4345

4446

4547
class AlreadyUpdatedError(Exception):
4648
"""Exception raised when the YAML file has already been updated."""
49+
4750
pass
4851

4952

5053
def transform(file_path: Path) -> None:
51-
with open(file_path, 'r') as f:
54+
with open(file_path, "r") as f:
5255
data = yaml.safe_load(f)
53-
54-
if 'acceptance_tests' in data:
56+
57+
if "acceptance_tests" in data:
5558
raise AlreadyUpdatedError()
5659

57-
if 'tests' not in data:
60+
if "tests" not in data:
5861
raise ValueError(f"No 'tests' key found in {file_path}, skipping transformation")
59-
62+
6063
# Extract the tests data
61-
tests_data = data.pop('tests')
62-
64+
tests_data = data.pop("tests")
65+
6366
if not isinstance(tests_data, dict):
6467
raise ValueError(f"Error: 'tests' key in {file_path} is not a dictionary")
65-
68+
6669
# Create the new acceptance_tests structure
67-
data['acceptance_tests'] = {}
68-
70+
data["acceptance_tests"] = {}
71+
6972
# Transform each test type
7073
for test_type, test_content in tests_data.items():
71-
data['acceptance_tests'][test_type] = {'tests': test_content}
72-
74+
data["acceptance_tests"][test_type] = {"tests": test_content}
75+
7376
# Write back to file with preserved formatting
74-
with open(file_path, 'w') as f:
75-
yaml.dump(data, f, Dumper=FixingListIndentationDumper, default_flow_style=False, sort_keys=False)
76-
77+
with open(file_path, "w") as f:
78+
yaml.dump(
79+
data, f, Dumper=FixingListIndentationDumper, default_flow_style=False, sort_keys=False
80+
)
81+
7782
print(f"Successfully transformed {file_path}")
7883

7984

8085
def main():
8186
if len(sys.argv) != 2:
8287
print("Usage: python fix_acceptance_tests_yml.py <airbyte_repo_path>")
8388
sys.exit(1)
84-
89+
8590
repo_path = Path(sys.argv[1])
8691

87-
for file_path in repo_path.glob('airbyte-integrations/connectors/source-*/acceptance-test-config.yml'):
92+
for file_path in repo_path.glob(
93+
"airbyte-integrations/connectors/source-*/acceptance-test-config.yml"
94+
):
8895
try:
8996
transform(file_path)
9097
except AlreadyUpdatedError:

0 commit comments

Comments
 (0)