Skip to content

Commit

Permalink
Drop Python 3.8 support in adodbapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Nov 18, 2024
1 parent 0b0ec6a commit 42d0e58
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
3 changes: 1 addition & 2 deletions adodbapi/apibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import sys
import time
from collections.abc import Callable, Iterable, Mapping
from typing import Dict

# noinspection PyUnresolvedReferences
from . import ado_consts as adc
Expand Down Expand Up @@ -465,7 +464,7 @@ def convert_to_python(variant, func): # convert DB value into Python value
return func(variant) # call the appropriate conversion function


class MultiMap(Dict[int, Callable[[object], object]]):
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"""
Expand Down
60 changes: 4 additions & 56 deletions adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import decimal
import random
import string
import sys
import time
import unittest

Expand All @@ -37,14 +36,6 @@
import adodbapi
import adodbapi.apibase as api

try:
import adodbapi.ado_consts as ado_consts
except ImportError: # we are doing a shortcut import as a module -- so
try:
import ado_consts
except ImportError:
from adodbapi import ado_consts


def randomstring(length):
return "".join([random.choice(string.ascii_letters) for n in range(32)])
Expand Down Expand Up @@ -188,49 +179,6 @@ def testUserDefinedConversions(self):
pass
self.helpRollbackTblTemp()

def testUserDefinedConversionForExactNumericTypes(self):
# variantConversions is a dictionary of conversion functions
# held internally in adodbapi.apibase
#
# !!! this test intentionally alters the value of what should be constant in the module
# !!! no new code should use this example, to is only a test to see that the
# !!! deprecated way of doing this still works. (use connection.variantConversions)
#
if sys.version_info < (3, 0): ### Py3 need different test
oldconverter = adodbapi.variantConversions[
ado_consts.adNumeric
] # keep old function to restore later
# By default decimal and "numbers" are returned as decimals.
# Instead, make numbers return as floats
try:
adodbapi.variantConversions[ado_consts.adNumeric] = adodbapi.cvtFloat
self.helpTestDataType(
"decimal(18,2)", "NUMBER", 3.45, compareAlmostEqual=1
)
self.helpTestDataType(
"numeric(18,2)", "NUMBER", 3.45, compareAlmostEqual=1
)
# now return strings
adodbapi.variantConversions[ado_consts.adNumeric] = adodbapi.cvtString
self.helpTestDataType("numeric(18,2)", "NUMBER", "3.45")
# now a completely weird user defined conversion
adodbapi.variantConversions[ado_consts.adNumeric] = (
lambda x: "!!This function returns a funny unicode string %s!!" % x
)
self.helpTestDataType(
"numeric(18,2)",
"NUMBER",
"3.45",
allowedReturnValues=[
"!!This function returns a funny unicode string 3.45!!"
],
)
finally:
# now reset the converter to its original function
adodbapi.variantConversions[ado_consts.adNumeric] = (
oldconverter # Restore the original conversion function
)

def helpTestDataType(
self,
sqlDataTypeString,
Expand Down Expand Up @@ -432,7 +380,7 @@ def testDataTypeInt(self):
"bigint",
"NUMBER",
3000000000,
allowedReturnValues=[3000000000, int(3000000000)],
allowedReturnValues=[3000000000, 3000000000],
)
self.helpTestDataType("int", "NUMBER", 2147483647)

Expand Down Expand Up @@ -1136,7 +1084,7 @@ def getConnection(self):
return self.conn

def getAnotherConnection(self, addkeys=None):
keys = dict(config.connStrSQLServer[1])
keys = config.connStrSQLServer[1].copy()
if addkeys:
keys.update(addkeys)
return config.dbSqlServerconnect(*config.connStrSQLServer[0], **keys)
Expand Down Expand Up @@ -1316,7 +1264,7 @@ def getConnection(self):
return self.conn

def getAnotherConnection(self, addkeys=None):
keys = dict(config.connStrMySql[1])
keys = config.connStrMySql[1].copy()
if addkeys:
keys.update(addkeys)
return config.dbMySqlconnect(*config.connStrMySql[0], **keys)
Expand Down Expand Up @@ -1382,7 +1330,7 @@ def getConnection(self):
return self.conn

def getAnotherConnection(self, addkeys=None):
keys = dict(config.connStrPostgres[1])
keys = config.connStrPostgres[1].copy()
if addkeys:
keys.update(addkeys)
return config.dbPostgresConnect(*config.connStrPostgres[0], **keys)
Expand Down
12 changes: 3 additions & 9 deletions adodbapi/test/dbapi20.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
__version__ = "$Revision: 1.15.0 $"[11:-2]
__author__ = "Stuart Bishop <stuart@stuartbishop.net>"

import sys
import time
import unittest

Expand Down Expand Up @@ -197,14 +196,9 @@ def test_paramstyle(self):
self.fail("Driver doesn't define paramstyle")

def test_Exceptions(self):
# Make sure required exceptions exist, and are in the
# defined hierarchy.
if sys.version[0] == "3": # under Python 3 StardardError no longer exists
self.assertTrue(issubclass(self.driver.Warning, Exception))
self.assertTrue(issubclass(self.driver.Error, Exception))
else:
self.failUnless(issubclass(self.driver.Warning, Exception))
self.failUnless(issubclass(self.driver.Error, Exception))
# Make sure required exceptions exist, and are in the defined hierarchy.
self.assertTrue(issubclass(self.driver.Warning, Exception))
self.assertTrue(issubclass(self.driver.Error, Exception))

self.assertTrue(issubclass(self.driver.InterfaceError, self.driver.Error))
self.assertTrue(issubclass(self.driver.DatabaseError, self.driver.Error))
Expand Down
2 changes: 1 addition & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"typeCheckingMode": "basic",
// Target the oldest supported version in editors and default CLI
"pythonVersion": "3.8",
"pythonVersion": "3.9",
// Keep it simple for now by allowing both mypy and pyright to use `type: ignore`
"enableTypeIgnoreComments": true,
// Exclude from scanning when running pyright
Expand Down

0 comments on commit 42d0e58

Please sign in to comment.