diff --git a/src/ytdl_sub/entries/script/variable_definitions.py b/src/ytdl_sub/entries/script/variable_definitions.py index a88af724..cb6ad612 100644 --- a/src/ytdl_sub/entries/script/variable_definitions.py +++ b/src/ytdl_sub/entries/script/variable_definitions.py @@ -1216,6 +1216,9 @@ class VariableDefinitions( } | self.injected_variables() def get(self, name: str) -> Optional[Variable]: + """ + Returns the variable attribute if it exists. None otherwise. + """ if not hasattr(self, name): return None return getattr(self, name) diff --git a/src/ytdl_sub/utils/script.py b/src/ytdl_sub/utils/script.py index 44f53b15..ee5c0d2a 100644 --- a/src/ytdl_sub/utils/script.py +++ b/src/ytdl_sub/utils/script.py @@ -18,6 +18,7 @@ from ytdl_sub.script.utils.name_validation import is_function # pylint: disable=too-many-return-statements # pylint: disable=too-many-branches + class ScriptUtils: @classmethod def add_sanitized_variables(cls, variables: Dict[str, str]) -> Dict[str, str]: diff --git a/tests/unit/validators/test_string_formatter_validator.py b/tests/unit/validators/test_string_formatter_validator.py index a1a05b85..44b2194f 100644 --- a/tests/unit/validators/test_string_formatter_validator.py +++ b/tests/unit/validators/test_string_formatter_validator.py @@ -113,12 +113,12 @@ class TestUnstructuredDictFormatterValidator(object): assert len(validator.dict) == 8 assert all(isinstance(val, expected_formatter_class) for val in validator.dict.values()) assert validator.dict_with_format_strings == { - "key1": '{ %concat( "string with ", variable ) }', + "key1": "string with { variable }", "key2": "no variables", "key3": "{ %int(3) }", "key4": "{ %float(4.132) }", "key5": "{ %bool(True) }", "key6": '{ { %concat( variable, "_key" ): "value", "static_key": %concat( variable, "_value" ) } }', "key7": '{ [ "list_1", %concat( "list_", variable_2 ) ] }', - "key8": '{ %concat( "string ", variable1, " with multiple ", variable2 ) }', + "key8": "string { variable1 } with multiple { variable2 }", }