diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 5783842e9ddef..e0340f99b92e1 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -470,12 +470,12 @@ def isin(comps: ListLike, values: ListLike) -> npt.NDArray[np.bool_]: if not is_list_like(comps): raise TypeError( "only list-like objects are allowed to be passed " - f"to isin(), you passed a [{type(comps).__name__}]" + f"to isin(), you passed a `{type(comps).__name__}`" ) if not is_list_like(values): raise TypeError( "only list-like objects are allowed to be passed " - f"to isin(), you passed a [{type(values).__name__}]" + f"to isin(), you passed a `{type(values).__name__}`" ) if not isinstance(values, (ABCIndex, ABCSeries, ABCExtensionArray, np.ndarray)): diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 8898379689cfd..46e2b64cb60c6 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -2581,7 +2581,7 @@ def isin(self, values) -> npt.NDArray[np.bool_]: values_type = type(values).__name__ raise TypeError( "only list-like objects are allowed to be passed " - f"to isin(), you passed a [{values_type}]" + f"to isin(), you passed a `{values_type}`" ) values = sanitize_array(values, None, None) null_mask = np.asarray(isna(values)) diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index 35960c707d3bd..e6e1363603e09 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -158,7 +158,7 @@ def test_simple_cmp_ops(self, cmp_op, lhs, rhs, engine, parser): [ r"only list-like( or dict-like)? objects are allowed to be " r"passed to (DataFrame\.)?isin\(\), you passed a " - r"(\[|')bool(\]|')", + r"(`|')bool(`|')", "argument of type 'bool' is not iterable", ] ) @@ -203,7 +203,7 @@ def test_compound_invert_op(self, op, lhs, rhs, request, engine, parser): [ r"only list-like( or dict-like)? objects are allowed to be " r"passed to (DataFrame\.)?isin\(\), you passed a " - r"(\[|')float(\]|')", + r"(`|')float(`|')", "argument of type 'float' is not iterable", ] ) diff --git a/pandas/tests/series/methods/test_isin.py b/pandas/tests/series/methods/test_isin.py index 3e4857b7abf38..4ea2fbf51afc9 100644 --- a/pandas/tests/series/methods/test_isin.py +++ b/pandas/tests/series/methods/test_isin.py @@ -34,7 +34,7 @@ def test_isin_with_string_scalar(self): s = Series(["A", "B", "C", "a", "B", "B", "A", "C"]) msg = ( r"only list-like objects are allowed to be passed to isin\(\), " - r"you passed a \[str\]" + r"you passed a `str`" ) with pytest.raises(TypeError, match=msg): s.isin("a") diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index 8c26bbd209a6a..34a0bee877664 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -888,7 +888,7 @@ class TestIsin: def test_invalid(self): msg = ( r"only list-like objects are allowed to be passed to isin\(\), " - r"you passed a \[int\]" + r"you passed a `int`" ) with pytest.raises(TypeError, match=msg): algos.isin(1, 1)