-
Notifications
You must be signed in to change notification settings - Fork 793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix static typing issue & turn on mypy+pyright in adodbapi #2279
Conversation
@@ -461,20 +465,25 @@ def convert_to_python(variant, func): # convert DB value into Python value | |||
return func(variant) # call the appropriate conversion function | |||
|
|||
|
|||
class MultiMap(dict): # builds a dictionary from {(sequence,of,keys) : function} | |||
"""A dictionary of ado.type : function -- but you can set multiple items by passing a sequence of keys""" | |||
class MultiMap(Dict[int, Callable[[object], object]]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing issue here was that dict
leads to partially Any
type. Since this is a very small and simple class, I completely typed it.
def __init__(self, aDict): | ||
for k, v in list(aDict.items()): | ||
def __init__(self, aDict: Mapping[Iterable[int] | int, Callable[[object], object]]): | ||
for k, v in aDict.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ItemsView
(or in the case of a dict
, dict_items
) is already iterable. coercing to a list was redundant.
ad5f536
to
fd5cc25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
Work towards a typed API.