Repository: mkdocs/mkdocs

Issue:
Empty mkdocs_theme.yml breaks build
Hello! In the docs its [stated](https://www.mkdocs.org/dev-guide/themes/#theme-configuration) that a theme **can** have an empty `mkdocs_theme.yml` file:

> However, if the theme offers no configuration options, the file is still required and can be left blank.

Unfortunately this seems to have changed recently and now themes with empty `mkdocs_theme.yml` files are causing an exception when building:

```shell
> mkdocs build --verbose
DEBUG   -  Loading configuration file: ./mkdocs.yml
DEBUG   -  Loaded theme configuration for 'custom_theme' from
           './venv/lib/python3.12/site-packages/custom_theme/mkdocs_theme.yml':
           None
Traceback (most recent call last):
  [...]
  File "./venv/lib/python3.12/site-packages/mkdocs/config/config_options.py", line 868, in run_validation
    return theme.Theme(**theme_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.12/site-packages/mkdocs/theme.py", line 61, in __init__
    self._load_theme_config(name)
  File "./venv/lib/python3.12/site-packages/mkdocs/theme.py", line 143, in _load_theme_config
    if parent_theme := theme_config.pop('extends', None):
                       ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'pop'
```


Discussion:

Patch:
diff --git a/mkdocs/theme.py b/mkdocs/theme.py
index bf587201..b45f1079 100644
--- a/mkdocs/theme.py
+++ b/mkdocs/theme.py
@@ -138,6 +138,9 @@ class Theme(MutableMapping[str, Any]):
                 f"Please upgrade to a current version of the theme."
             )
 
+        if theme_config is None:
+            theme_config = {}
+
         log.debug(f"Loaded theme configuration for '{name}' from '{file_path}': {theme_config}")
 
         if parent_theme := theme_config.pop('extends', None):


Test patch:
diff --git a/mkdocs/tests/theme_tests.py b/mkdocs/tests/theme_tests.py
index f9989fb3..ddc526bf 100644
--- a/mkdocs/tests/theme_tests.py
+++ b/mkdocs/tests/theme_tests.py
@@ -104,3 +104,22 @@ class ThemeTests(unittest.TestCase):
                 ],
             )
             self.assertEqual(theme.static_templates, {'sitemap.xml', 'child.html', 'parent.html'})
+
+    def test_empty_config_file(self):
+        # Test for themes with *empty* mkdocs_theme.yml.
+        # See https://github.com/mkdocs/mkdocs/issues/3699
+        m = mock.Mock(
+            # yaml.load returns "None" for an empty file
+            side_effect=[None]
+        )
+        with mock.patch('yaml.load', m) as m:
+            theme = Theme(name='mkdocs')
+            # Should only have the default name and locale __vars set in
+            # Theme.__init__()
+            self.assertEqual(
+                dict(theme),
+                {
+                    'name': 'mkdocs',
+                    'locale': parse_locale('en'),
+                },
+            )