From 1300d2c77dd49f5dea459ad844d72edcc856c4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 9 Oct 2023 14:08:03 +0200 Subject: [PATCH 1/2] fix: Don't deepcopy the local config This was done in commit 3cbe472e98be1174966bdbda34d6a6fb2336f2cf to avoid a type warning that the second and next arguments to ChainMap are not mutable. Related Mypy issue: https://github.com/python/typeshed/issues/8430. When we use `!relative` in MkDocs configuration, the config then contains a MkDocs path placeholder instance, which itself contains a reference to the MkDocs config, and all its plugins, including mkdocstrings, and all its objects, etc. Upon deepcopying this huge object tree, deepcopy fails on mkdocstrings private attribute `_inv_futures`, which contains `Future` and therefore `thread.RLock` objects, which are not serializable. This failed with a `TypeError: cannot pickle '_thread.RLock` objects`. So in this commit we stop deep-copying everything just to avoid a Mypy warning, and instead we add a type-ignore comment. If Mypy fixes this someday, we'll simply get a new warning that the comment is unused. --- src/mkdocstrings_handlers/python/handler.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py index 3fc7a4fb..056429e8 100644 --- a/src/mkdocstrings_handlers/python/handler.py +++ b/src/mkdocstrings_handlers/python/handler.py @@ -2,7 +2,6 @@ from __future__ import annotations -import copy import glob import os import posixpath @@ -260,9 +259,7 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem: if config.get("fallback", False) and unknown_module: raise CollectionError("Not loading additional modules during fallback") - # See: https://github.com/python/typeshed/issues/8430 - mutable_config = dict(copy.deepcopy(config)) - final_config = ChainMap(mutable_config, self.default_config) + final_config = ChainMap(config, self.default_config) # type: ignore[arg-type] parser_name = final_config["docstring_style"] parser_options = final_config["docstring_options"] parser = parser_name and Parser(parser_name) @@ -308,9 +305,7 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem: return doc_object def render(self, data: CollectorItem, config: Mapping[str, Any]) -> str: # noqa: D102 (ignore missing docstring) - # See https://github.com/python/typeshed/issues/8430 - mutabled_config = dict(copy.deepcopy(config)) - final_config = ChainMap(mutabled_config, self.default_config) + final_config = ChainMap(config, self.default_config) # type: ignore[arg-type] template_name = rendering.do_get_template(data) template = self.env.get_template(template_name) From f747ecbf3a47ae1e1d9d38627aaf9e23218f407b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 9 Oct 2023 14:08:30 +0200 Subject: [PATCH 2/2] chore: Prepare release 1.7.3 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e63f4e29..ab570436 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). +## [1.7.3](https://github.com/mkdocstrings/python/releases/tag/1.7.3) - 2023-10-09 + +[Compare with 1.7.2](https://github.com/mkdocstrings/python/compare/1.7.2...1.7.3) + +### Bug Fixes + +- Don't deepcopy the local config ([1300d2c](https://github.com/mkdocstrings/python/commit/1300d2c77dd49f5dea459ad844d72edcc856c4cd) by Timothée Mazzucotelli). + ## [1.7.2](https://github.com/mkdocstrings/python/releases/tag/1.7.2) - 2023-10-05 [Compare with 1.7.1](https://github.com/mkdocstrings/python/compare/1.7.1...1.7.2)