Skip to content

Commit 5c47e90

Browse files
committed
Fix linting and typing
1 parent e52ef3e commit 5c47e90

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

tested/dsl/translate_parser.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,18 @@ def is_expression(_checker: TypeChecker, instance: Any) -> bool:
187187
return isinstance(instance, ExpressionString)
188188

189189

190-
def load_schema_validator(dsl_object: YamlObject = None, file: str = "schema-strict.json") -> Validator:
190+
def load_schema_validator(
191+
dsl_object: YamlObject = None, file: str = "schema-strict.json"
192+
) -> Validator:
191193
"""
192194
Load the JSON Schema validator used to check DSL test suites.
193195
"""
194196
# if the programming language is set in the root, tested_dsl_expressions don't need to be parseable
195-
language_present = dsl_object is not None and "language" in dsl_object
197+
language_present = (
198+
dsl_object is not None
199+
and isinstance(dsl_object, dict)
200+
and "language" in dsl_object
201+
)
196202

197203
def validate_tested_dsl_expression(value: object) -> bool:
198204
if not isinstance(value, str):
@@ -213,7 +219,9 @@ def validate_tested_dsl_expression(value: object) -> bool:
213219
"oracle", is_oracle
214220
).redefine("expression", is_expression)
215221
format_checker = original_validator.FORMAT_CHECKER
216-
format_checker.checks("tested-dsl-expression", SyntaxError)(validate_tested_dsl_expression)
222+
format_checker.checks("tested-dsl-expression", SyntaxError)(
223+
validate_tested_dsl_expression
224+
)
217225
tested_validator = extend_validator(original_validator, type_checker=type_checker)
218226
return tested_validator(schema_object, format_checker=format_checker)
219227

tests/test_dsl_yaml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@ def test_empty_text_data_newlines():
13031303
actual_stderr = suite.tabs[0].contexts[0].testcases[0].output.stderr.data
13041304
assert actual_stderr == ""
13051305

1306+
13061307
def test_programming_language_can_be_globally_configured():
13071308
yaml_str = """
13081309
namespace: "Numbers"
@@ -1325,6 +1326,7 @@ def test_programming_language_can_be_globally_configured():
13251326
assert testcase.input.type == "expression"
13261327
assert testcase.input.literals.keys() == {"java"}
13271328

1329+
13281330
def test_strict_json_schema_is_valid():
13291331
path_to_schema = Path(__file__).parent / "tested-draft7.json"
13301332
with open(path_to_schema, "r") as schema_file:
@@ -1337,6 +1339,6 @@ def test_strict_json_schema_is_valid():
13371339

13381340

13391341
def test_editor_json_schema_is_valid():
1340-
validator = load_schema_validator(file= "schema.json")
1342+
validator = load_schema_validator(file="schema.json")
13411343
assert isinstance(validator.schema, dict)
13421344
validator.check_schema(validator.schema)

0 commit comments

Comments
 (0)