Skip to content

Commit 04430f6

Browse files
authored
Update values assignment
segregated the steps associated with assigning values to NDArrayBackedExtensionArray versus PandasObject/ExtensionArray to improve clarity and avoid a mypy type hinting issue.
1 parent 6d602aa commit 04430f6

File tree

1 file changed

+7
-2
lines changed
  • packages/db-dtypes/db_dtypes

1 file changed

+7
-2
lines changed

packages/db-dtypes/db_dtypes/core.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,20 @@ class BaseDatetimeArray(pandas_backports.OpsMixin, _mixins.NDArrayBackedExtensio
5757
def _datetime(cls, value: Any) -> Any:
5858
raise NotImplementedError
5959

60-
def __init__(self, values, dtype=None, copy: bool = False):
60+
def __init__(self, values, dtype=None, copy: bool = False):
6161
if not (
6262
isinstance(values, numpy.ndarray) and values.dtype == numpy.dtype("<M8[ns]")
6363
):
6464
values = self.__ndarray(values)
6565
elif copy:
6666
values = values.copy()
6767

68-
super().__init__(values=values, dtype=values.dtype) # type: ignore[call-arg]
68+
# 1. Assign the internal attributes required by NDArrayBackedExtensionArray
69+
self._ndarray = values
70+
self._dtype = values.dtype
71+
72+
# 2. Call super() without arguments to initialize PandasObject/ExtensionArray
73+
super().__init__()
6974

7075
@classmethod
7176
def __ndarray(cls, scalars):

0 commit comments

Comments
 (0)