From 427d553c2bf2e1c7e7a71a78a544f174dba082ac Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Fri, 21 Oct 2022 20:48:26 +0200 Subject: [PATCH] Let plugins put strings into `warnings` even though they should be 2-tuples. Fixes #3014 --- mkdocs/config/config_options.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py index 1545d5cf..b3181166 100644 --- a/mkdocs/config/config_options.py +++ b/mkdocs/config/config_options.py @@ -996,11 +996,19 @@ class Plugins(OptionallyRequired[plugins.PluginCollection]): if hasattr(plugin, 'on_startup') or hasattr(plugin, 'on_shutdown'): self.plugin_cache[name] = plugin - errors, warnings = plugin.load_config( + errors, warns = plugin.load_config( config, self._config.config_file_path if self._config else None ) - self.warnings.extend(f"Plugin '{name}' value: '{x}'. Warning: {y}" for x, y in warnings) - errors_message = '\n'.join(f"Plugin '{name}' value: '{x}'. Error: {y}" for x, y in errors) + for warning in warns: + if isinstance(warning, str): + self.warnings.append(f"Plugin '{name}'. Warning: {warning}") + else: + key, msg = warning + self.warnings.append(f"Plugin '{name}' value: '{key}'. Warning: {msg}") + + errors_message = '\n'.join( + f"Plugin '{name}' value: '{key}'. Error: {msg}" for key, msg in errors + ) if errors_message: raise ValidationError(errors_message) return plugin