Skip to content

Commit 6da7131

Browse files
committed
CLN: removed unnecessary type checks
1 parent e55a1e4 commit 6da7131

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
@@ -333,7 +333,7 @@ def _str_contains(
333333
def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
334334
if isinstance(pat, str):
335335
result = pc.starts_with(self._pa_array, pattern=pat)
336-
elif isinstance(pat, tuple) and all(isinstance(x, str) for x in pat):
336+
else:
337337
if len(pat) == 0:
338338
# mimic existing behaviour of string extension array
339339
# and python string method
@@ -345,8 +345,6 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
345345

346346
for p in pat[1:]:
347347
result = pc.or_(result, pc.starts_with(self._pa_array, pattern=p))
348-
else:
349-
raise TypeError("pat must be str or tuple[str, ...]")
350348
if not isna(na):
351349
result = result.fill_null(na)
352350
result = self._result_converter(result)
@@ -357,7 +355,7 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
357355
def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
358356
if isinstance(pat, str):
359357
result = pc.ends_with(self._pa_array, pattern=pat)
360-
elif isinstance(pat, tuple) and all(isinstance(x, str) for x in pat):
358+
else:
361359
if len(pat) == 0:
362360
# mimic existing behaviour of string extension array
363361
# and python string method
@@ -369,8 +367,6 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
369367

370368
for p in pat[1:]:
371369
result = pc.or_(result, pc.ends_with(self._pa_array, pattern=p))
372-
else:
373-
raise TypeError("pat must be of type str or tuple[str, ...]")
374370
if not isna(na):
375371
result = result.fill_null(na)
376372
result = self._result_converter(result)

0 commit comments

Comments
 (0)