From 1f1e220113cde0ffb010210c05156826496d0200 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 7 Nov 2025 11:05:59 -0800 Subject: [PATCH] CLN: Replace get_option(infer_string) with using_string_dtype --- pandas/core/strings/accessor.py | 4 ++-- pandas/io/pytables.py | 8 ++++---- pandas/io/sas/sas7bdat.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index ff3a17e4d2d5b..110473be5d27c 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -12,7 +12,7 @@ import numpy as np -from pandas._config import get_option +from pandas._config import using_string_dtype from pandas._libs import lib from pandas._typing import ( @@ -2123,7 +2123,7 @@ def decode( """ if dtype is not None and not is_string_dtype(dtype): raise ValueError(f"dtype must be string or object, got {dtype=}") - if dtype is None and get_option("future.infer_string"): + if dtype is None and using_string_dtype(): dtype = "str" # TODO: Add a similar _bytes interface. if encoding in _cpython_optimized_decoders: diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 3616a93321358..f7980ea01843e 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -2278,7 +2278,7 @@ def convert( except UnicodeEncodeError as err: if ( errors == "surrogatepass" - and get_option("future.infer_string") + and using_string_dtype() and str(err).endswith("surrogates not allowed") and HAS_PYARROW ): @@ -3214,7 +3214,7 @@ def read_index_node( except UnicodeEncodeError as err: if ( self.errors == "surrogatepass" - and get_option("future.infer_string") + and using_string_dtype() and str(err).endswith("surrogates not allowed") and HAS_PYARROW ): @@ -3365,7 +3365,7 @@ def read( except UnicodeEncodeError as err: if ( self.errors == "surrogatepass" - and get_option("future.infer_string") + and using_string_dtype() and str(err).endswith("surrogates not allowed") and HAS_PYARROW ): @@ -4829,7 +4829,7 @@ def read( except UnicodeEncodeError as err: if ( self.errors == "surrogatepass" - and get_option("future.infer_string") + and using_string_dtype() and str(err).endswith("surrogates not allowed") and HAS_PYARROW ): diff --git a/pandas/io/sas/sas7bdat.py b/pandas/io/sas/sas7bdat.py index 089576e5680cb..e3c1b2219599d 100644 --- a/pandas/io/sas/sas7bdat.py +++ b/pandas/io/sas/sas7bdat.py @@ -22,7 +22,7 @@ import numpy as np -from pandas._config import get_option +from pandas._config import using_string_dtype from pandas._libs.byteswap import ( read_double_with_byteswap, @@ -699,7 +699,7 @@ def _chunk_to_dataframe(self) -> DataFrame: rslt = {} js, jb = 0, 0 - infer_string = get_option("future.infer_string") + infer_string = using_string_dtype() for j in range(self.column_count): name = self.column_names[j]