This commit is contained in:
Jesse Bannon 2026-01-22 15:03:26 -08:00
parent 82dc29b0d5
commit 6156a263f0
4 changed files with 28 additions and 26 deletions

View file

@ -725,7 +725,9 @@ class Script:
if name not in unresolvable
}
to_partially_resolve: Set[Variable] = {Variable(name) for name in output_filter} if output_filter else set(unresolved.keys())
to_partially_resolve: Set[Variable] = (
{Variable(name) for name in output_filter} if output_filter else set(unresolved.keys())
)
partially_resolved = True
while partially_resolved:
@ -762,27 +764,33 @@ class Script:
# which means we can iterate again
partially_resolved |= definition != maybe_resolved
return {
var.name: ResolvedSyntaxTree(ast=[definition])
for var, definition in resolved.items()
} | {var.name: SyntaxTree(ast=[definition]) for var, definition in unresolved.items()}
if output_filter:
out: Dict[str, SyntaxTree] = {}
for name in output_filter:
variable_name = Variable(name)
if variable_name in resolved:
out[name] = ResolvedSyntaxTree(ast=[resolved[variable_name]])
else:
out[name] = SyntaxTree(ast=[unresolved[variable_name]])
return out
return {
var.name: ResolvedSyntaxTree(ast=[definition]) for var, definition in resolved.items()
} | {var.name: SyntaxTree(ast=[definition]) for var, definition in unresolved.items()}
def resolve_partial(
self,
unresolvable: Optional[Set[str]] = None,
self,
unresolvable: Optional[Set[str]] = None,
) -> "Script":
out = self._resolve_partial(unresolvable=unresolvable)
return copy.deepcopy(self).add_parsed(
{var_name: self._variables[var_name] for var_name in unresolvable}
| out
)
{var_name: self._variables[var_name] for var_name in unresolvable} | out
)
def resolve_partial_once(
self,
variable_definitions: Dict[str, SyntaxTree],
unresolvable: Optional[Set[str]] = None
self, variable_definitions: Dict[str, SyntaxTree], unresolvable: Optional[Set[str]] = None
) -> Dict[str, SyntaxTree]:
try:
self.add_parsed(variable_definitions)

View file

@ -371,13 +371,6 @@ class BuiltInFunction(Function, BuiltInFunctionType):
If the conditional partially resolvable enough to warrant evaluation,
perform it here.
"""
if self.is_subset_of(
variables=resolved_variables, custom_function_definitions=custom_functions
):
return self.resolve(
resolved_variables=resolved_variables,
custom_functions=custom_functions,
)
if self.name == "if":
maybe_resolvable_arg, is_resolvable = VariableDependency.try_partial_resolve(

View file

@ -263,6 +263,9 @@ class VariableDependency(ABC):
for arg in args:
maybe_resolvable_args.append(arg)
if hasattr(arg, "ast"):
print("sfdsf")
if isinstance(arg, Lambda) and arg.value in custom_functions:
if not custom_functions[arg.value].is_subset_of(
variables=resolved_variables,

View file

@ -254,12 +254,10 @@ def _validate_formatter(
if resolve_partial and not is_static_formatter:
formatter_hash = get_md5_hash(formatter_validator.format_string)
parsed = (
mock_script.resolve_partial_once(
variable_definitions={formatter_hash: formatter_validator.parsed},
unresolvable=unresolved_variables
)[formatter_hash]
)
parsed = mock_script.resolve_partial_once(
variable_definitions={formatter_hash: formatter_validator.parsed},
unresolvable=unresolved_variables,
)[formatter_hash]
# Add lambda functions to custom function names, if it's custom
for lambda_func in parsed.lambdas: