Skip to content

Commit

Permalink
Remove defaultdict
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Sep 28, 2023
1 parent 10e73ca commit e551974
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sphinx_js/typedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,23 +346,21 @@ class Comment(BaseModel):
summary: list[DescriptionItem] = []
blockTags: list[Tag] = []
modifierTags: list[str] = []
tags: dict[str, list[Sequence[DescriptionItem]]] = Field(
default_factory=partial(defaultdict, list)
)
tags: dict[str, list[Sequence[DescriptionItem]]] = Field(default_factory=dict)

def __init__(self, *args: Any, **kwargs: Any):
super().__init__(*args, **kwargs)
for tag in self.blockTags:
self.tags[tag.tag.removeprefix("@")].append(tag.content)
self.tags.setdefault(tag.tag.removeprefix("@"), []).append(tag.content)

def get_description(self) -> Sequence[ir.DescriptionItem]:
return description_to_ir(self.summary)

def get_tag_list(self, tag: str) -> list[Sequence[ir.DescriptionItem]]:
return [description_to_ir(t) for t in self.tags[tag]]
return [description_to_ir(t) for t in self.tags.get(tag, [])]

def get_tag_one(self, tag: str) -> Sequence[ir.DescriptionItem]:
l = self.tags[tag]
l = self.tags.get(tag, None)
if not l:
return []
assert len(l) == 1
Expand Down

0 comments on commit e551974

Please sign in to comment.