-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,15 @@ | |
* http://sourceforge.net/projects/adodbapi | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import datetime | ||
import decimal | ||
import numbers | ||
import sys | ||
import time | ||
from collections.abc import Callable, Iterable, Mapping | ||
from typing import Dict | ||
|
||
# noinspection PyUnresolvedReferences | ||
from . import ado_consts as adc | ||
|
@@ -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]]): | ||
# builds a dictionary from {(iterable,of,keys) : function} | ||
"""A dictionary of ado.type : function | ||
-- but you can set multiple items by passing an iterable of keys""" | ||
|
||
# useful for defining conversion functions for groups of similar data types. | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self[k] = v # we must call __setitem__ | ||
|
||
def __setitem__(self, adoType, cvtFn): | ||
"set a single item, or a whole sequence of items" | ||
try: # user passed us a sequence, set them individually | ||
def __setitem__( | ||
self, adoType: Iterable[int] | int, cvtFn: Callable[[object], object] | ||
): | ||
"set a single item, or a whole iterable of items" | ||
if isinstance(adoType, Iterable): | ||
# user passed us an iterable, set them individually | ||
for type in adoType: | ||
dict.__setitem__(self, type, cvtFn) | ||
except TypeError: # a single value fails attempt to iterate | ||
else: | ||
dict.__setitem__(self, adoType, cvtFn) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,20 +3,6 @@ | |
Adodbapi can be run on CPython 3.5 and later. | ||
""" | ||
|
||
CLASSIFIERS = """\ | ||
Development Status :: 5 - Production/Stable | ||
Intended Audience :: Developers | ||
License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) | ||
Operating System :: Microsoft :: Windows | ||
Operating System :: POSIX :: Linux | ||
Programming Language :: Python | ||
Programming Language :: Python :: 3 | ||
Programming Language :: SQL | ||
Topic :: Software Development | ||
Topic :: Software Development :: Libraries :: Python Modules | ||
Topic :: Database | ||
""" | ||
|
||
NAME = "adodbapi" | ||
MAINTAINER = "Vernon Cole" | ||
MAINTAINER_EMAIL = "[email protected]" | ||
|
@@ -25,7 +11,19 @@ | |
) | ||
URL = "http://sourceforge.net/projects/adodbapi" | ||
LICENSE = "LGPL" | ||
CLASSIFIERS = filter(None, CLASSIFIERS.split("\n")) | ||
CLASSIFIERS = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", | ||
"Operating System :: Microsoft :: Windows", | ||
"Operating System :: POSIX :: Linux", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: SQL", | ||
"Topic :: Software Development", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
"Topic :: Database", | ||
] | ||
AUTHOR = "Henrik Ekelund, Vernon Cole, et.al." | ||
AUTHOR_EMAIL = "[email protected]" | ||
PLATFORMS = ["Windows", "Linux"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 partiallyAny
type. Since this is a very small and simple class, I completely typed it.