Skip to content

Commit 8c8942a

Browse files
Improved type annotations.
1 parent 40caed2 commit 8c8942a

File tree

3 files changed

+64
-10
lines changed

3 files changed

+64
-10
lines changed

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Thick Mode Changes
6363
Common Changes
6464
++++++++++++++
6565

66+
#) Improved type annotations.
6667
#) Error ``DPY-2038: element at index {index} does not exist`` is now raised
6768
whenever an element in a database collection is missing. Previously, thick
6869
mode raised ``DPI-1024: element at index {index} does not exist`` and thin

src/oracledb/__init__.py

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2023, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -43,15 +43,67 @@
4343
from .lob import LOB
4444
from .dbobject import DbObject, DbObjectType
4545
from .var import Var
46-
from .constructors import *
4746
from .dsn import makedsn
4847
from .driver_mode import is_thin_mode
4948

50-
from .base_impl import *
51-
from .thick_impl import clientversion, init_oracle_client
49+
from .base_impl import (
50+
51+
# database types
52+
DB_TYPE_BFILE,
53+
DB_TYPE_BINARY_DOUBLE,
54+
DB_TYPE_BINARY_FLOAT,
55+
DB_TYPE_BINARY_INTEGER,
56+
DB_TYPE_BLOB,
57+
DB_TYPE_BOOLEAN,
58+
DB_TYPE_CHAR,
59+
DB_TYPE_CLOB,
60+
DB_TYPE_CURSOR,
61+
DB_TYPE_DATE,
62+
DB_TYPE_INTERVAL_DS,
63+
DB_TYPE_INTERVAL_YM,
64+
DB_TYPE_JSON,
65+
DB_TYPE_LONG,
66+
DB_TYPE_LONG_NVARCHAR,
67+
DB_TYPE_LONG_RAW,
68+
DB_TYPE_NCHAR,
69+
DB_TYPE_NCLOB,
70+
DB_TYPE_NUMBER,
71+
DB_TYPE_NVARCHAR,
72+
DB_TYPE_OBJECT,
73+
DB_TYPE_RAW,
74+
DB_TYPE_ROWID,
75+
DB_TYPE_TIMESTAMP,
76+
DB_TYPE_TIMESTAMP_LTZ,
77+
DB_TYPE_TIMESTAMP_TZ,
78+
DB_TYPE_UNKNOWN,
79+
DB_TYPE_UROWID,
80+
DB_TYPE_VARCHAR,
81+
82+
# API types
83+
BINARY,
84+
DATETIME,
85+
NUMBER,
86+
ROWID,
87+
STRING
88+
)
89+
90+
from .thick_impl import (
91+
clientversion,
92+
init_oracle_client
93+
)
94+
95+
from .constructors import (
96+
Binary,
97+
Date,
98+
DateFromTicks,
99+
Time,
100+
TimeFromTicks,
101+
Timestamp,
102+
TimestampFromTicks
103+
)
52104

53105
package = sys.modules[__name__]
54-
init_base_impl(package)
106+
base_impl.init_base_impl(package)
55107
thick_impl.init_thick_impl(package)
56108
thin_impl.init_thin_impl(package)
57109
del package
@@ -68,8 +120,9 @@ def __setattr__(self, name, value):
68120
__future__ = Future()
69121

70122
# remove unnecessary symbols
71-
del exceptions, errors, connection, pool, constants
72-
del constructors, base_impl, thick_impl, thin_impl, utils
123+
del exceptions, errors, connection, pool, constants, driver_mode, sys
124+
del constructors, dsn, lob, base_impl, thick_impl, thin_impl, utils, var
125+
del connect_params, pool_params, subscr, aq, soda, cursor, dbobject
73126

74127
# general aliases (for backwards compatibility)
75128
ObjectType = DbObjectType

src/oracledb/cursor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2021, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2021, 2023, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -309,7 +309,7 @@ def description(self) -> tuple:
309309

310310
def execute(self, statement: Union[str, None],
311311
parameters: Union[list, tuple, dict]=None,
312-
**keyword_parameters: dict) -> Union["Cursor", None]:
312+
**keyword_parameters: Any) -> Union["Cursor", None]:
313313
"""
314314
Execute a statement against the database.
315315
@@ -702,7 +702,7 @@ def scrollable(self, value: bool) -> None:
702702
self._verify_open()
703703
self._impl.scrollable = value
704704

705-
def setinputsizes(self, *args: tuple, **kwargs: dict) -> Union[list, dict]:
705+
def setinputsizes(self, *args: Any, **kwargs: Any) -> Union[list, dict]:
706706
"""
707707
This can be used before a call to execute(), callfunc() or callproc()
708708
to predefine memory areas for the operation’s parameters. Each

0 commit comments

Comments
 (0)