@@ -796,9 +796,16 @@ def convert_analyse_config(
796796 if src_discover :
797797 analyse_config_dict ["src_files" ] = src_discover .source_paths
798798 analyse_config_dict ["src_dir" ] = src_discover .src_discover_config .src_dir
799- analyse_config_dict ["comment_type" ] = CommentType (
800- src_discover .src_discover_config .comment_type
801- )
799+ try :
800+ analyse_config_dict ["comment_type" ] = CommentType (
801+ src_discover .src_discover_config .comment_type
802+ )
803+ except ValueError :
804+ # If invalid comment_type, keep the string value
805+ # Validation will catch this error later
806+ analyse_config_dict ["comment_type" ] = (
807+ src_discover .src_discover_config .comment_type
808+ ) # type: ignore[typeddict-item]
802809
803810 return SourceAnalyseConfig (** analyse_config_dict )
804811
@@ -862,5 +869,12 @@ def generate_project_configs(
862869 analyse_config = convert_analyse_config (analyse_section_config )
863870 analyse_config .get_oneline_needs = True # force to get oneline_need
864871 # Copy comment_type from source_discover_config to analyse_config
865- analyse_config .comment_type = CommentType (source_discover_config .comment_type )
872+ try :
873+ analyse_config .comment_type = CommentType (
874+ source_discover_config .comment_type
875+ )
876+ except ValueError :
877+ # If invalid comment_type, keep the string value
878+ # Validation will catch this error later
879+ analyse_config .comment_type = source_discover_config .comment_type # type: ignore[assignment]
866880 project_config ["analyse_config" ] = analyse_config
0 commit comments