Skip to content

Commit 1d4f726

Browse files
committed
Fix typing
1 parent a7b4e27 commit 1d4f726

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pandas/core/internals/array_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def fillna(self: T, value, limit, inplace: bool, downcast) -> T:
374374
def astype(self: T, dtype, copy: bool = False, errors: str = "raise") -> T:
375375
return self.apply(astype_array_safe, dtype=dtype, copy=copy, errors=errors)
376376

377-
def convert(self: T, copy: bool) -> T:
377+
def convert(self: T, copy: bool | None) -> T:
378378
def _convert(arr):
379379
if is_object_dtype(arr.dtype):
380380
# extract PandasArray for tests that patch PandasArray._typ

pandas/core/internals/blocks.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ def convert(
462462
"""
463463
if not copy and using_copy_on_write:
464464
result = self.copy(deep=False)
465-
result._ref = weakref.ref(original_blocks[self.mgr_locs.as_array[0]])
465+
result._ref = weakref.ref( # type: ignore[attr-defined]
466+
original_blocks[self.mgr_locs.as_array[0]]
467+
)
466468
return [result]
467469
return [self.copy()] if copy else [self]
468470

@@ -1982,7 +1984,9 @@ def convert(
19821984
# that is fixed, we short-circuit here.
19831985
if using_copy_on_write:
19841986
result = self.copy(deep=False)
1985-
result._ref = weakref.ref(original_blocks[self.mgr_locs.as_array[0]])
1987+
result._ref = weakref.ref( # type: ignore[attr-defined]
1988+
original_blocks[self.mgr_locs.as_array[0]]
1989+
)
19861990
return [result]
19871991
return [self]
19881992

@@ -2007,7 +2011,7 @@ def convert(
20072011

20082012
res_values = ensure_block_shape(res_values, self.ndim)
20092013
result = self.make_block(res_values)
2010-
result._ref = ref
2014+
result._ref = ref # type: ignore[attr-defined]
20112015
return [result]
20122016

20132017

pandas/core/internals/managers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def convert(self: T, copy: bool | None) -> T:
455455
using_copy_on_write=using_copy_on_write(),
456456
original_blocks=original_blocks,
457457
)
458-
refs = [getattr(blk, "_ref", None) is not None for blk in mgr.blocks]
458+
refs = [getattr(blk, "_ref", None) for blk in mgr.blocks]
459459
if any(ref is not None for ref in refs):
460460
mgr.refs = refs
461461
mgr.parent = self

0 commit comments

Comments
 (0)