Changeset - 959bda307b31
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-03-30 03:28:03
brettcsmith@brettcsmith.org
typing: Refine any generics when possible.

These were tightened up by running mypy with --disallow-any-generics
and cleaning up reported errors.

There are still a couple of cases I don't know how to deal with
right now that prevent me from setting that option permanently:

* plugin/__init__.py sets up a dict where the key is a Directive
and its value is a set of hooks that correspond to that type
of directive. The relationship between key and value is not
expressable through the type system, and any other solution would
make the code way more involved and less dynamic.

* The type variable used in _GenericRange still isn't quite right,
in the sense that specifying a value for CT creates more errors
I don't know how to deal with. Protocols seem like the right
solution for that but they apparently didn't land for Python 3.7
that I can see.
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/beancount_types.py
Show inline comments
...
 
@@ -46,8 +46,8 @@ class Transaction(Directive):
 
    flag: bc_data.Flag
 
    payee: Optional[str]
 
    narration: str
 
    tags: Set
 
    links: Set
 
    tags: Set[str]
 
    links: Set[str]
 
    postings: List[Posting]
 

	
 

	
conservancy_beancount/errors.py
Show inline comments
...
 
@@ -118,7 +118,7 @@ class InvalidMetadataError(Error):
 
                 key: MetaKey,
 
                 value: Optional[MetaValue]=None,
 
                 post: Optional[bc_data.Posting]=None,
 
                 need_type: Type=str,
 
                 need_type: Type[object]=str,
 
                 source: Meta=None,
 
    ) -> None:
 
        if post is None:
0 comments (0 inline, 0 general)