Skip to content

Commit 21a3357

Browse files
committed
Fix pre-commit issues
1 parent 604882e commit 21a3357

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ def step_call(
14331433
if not isinstance(closure, FunctionBlock):
14341434
msg = f"Type error: {block.call} is of type {type(closure)} but should be a function."
14351435
if isinstance(closure, str) and isinstance(scope.get(closure), FunctionBlock):
1436-
msg += " You might want to call `${ " + block.call + " }`."
1436+
msg += " You might want to call `${ " + str(block.call) + " }`."
14371437
raise PDLRuntimeError(
14381438
msg,
14391439
loc=append(loc, "call"),
@@ -1449,12 +1449,17 @@ def step_call(
14491449
trace=block.model_copy(),
14501450
)
14511451
f_body = closure.returns
1452-
f_scope = closure.scope | {"pdl_context": scope["pdl_context"]} | args
1453-
fun_loc = LocationType(
1454-
file=closure.location.file,
1455-
path=closure.location.path + ["return"],
1456-
table=loc.table,
1452+
f_scope = (
1453+
(closure.scope or {}) | {"pdl_context": scope["pdl_context"]} | (args or {})
14571454
)
1455+
if closure.location is not None:
1456+
fun_loc = LocationType(
1457+
file=closure.location.file,
1458+
path=closure.location.path + ["return"],
1459+
table=loc.table,
1460+
)
1461+
else:
1462+
fun_loc = empty_block_location
14581463
try:
14591464
result, background, _, f_trace = yield from step_block(
14601465
state, f_scope, f_body, fun_loc

src/pdl/pdl_schema_validator.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any
1+
from typing import Any, Optional
22

33
from jsonschema import ValidationError, validate
44

@@ -7,15 +7,19 @@
77
from .pdl_schema_utils import get_json_schema, pdltype_to_jsonschema
88

99

10-
def type_check_args(args: dict[str, Any], params: dict[str, Any], loc) -> list[str]:
10+
def type_check_args(
11+
args: Optional[dict[str, Any]], params: Optional[dict[str, Any]], loc
12+
) -> list[str]:
1113
if (args == {} or args is None) and (params is None or params == {}):
1214
return []
13-
args_copy = args.copy()
14-
params_copy = params.copy()
15-
if args_copy is None:
15+
if args is None:
1616
args_copy = {}
17-
if params_copy is None:
17+
else:
18+
args_copy = args.copy()
19+
if params is None:
1820
params_copy = {}
21+
else:
22+
params_copy = params.copy()
1923
# if "pdl_context" not in args_copy:
2024
# args_copy["pdl_context"] = "pdl_context"
2125
# if "pdl_context" not in params_copy:

0 commit comments

Comments
 (0)