Skip to content

Commit

Permalink
Better guard an edge case in plugin config
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Oct 8, 2022
1 parent b964e05 commit aaf819f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mkdocs/config/config_options.py
Expand Up @@ -946,7 +946,7 @@ def _parse_configs(cls, value: Union[list, tuple, dict]) -> Iterator[Tuple[str,
else:
for item in value:
if isinstance(item, dict):
if len(item) > 1:
if len(item) != 1:
raise ValidationError('Invalid Plugins configuration')
name, cfg = item.popitem()
else:
Expand Down
8 changes: 8 additions & 0 deletions mkdocs/tests/config/config_options_tests.py
Expand Up @@ -1812,6 +1812,14 @@ class Schema(Config):
with self.expect_error(plugins="Invalid Plugins configuration"):
self.get_config(Schema, cfg)

cfg = {
'plugins': [
{},
],
}
with self.expect_error(plugins="Invalid Plugins configuration"):
self.get_config(Schema, cfg)

def test_plugin_config_not_string_or_dict(self, mock_class) -> None:
class Schema(Config):
plugins = c.Plugins()
Expand Down

0 comments on commit aaf819f

Please sign in to comment.