Changeset - 5e061da94018
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-04-24 19:36:02
brettcsmith@brettcsmith.org
reports: Fix return type of RelatedPostings.group_by_meta.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/core.py
Show inline comments
...
 
@@ -103,21 +103,21 @@ class RelatedPostings(Sequence[data.Posting]):
 

	
 
    @classmethod
 
    def group_by_meta(cls,
 
                      postings: Iterable[data.Posting],
 
                      key: MetaKey,
 
                      default: Optional[MetaValue]=None,
 
    ) -> Mapping[MetaKey, 'RelatedPostings']:
 
    ) -> Mapping[Optional[MetaValue], 'RelatedPostings']:
 
        """Relate postings by metadata value
 

	
 
        This method takes an iterable of postings and returns a mapping.
 
        The keys of the mapping are the values of post.meta.get(key, default).
 
        The values are RelatedPostings instances that contain all the postings
 
        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:
 
            retval[post.meta.get(key, default)].add(post)
 
        retval.default_factory = None
 
        return retval
 

	
 
    @overload
0 comments (0 inline, 0 general)