|
2 | 2 |
|
3 | 3 | from __future__ import annotations
|
4 | 4 |
|
| 5 | +import copy |
5 | 6 | import glob
|
6 | 7 | import os
|
7 | 8 | import posixpath
|
8 | 9 | import re
|
9 | 10 | import sys
|
10 | 11 | from collections import ChainMap
|
11 | 12 | from contextlib import suppress
|
12 |
| -from typing import Any, BinaryIO, Iterator, Optional, Tuple |
| 13 | +from typing import Any, BinaryIO, Iterator, Mapping, Optional, Tuple |
13 | 14 |
|
14 | 15 | from griffe.agents.extensions import load_extensions
|
15 | 16 | from griffe.collections import LinesCollection, ModulesCollection
|
@@ -189,13 +190,15 @@ def load_inventory(
|
189 | 190 | for item in Inventory.parse_sphinx(in_file, domain_filter=("py",)).values(): # noqa: WPS526
|
190 | 191 | yield item.name, posixpath.join(base_url, item.uri)
|
191 | 192 |
|
192 |
| - def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: D102,WPS231 |
| 193 | + def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem: # noqa: D102,WPS231 |
193 | 194 | module_name = identifier.split(".", 1)[0]
|
194 | 195 | unknown_module = module_name not in self._modules_collection
|
195 | 196 | if config.get("fallback", False) and unknown_module:
|
196 | 197 | raise CollectionError("Not loading additional modules during fallback")
|
197 | 198 |
|
198 |
| - final_config = ChainMap(config, self.default_config) |
| 199 | + # See: https://github.com/python/typeshed/issues/8430 |
| 200 | + mutable_config = dict(copy.deepcopy(config)) |
| 201 | + final_config = ChainMap(mutable_config, self.default_config) |
199 | 202 | parser_name = final_config["docstring_style"]
|
200 | 203 | parser_options = final_config["docstring_options"]
|
201 | 204 | parser = parser_name and Parser(parser_name)
|
@@ -232,8 +235,10 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: D102
|
232 | 235 |
|
233 | 236 | return doc_object
|
234 | 237 |
|
235 |
| - def render(self, data: CollectorItem, config: dict) -> str: # noqa: D102 (ignore missing docstring) |
236 |
| - final_config = ChainMap(config, self.default_config) |
| 238 | + def render(self, data: CollectorItem, config: Mapping[str, Any]) -> str: # noqa: D102 (ignore missing docstring) |
| 239 | + # See https://github.com/python/typeshed/issues/8430 |
| 240 | + mutabled_config = dict(copy.deepcopy(config)) |
| 241 | + final_config = ChainMap(mutabled_config, self.default_config) |
237 | 242 |
|
238 | 243 | template = self.env.get_template(f"{data.kind.value}.html")
|
239 | 244 |
|
|
0 commit comments