Skip to content

Commit 15fa532

Browse files
committed
Cache properties of DocstringAnnotations
1 parent bd41911 commit 15fa532

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/docstub/_docstrings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import textwrap
55
from dataclasses import dataclass, field
6+
from functools import cached_property
67
from pathlib import Path
78

89
import click
@@ -343,7 +344,7 @@ def _doctype_to_annotation(self, doctype):
343344
)
344345
return ErrorFallbackAnnotation
345346

346-
@property
347+
@cached_property
347348
def parameters(self) -> dict[str, Annotation]:
348349
def name_and_type(numpydoc_section):
349350
name_type = {
@@ -366,7 +367,7 @@ def name_and_type(numpydoc_section):
366367
}
367368
return annotations
368369

369-
@property
370+
@cached_property
370371
def returns(self) -> Annotation | None:
371372
out = [
372373
self._doctype_to_annotation(param.type)
@@ -376,7 +377,7 @@ def returns(self) -> Annotation | None:
376377
out = Annotation.as_return_tuple(out) if out else None
377378
return out
378379

379-
@property
380+
@cached_property
380381
def yields(self) -> Annotation | None:
381382
out = {
382383
self._doctype_to_annotation(param.type)

0 commit comments

Comments
 (0)