green baby

This commit is contained in:
Jesse Bannon 2025-12-29 23:38:44 -08:00
parent b9af1c375b
commit a47dee620f
4 changed files with 13 additions and 9 deletions

2
.gitignore vendored
View file

@ -152,3 +152,5 @@ ffmpeg.exe
ffprobe.exe
tools/docgen/out
prof/

View file

@ -220,13 +220,14 @@ def _validate_formatter(
unresolved_variables: Set[str],
formatter_validator: Union[StringFormatterValidator, OverridesStringFormatterValidator],
) -> str:
is_static_formatter = False
unresolvable = unresolved_variables
if isinstance(formatter_validator, OverridesStringFormatterValidator):
is_static_formatter = True
unresolvable = unresolved_variables.union({VARIABLES.entry_metadata.variable_name})
parsed = formatter_validator.parsed
if resolved := parsed.maybe_resolvable:
return resolved.native
is_static_formatter = isinstance(formatter_validator, OverridesStringFormatterValidator)
if is_static_formatter:
unresolved_variables = unresolved_variables.union({VARIABLES.entry_metadata.variable_name})
variable_names = {var.name for var in parsed.variables}
custom_function_names = {f"%{func.name}" for func in parsed.custom_functions}
@ -240,7 +241,7 @@ def _validate_formatter(
"contains the following custom functions that do not exist: "
f"{', '.join(sorted(custom_function_names - mock_script.function_names))}"
)
if unresolved := variable_names.intersection(unresolvable):
if unresolved := variable_names.intersection(unresolved_variables):
raise StringFormattingVariableNotFoundException(
"contains the following variables that are unresolved when executing this "
f"formatter: {', '.join(sorted(unresolved))}"
@ -249,7 +250,7 @@ def _validate_formatter(
if is_static_formatter:
return mock_script.resolve_once(
{"tmp_var": formatter_validator.format_string},
unresolvable=unresolvable,
unresolvable=unresolved_variables,
update=True,
)["tmp_var"].native

View file

@ -555,4 +555,4 @@ def test_tv_show_resolved_yaml(config_file: ConfigFile, tv_show_subscriptions_pa
assert len(subs) == 8
yaml_out = subs[0].resolved_yaml()
assert yaml_out == "nope"
print(yaml_out)

View file

@ -41,6 +41,7 @@ def should_filter_property(property_name: str) -> bool:
"list",
"script",
"unresolvable",
"leaf_name",
)