diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py index 9f160e82..ee75b047 100644 --- a/mkdocs/config/config_options.py +++ b/mkdocs/config/config_options.py @@ -95,7 +95,7 @@ class SubConfig(Generic[SomeConfig], BaseConfigOption[SomeConfig]): if self._do_validation: # Capture errors and warnings - self.warnings = [f"Sub-option '{key}': {msg}" for key, msg in warnings] + self.warnings.extend(f"Sub-option '{key}': {msg}" for key, msg in warnings) if failed: # Get the first failing one key, err = failed[0] @@ -188,6 +188,7 @@ class ListOfItems(Generic[T], BaseConfigOption[List[T]]): fake_keys = [f'{parent_key_name}[{i}]' for i in range(len(value))] fake_config.data = dict(zip(fake_keys, value)) + self.option_type.warnings = self.warnings for key_name in fake_config: self.option_type.pre_validation(fake_config, key_name) for key_name in fake_config: diff --git a/mkdocs/tests/config/config_options_tests.py b/mkdocs/tests/config/config_options_tests.py index 952f4ce9..f82a1de9 100644 --- a/mkdocs/tests/config/config_options_tests.py +++ b/mkdocs/tests/config/config_options_tests.py @@ -678,6 +678,19 @@ class ListOfItemsTest(TestCase): with self.expect_error(option="'asdf' is not a valid port"): self.get_config(Schema, {'option': ["localhost:8000", "1.2.3.4:asdf"]}) + def test_warning(self) -> None: + class Schema(Config): + option = c.ListOfItems(c.Deprecated()) + + self.get_config( + Schema, + {'option': ['a']}, + warnings=dict( + option="The configuration option 'option[0]' has been " + "deprecated and will be removed in a future release." + ), + ) + class FilesystemObjectTest(TestCase): def test_valid_dir(self) -> None: