Skip to content

CLN: remove is_stringlike #29450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
is_re_compilable,
is_scalar,
is_sequence,
is_string_like,
)

from pandas._typing import ArrayLike
Expand Down Expand Up @@ -1383,8 +1382,8 @@ def is_numeric_v_string_like(a, b):
is_a_string_array = is_a_array and is_string_like_dtype(a)
is_b_string_array = is_b_array and is_string_like_dtype(b)

is_a_scalar_string_like = not is_a_array and is_string_like(a)
is_b_scalar_string_like = not is_b_array and is_string_like(b)
is_a_scalar_string_like = not is_a_array and isinstance(a, str)
is_b_scalar_string_like = not is_b_array and isinstance(b, str)

return (
(is_a_numeric_array and is_b_scalar_string_like)
Expand Down
24 changes: 0 additions & 24 deletions pandas/core/dtypes/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,6 @@ def is_number(obj):
return isinstance(obj, (Number, np.number))


def is_string_like(obj):
"""
Check if the object is a string.

Parameters
----------
obj : The object to check

Examples
--------
>>> is_string_like("foo")
True
>>> is_string_like(1)
False

Returns
-------
is_str_like : bool
Whether `obj` is a string or not.
"""

return isinstance(obj, str)


def _iterable_not_string(obj):
"""
Check if the object is an iterable but not a string.
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
is_integer,
is_list_like,
is_scalar,
is_string_like,
)
from pandas.core.dtypes.concat import concat_compat
from pandas.core.dtypes.dtypes import DatetimeTZDtype
Expand Down Expand Up @@ -1659,7 +1658,7 @@ def bdate_range(
msg = "freq must be specified for bdate_range; use date_range instead"
raise TypeError(msg)

if is_string_like(freq) and freq.startswith("C"):
if isinstance(freq, str) and freq.startswith("C"):
try:
weekmask = weekmask or "Mon Tue Wed Thu Fri"
freq = prefix_mapping[freq](holidays=holidays, weekmask=weekmask)
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
is_list_like,
is_object_dtype,
is_scalar,
is_string_like,
is_timedelta64_dtype,
)
from pandas.core.dtypes.generic import (
Expand Down Expand Up @@ -4539,7 +4538,7 @@ def to_csv(self, *args, **kwargs):
# passed as second argument (while the first is the same)
maybe_sep = args[1]

if not (is_string_like(maybe_sep) and len(maybe_sep) == 1):
if not (isinstance(maybe_sep, str) and len(maybe_sep) == 1):
# old signature
warnings.warn(
"The signature of `Series.to_csv` was aligned "
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
is_list_like,
is_re,
is_scalar,
is_string_like,
)
from pandas.core.dtypes.generic import (
ABCDataFrame,
Expand Down Expand Up @@ -601,7 +600,7 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
"""

# Check whether repl is valid (GH 13438, GH 15055)
if not (is_string_like(repl) or callable(repl)):
if not (isinstance(repl, str) or callable(repl)):
raise TypeError("repl must be a string or callable")

is_compiled_re = is_re(pat)
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pandas.compat._optional import import_optional_dependency
from pandas.util._decorators import Appender

from pandas.core.dtypes.common import is_float, is_string_like
from pandas.core.dtypes.common import is_float

import pandas as pd
from pandas.api.types import is_dict_like, is_list_like
Expand Down Expand Up @@ -1488,7 +1488,7 @@ def _get_level_lengths(index, hidden_elements=None):


def _maybe_wrap_formatter(formatter):
if is_string_like(formatter):
if isinstance(formatter, str):
return lambda x: formatter.format(x)
elif callable(formatter):
return formatter
Expand Down