diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2c57900..f9f2c8c3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [0.8.2](https://github.com/mkdocstrings/python/releases/tag/0.8.2) - 2022-11-19
+
+[Compare with 0.8.1](https://github.com/mkdocstrings/python/compare/0.8.1...0.8.2)
+
+### Bug Fixes
+- Fix base directory used to expand globs ([34cfa4b](https://github.com/mkdocstrings/python/commit/34cfa4b41f264437a338e66f6060ceeee134ba15) by Florian Hofer). [PR #45](https://github.com/mkdocstrings/python/pull/45)
+
+
## [0.8.1](https://github.com/mkdocstrings/python/releases/tag/0.8.1) - 2022-11-19
[Compare with 0.8.0](https://github.com/mkdocstrings/python/compare/0.8.0...0.8.1)
diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py
index 4d076f8b..afb8ed98 100644
--- a/src/mkdocstrings_handlers/python/handler.py
+++ b/src/mkdocstrings_handlers/python/handler.py
@@ -145,7 +145,8 @@ def __init__(
super().__init__(*args, **kwargs)
self._config_file_path = config_file_path
paths = paths or []
- with chdir(os.path.dirname(config_file_path) if config_file_path else "."):
+ glob_base_dir = os.path.dirname(os.path.abspath(config_file_path)) if config_file_path else "."
+ with chdir(glob_base_dir):
resolved_globs = [glob.glob(path) for path in paths]
paths = [path for glob_list in resolved_globs for path in glob_list]
if not paths and config_file_path:
diff --git a/tests/test_handler.py b/tests/test_handler.py
index 280e4791..93148d5f 100644
--- a/tests/test_handler.py
+++ b/tests/test_handler.py
@@ -1,5 +1,8 @@
"""Tests for the `handler` module."""
+import os
+from glob import glob
+
import pytest
from griffe.docstrings.dataclasses import DocstringSectionExamples, DocstringSectionKind
@@ -83,3 +86,15 @@ def test_expand_globs(tmp_path):
)
for path in globbed_paths: # noqa: WPS440
assert str(path) in handler._paths # noqa: WPS437
+
+
+def test_expand_globs_without_changing_directory():
+ """Assert globs are correctly expanded when we are already in the right directory."""
+ handler = PythonHandler(
+ handler="python",
+ theme="material",
+ config_file_path="mkdocs.yml",
+ paths=["*.md"],
+ )
+ for path in list(glob(os.path.abspath(".") + "/*.md")):
+ assert path in handler._paths # noqa: WPS437