Skip to content

Commit 6fd326d

Browse files
committed
TYP: Add FrameORSeries to NDFrame
1 parent 9871bdd commit 6fd326d

File tree

3 files changed

+100
-61
lines changed

3 files changed

+100
-61
lines changed

pandas/core/base.py

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import numpy as np
99

1010
import pandas._libs.lib as lib
11+
from pandas._typing import T
1112
from pandas.compat import PYPY
1213
from pandas.compat.numpy import function as nv
1314
from pandas.errors import AbstractMethodError
@@ -87,6 +88,14 @@ def __sizeof__(self):
8788
# object's 'sizeof'
8889
return super().__sizeof__()
8990

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+
9099

91100
class NoNewAttributesMixin:
92101
"""Mixin which prevents adding new attributes.

0 commit comments

Comments
 (0)