We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9871bdd commit 6fd326dCopy full SHA for 6fd326d
pandas/core/base.py
@@ -8,6 +8,7 @@
8
import numpy as np
9
10
import pandas._libs.lib as lib
11
+from pandas._typing import T
12
from pandas.compat import PYPY
13
from pandas.compat.numpy import function as nv
14
from pandas.errors import AbstractMethodError
@@ -87,6 +88,14 @@ def __sizeof__(self):
87
88
# object's 'sizeof'
89
return super().__sizeof__()
90
91
+ def _ensure_type(self: T, obj) -> T:
92
+ """Ensure that an object has same type as self.
93
+
94
+ Used by type checkers.
95
+ """
96
+ assert isinstance(obj, type(self)), type(obj)
97
+ return obj
98
99
100
class NoNewAttributesMixin:
101
"""Mixin which prevents adding new attributes.
0 commit comments