Skip to content

Commit d7efb29

Browse files
mgeierAA-Turner
andauthored
ext.duration: Fix merge_domaindata() (#12251)
Co-authored-by: Adam Turner <[email protected]>
1 parent 04b229f commit d7efb29

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Bugs fixed
2727
Patch by Donald Hunter.
2828
* #12320: Fix removal of anchors from search summaries (regression in 7.3.0).
2929
Patch by Will Lachance.
30+
* #12251: Fix ``merge_domaindata()`` in ``sphinx.ext.duration``.
31+
Patch by Matthias Geier.
3032

3133
Testing
3234
-------

sphinx/ext/duration.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
from sphinx.util import logging
1414

1515
if TYPE_CHECKING:
16+
from typing import TypedDict
17+
1618
from docutils import nodes
1719

1820
from sphinx.application import Sphinx
1921

22+
class _DurationDomainData(TypedDict):
23+
reading_durations: dict[str, float]
24+
2025
logger = logging.getLogger(__name__)
2126

2227

@@ -38,9 +43,11 @@ def clear(self) -> None:
3843
def clear_doc(self, docname: str) -> None:
3944
self.reading_durations.pop(docname, None)
4045

41-
def merge_domaindata(self, docnames: list[str], otherdata: dict[str, float]) -> None:
42-
for docname, duration in otherdata.items():
43-
if docname in docnames:
46+
def merge_domaindata(self, docnames: list[str], otherdata: _DurationDomainData) -> None: # type: ignore[override]
47+
other_reading_durations = otherdata.get('reading_durations', {})
48+
docnames_set = frozenset(docnames)
49+
for docname, duration in other_reading_durations.items():
50+
if docname in docnames_set:
4451
self.reading_durations[docname] = duration
4552

4653

0 commit comments

Comments
 (0)