reports: Fix return type of RelatedPostings.group_by_meta.

This commit is contained in:
Brett Smith 2020-04-24 15:36:02 -04:00
parent bd00822b8f
commit 5e061da940

View file

@ -106,7 +106,7 @@ class RelatedPostings(Sequence[data.Posting]):
postings: Iterable[data.Posting], postings: Iterable[data.Posting],
key: MetaKey, key: MetaKey,
default: Optional[MetaValue]=None, default: Optional[MetaValue]=None,
) -> Mapping[MetaKey, 'RelatedPostings']: ) -> Mapping[Optional[MetaValue], 'RelatedPostings']:
"""Relate postings by metadata value """Relate postings by metadata value
This method takes an iterable of postings and returns a mapping. This method takes an iterable of postings and returns a mapping.
@ -114,7 +114,7 @@ class RelatedPostings(Sequence[data.Posting]):
The values are RelatedPostings instances that contain all the postings The values are RelatedPostings instances that contain all the postings
that had that same metadata value. that had that same metadata value.
""" """
retval: DefaultDict[MetaKey, 'RelatedPostings'] = collections.defaultdict(cls) retval: DefaultDict[Optional[MetaValue], 'RelatedPostings'] = collections.defaultdict(cls)
for post in postings: for post in postings:
retval[post.meta.get(key, default)].add(post) retval[post.meta.get(key, default)].add(post)
retval.default_factory = None retval.default_factory = None