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.
This commit is contained in:
Brett Smith 2020-03-29 23:28:03 -04:00
parent 22d5b7e90a
commit 959bda307b
2 changed files with 3 additions and 3 deletions

View file

@ -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]

View file

@ -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: