Skip to content

Commit 4b1338c

Browse files
rename WARNING_CHECK_DISABLED -> CHAINED_WARNING_DISABLED and combine with PYPY check
1 parent 2337961 commit 4b1338c

File tree

8 files changed

+27
-33
lines changed

8 files changed

+27
-33
lines changed

pandas/_testing/contexts.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
)
1313
import uuid
1414

15-
from pandas.compat import (
16-
PYPY,
17-
WARNING_CHECK_DISABLED,
18-
)
15+
from pandas.compat import CHAINED_WARNING_DISABLED
1916
from pandas.errors import ChainedAssignmentError
2017

2118
from pandas.io.common import get_handle
@@ -166,7 +163,7 @@ def with_csv_dialect(name: str, **kwargs) -> Generator[None]:
166163
def raises_chained_assignment_error(extra_warnings=(), extra_match=()):
167164
from pandas._testing import assert_produces_warning
168165

169-
if PYPY or WARNING_CHECK_DISABLED:
166+
if CHAINED_WARNING_DISABLED:
170167
if not extra_warnings:
171168
from contextlib import nullcontext
172169

pandas/compat/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
from typing import TYPE_CHECKING
1717

1818
from pandas.compat._constants import (
19+
CHAINED_WARNING_DISABLED,
1920
IS64,
2021
ISMUSL,
2122
PY312,
2223
PY314,
2324
PYPY,
24-
WARNING_CHECK_DISABLED,
2525
WASM,
2626
)
2727
from pandas.compat.numpy import is_numpy_dev
@@ -152,14 +152,14 @@ def is_ci_environment() -> bool:
152152

153153

154154
__all__ = [
155+
"CHAINED_WARNING_DISABLED",
155156
"HAS_PYARROW",
156157
"IS64",
157158
"ISMUSL",
158159
"PY312",
159160
"PY314",
160161
"PYARROW_MIN_VERSION",
161162
"PYPY",
162-
"WARNING_CHECK_DISABLED",
163163
"WASM",
164164
"is_numpy_dev",
165165
"pa_version_under14p0",

pandas/compat/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"])
2020
ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "")
2121
REF_COUNT = 3 if PY314 else 2
22-
CHAINED_WARNING_DISABLED = False # PY314
22+
CHAINED_WARNING_DISABLED = PYPY
2323

2424

2525
__all__ = [

pandas/core/frame.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
)
5050
from pandas._libs.hashtable import duplicated
5151
from pandas._libs.lib import is_range_indexer
52-
from pandas.compat import PYPY
52+
from pandas.compat import CHAINED_WARNING_DISABLED
5353
from pandas.compat._constants import (
5454
REF_COUNT,
5555
)
@@ -4404,7 +4404,7 @@ def __setitem__(self, key, value) -> None:
44044404
z 3 50
44054405
# Values for 'a' and 'b' are completely ignored!
44064406
"""
4407-
if not PYPY:
4407+
if not CHAINED_WARNING_DISABLED:
44084408
if sys.getrefcount(self) <= REF_COUNT and not lib.is_local_in_caller_frame(
44094409
self
44104410
):
@@ -9364,7 +9364,7 @@ def update(
93649364
1 2 500.0
93659365
2 3 6.0
93669366
"""
9367-
if not PYPY:
9367+
if not CHAINED_WARNING_DISABLED:
93689368
if sys.getrefcount(self) < REF_COUNT and not lib.is_local_in_caller_frame(
93699369
self
93709370
):

pandas/core/generic.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
WriteExcelBuffer,
8383
npt,
8484
)
85-
from pandas.compat import PYPY
85+
from pandas.compat import CHAINED_WARNING_DISABLED
8686
from pandas.compat._constants import (
8787
REF_COUNT,
8888
)
@@ -7081,7 +7081,7 @@ def fillna(
70817081
"""
70827082
inplace = validate_bool_kwarg(inplace, "inplace")
70837083
if inplace:
7084-
if not PYPY:
7084+
if not CHAINED_WARNING_DISABLED:
70857085
if sys.getrefcount(
70867086
self
70877087
) < REF_COUNT and not lib.is_local_in_caller_frame(self):
@@ -7330,7 +7330,7 @@ def ffill(
73307330
"""
73317331
inplace = validate_bool_kwarg(inplace, "inplace")
73327332
if inplace:
7333-
if not PYPY:
7333+
if not CHAINED_WARNING_DISABLED:
73347334
if sys.getrefcount(
73357335
self
73367336
) < REF_COUNT and not lib.is_local_in_caller_frame(self):
@@ -7472,7 +7472,7 @@ def bfill(
74727472
"""
74737473
inplace = validate_bool_kwarg(inplace, "inplace")
74747474
if inplace:
7475-
if not PYPY:
7475+
if not CHAINED_WARNING_DISABLED:
74767476
if sys.getrefcount(
74777477
self
74787478
) < REF_COUNT and not lib.is_local_in_caller_frame(self):
@@ -7559,7 +7559,7 @@ def replace(
75597559

75607560
inplace = validate_bool_kwarg(inplace, "inplace")
75617561
if inplace:
7562-
if not PYPY:
7562+
if not CHAINED_WARNING_DISABLED:
75637563
if sys.getrefcount(
75647564
self
75657565
) < REF_COUNT and not lib.is_local_in_caller_frame(self):
@@ -7924,7 +7924,7 @@ def interpolate(
79247924
inplace = validate_bool_kwarg(inplace, "inplace")
79257925

79267926
if inplace:
7927-
if not PYPY:
7927+
if not CHAINED_WARNING_DISABLED:
79287928
if sys.getrefcount(
79297929
self
79307930
) < REF_COUNT and not lib.is_local_in_caller_frame(self):
@@ -8581,7 +8581,7 @@ def clip(
85818581
inplace = validate_bool_kwarg(inplace, "inplace")
85828582

85838583
if inplace:
8584-
if not PYPY:
8584+
if not CHAINED_WARNING_DISABLED:
85858585
if sys.getrefcount(
85868586
self
85878587
) < REF_COUNT and not lib.is_local_in_caller_frame(self):
@@ -10218,7 +10218,7 @@ def where(
1021810218
"""
1021910219
inplace = validate_bool_kwarg(inplace, "inplace")
1022010220
if inplace:
10221-
if not PYPY:
10221+
if not CHAINED_WARNING_DISABLED:
1022210222
if sys.getrefcount(
1022310223
self
1022410224
) < REF_COUNT and not lib.is_local_in_caller_frame(self):
@@ -10284,7 +10284,7 @@ def mask(
1028410284
) -> Self | None:
1028510285
inplace = validate_bool_kwarg(inplace, "inplace")
1028610286
if inplace:
10287-
if not PYPY:
10287+
if not CHAINED_WARNING_DISABLED:
1028810288
if sys.getrefcount(
1028910289
self
1029010290
) < REF_COUNT and not lib.is_local_in_caller_frame(self):

pandas/core/indexing.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515

1616
from pandas._libs.indexing import NDFrameIndexerBase
1717
from pandas._libs.lib import item_from_zerodim
18-
from pandas.compat import PYPY
19-
from pandas.compat._constants import (
20-
REF_COUNT,
21-
WARNING_CHECK_DISABLED,
22-
)
18+
from pandas.compat import CHAINED_WARNING_DISABLED
19+
from pandas.compat._constants import REF_COUNT
2320
from pandas.errors import (
2421
AbstractMethodError,
2522
ChainedAssignmentError,
@@ -920,7 +917,7 @@ def _ensure_listlike_indexer(self, key, axis=None, value=None) -> None:
920917

921918
@final
922919
def __setitem__(self, key, value) -> None:
923-
if not PYPY and not WARNING_CHECK_DISABLED:
920+
if not CHAINED_WARNING_DISABLED:
924921
if sys.getrefcount(self.obj) <= REF_COUNT:
925922
warnings.warn(
926923
_chained_assignment_msg, ChainedAssignmentError, stacklevel=2
@@ -2588,7 +2585,7 @@ def __getitem__(self, key):
25882585
return super().__getitem__(key)
25892586

25902587
def __setitem__(self, key, value) -> None:
2591-
if not PYPY and not WARNING_CHECK_DISABLED:
2588+
if not CHAINED_WARNING_DISABLED:
25922589
if sys.getrefcount(self.obj) <= REF_COUNT:
25932590
warnings.warn(
25942591
_chained_assignment_msg, ChainedAssignmentError, stacklevel=2
@@ -2619,7 +2616,7 @@ def _convert_key(self, key):
26192616
return key
26202617

26212618
def __setitem__(self, key, value) -> None:
2622-
if not PYPY and not WARNING_CHECK_DISABLED:
2619+
if not CHAINED_WARNING_DISABLED:
26232620
if sys.getrefcount(self.obj) <= REF_COUNT:
26242621
warnings.warn(
26252622
_chained_assignment_msg, ChainedAssignmentError, stacklevel=2

pandas/core/series.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
reshape,
3535
)
3636
from pandas._libs.lib import is_range_indexer
37-
from pandas.compat import PYPY
37+
from pandas.compat import CHAINED_WARNING_DISABLED
3838
from pandas.compat._constants import (
3939
REF_COUNT,
4040
)
@@ -1057,7 +1057,7 @@ def _get_value(self, label, takeable: bool = False):
10571057
return self.iloc[loc]
10581058

10591059
def __setitem__(self, key, value) -> None:
1060-
if not PYPY:
1060+
if not CHAINED_WARNING_DISABLED:
10611061
if sys.getrefcount(self) <= REF_COUNT and not lib.is_local_in_caller_frame(
10621062
self
10631063
):
@@ -3353,7 +3353,7 @@ def update(self, other: Series | Sequence | Mapping) -> None:
33533353
2 3
33543354
dtype: int64
33553355
"""
3356-
if not PYPY:
3356+
if not CHAINED_WARNING_DISABLED:
33573357
if sys.getrefcount(self) < REF_COUNT and not lib.is_local_in_caller_frame(
33583358
self
33593359
):

pandas/tests/copy_view/test_chained_assignment_deprecation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.compat import WARNING_CHECK_DISABLED
4+
from pandas.compat import CHAINED_WARNING_DISABLED
55
from pandas.errors import ChainedAssignmentError
66

77
from pandas import DataFrame
@@ -18,7 +18,7 @@ def test_series_setitem(indexer):
1818

1919
# using custom check instead of tm.assert_produces_warning because that doesn't
2020
# fail if multiple warnings are raised
21-
if WARNING_CHECK_DISABLED:
21+
if CHAINED_WARNING_DISABLED:
2222
return
2323
with pytest.warns() as record: # noqa: TID251
2424
df["a"][indexer] = 0

0 commit comments

Comments
 (0)