Skip to content

Commit 3b247d9

Browse files
committed
CLN: removed unnecessary type checks
1 parent 9dc3587 commit 3b247d9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

pandas/core/arrays/string_arrow.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def _str_contains(
339339
def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
340340
if isinstance(pat, str):
341341
result = pc.starts_with(self._pa_array, pattern=pat)
342-
elif isinstance(pat, tuple) and all(isinstance(x, str) for x in pat):
342+
else:
343343
if len(pat) == 0:
344344
# mimic existing behaviour of string extension array
345345
# and python string method
@@ -351,16 +351,14 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
351351

352352
for p in pat[1:]:
353353
result = pc.or_(result, pc.starts_with(self._pa_array, pattern=p))
354-
else:
355-
raise TypeError("pat must be str or tuple[str, ...]")
356354
if not isna(na):
357355
result = result.fill_null(na)
358356
return self._result_converter(result)
359357

360358
def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
361359
if isinstance(pat, str):
362360
result = pc.ends_with(self._pa_array, pattern=pat)
363-
elif isinstance(pat, tuple) and all(isinstance(x, str) for x in pat):
361+
else:
364362
if len(pat) == 0:
365363
# mimic existing behaviour of string extension array
366364
# and python string method
@@ -372,8 +370,6 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
372370

373371
for p in pat[1:]:
374372
result = pc.or_(result, pc.ends_with(self._pa_array, pattern=p))
375-
else:
376-
raise TypeError("pat must be of type str or tuple[str, ...]")
377373
if not isna(na):
378374
result = result.fill_null(na)
379375
return self._result_converter(result)

0 commit comments

Comments
 (0)