From a6ec1b06212b59ca8aa9826aac04cfeb37cd2dbe Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 14 Apr 2026 23:43:03 +0200 Subject: [PATCH] Rename YAML comment transfer functions (no longer solely about transferring missing comments) --- src/serena/config/serena_config.py | 6 +++--- src/serena/util/yaml.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/serena/config/serena_config.py b/src/serena/config/serena_config.py index a9cefd3b..26815061 100644 --- a/src/serena/config/serena_config.py +++ b/src/serena/config/serena_config.py @@ -31,7 +31,7 @@ from serena.constants import ( SERENA_MANAGED_DIR_NAME, ) from serena.util.inspection import determine_programming_language_composition -from serena.util.yaml import YamlCommentNormalisation, load_yaml, normalise_yaml_comments, save_yaml, transfer_missing_yaml_comments +from serena.util.yaml import YamlCommentNormalisation, load_yaml, normalise_yaml_comments, save_yaml, transfer_yaml_comments from solidlsp.ls_config import Language from ..analytics import RegisteredTokenCountEstimator @@ -581,7 +581,7 @@ class ProjectConfig(SharedConfig): # transfer missing comments from the template file template_config, _ = self._load_yaml_dict(PROJECT_TEMPLATE_FILE, self.YAML_COMMENT_NORMALISATION) - transfer_missing_yaml_comments(template_config, config_with_comments, self.YAML_COMMENT_NORMALISATION, force_update_all=True) + transfer_yaml_comments(template_config, config_with_comments, self.YAML_COMMENT_NORMALISATION, force_update_all=True) # save project.yml save_yaml(config_path, config_with_comments) @@ -1063,7 +1063,7 @@ class SerenaConfig(SharedConfig): # For some keys, we force updates, because old comments are problematic/misleading. normalise_yaml_comments(commented_yaml, YamlCommentNormalisation.LEADING_WITH_CONVERSION_FROM_TRAILING) template_yaml = load_yaml(SERENA_CONFIG_TEMPLATE_FILE, comment_normalisation=YamlCommentNormalisation.LEADING) - transfer_missing_yaml_comments(template_yaml, commented_yaml, YamlCommentNormalisation.LEADING, force_update_all=True) + transfer_yaml_comments(template_yaml, commented_yaml, YamlCommentNormalisation.LEADING, force_update_all=True) save_yaml(self.config_file_path, commented_yaml) diff --git a/src/serena/util/yaml.py b/src/serena/util/yaml.py index ad177dce..89c68027 100644 --- a/src/serena/util/yaml.py +++ b/src/serena/util/yaml.py @@ -204,7 +204,7 @@ def yaml_comment_entry_is_empty(comment_entry: Any) -> bool: return False -def transfer_missing_yaml_comments_by_index( +def transfer_yaml_comments_by_index( source: CommentedMap, target: CommentedMap, indices: list[int], forced_update_keys: Sequence[str] = (), force_update_all: bool = False ) -> None: """ @@ -231,7 +231,7 @@ def transfer_missing_yaml_comments_by_index( target_comment[index] = source_comment[index] -def transfer_missing_yaml_comments( +def transfer_yaml_comments( source: CommentedMap, target: CommentedMap, comment_normalisation: YamlCommentNormalisation, @@ -251,7 +251,7 @@ def transfer_missing_yaml_comments( case YamlCommentNormalisation.NONE: pass case YamlCommentNormalisation.LEADING | YamlCommentNormalisation.LEADING_WITH_CONVERSION_FROM_TRAILING: - transfer_missing_yaml_comments_by_index( + transfer_yaml_comments_by_index( source, target, [ITEM_COMMENT_INDEX_BEFORE], forced_update_keys=forced_update_keys, force_update_all=force_update_all ) case _: