We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9871bdd commit d01e6ccCopy full SHA for d01e6cc
pandas/core/base.py
@@ -37,6 +37,10 @@
37
from pandas.core.construction import create_series_with_explicit_dtype
38
import pandas.core.nanops as nanops
39
40
+
41
+from pandas._typing import T
42
43
44
_shared_docs: Dict[str, str] = dict()
45
_indexops_doc_kwargs = dict(
46
klass="IndexOpsMixin",
@@ -87,6 +91,14 @@ def __sizeof__(self):
87
91
# object's 'sizeof'
88
92
return super().__sizeof__()
89
93
94
+ def _ensure_type(self: T, obj) -> T:
95
+ """Ensure that an object has same type as self.
96
97
+ Used by type checkers.
98
+ """
99
+ assert isinstance(obj, type(self)), type(obj)
100
+ return obj
101
90
102
103
class NoNewAttributesMixin:
104
"""Mixin which prevents adding new attributes.
0 commit comments