diff --git a/adodbapi/adodbapi.py b/adodbapi/adodbapi.py index 0f84a890a..4e85bc525 100644 --- a/adodbapi/adodbapi.py +++ b/adodbapi/adodbapi.py @@ -418,9 +418,8 @@ def __setattr__(self, name, value): f"paramstyle={value!r} not in:{api.accepted_paramstyles!r}", ) elif name == "variantConversions": - value = copy.copy( - value - ) # make a new copy -- no changes in the default, please + # make a new copy -- no changes in the default, please + value = copy.copy(value) object.__setattr__(self, name, value) def __getattr__(self, item): diff --git a/adodbapi/apibase.py b/adodbapi/apibase.py index 3231f78ac..749c378d3 100644 --- a/adodbapi/apibase.py +++ b/adodbapi/apibase.py @@ -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(): 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) diff --git a/adodbapi/setup.py b/adodbapi/setup.py index f6b274661..ac796d371 100644 --- a/adodbapi/setup.py +++ b/adodbapi/setup.py @@ -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 = "vernondcole@gmail.com" @@ -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 = "vernondcole@gmail.com" PLATFORMS = ["Windows", "Linux"] diff --git a/mypy.ini b/mypy.ini index eb8e23ae9..a93198a2f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -40,8 +40,6 @@ exclude = (?x)( | ^Pythonwin/Scintilla/ ; Forked IDLE extensions predating Python 2.3. They now live in idlelib in https://github.com/python/cpython/tree/main/Lib/idlelib | ^Pythonwin/pywin/idle/ - ; TODO: adodbapi should be updated and fixed separately - | ^adodbapi/ ; TODO: Ignoring non-public APIs until all public API is typed | ([Tt]est|[Dd]emos?)/ ) diff --git a/pyrightconfig.json b/pyrightconfig.json index 356d749ba..bc3c26fbc 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -16,8 +16,6 @@ "**/test/", "**/Demos/", "**/demo/", - // TODO: adodbapi should be updated and fixed separately - "adodbapi/", ], // Packages that will be accessible globally. // Setting this makes pyright use the repo's code for those modules instead of typeshed or pywin32 in site-packages