Skip to content
Merged
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[tool.mypy]
ignore_missing_imports = true
ignore_errors = false
enable_error_code = "ignore-without-code"
warn_unused_ignores = true
# If we don't specify this, then mypy will check excluded files if
# they are imported by a checked file.
follow_imports = "skip"
Expand Down
66 changes: 31 additions & 35 deletions python/cudf/cudf/core/accessors/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def join(
else:
# If self._column is not a ListColumn, we will have to
# split each row by character and create a ListColumn out of it.
list_column = self._column.fillna("").character_tokenize() # type: ignore[assignment]
list_column = self._column.fillna("").character_tokenize()
if len(list_column) == 0:
list_column = column_empty( # type: ignore[assignment]
len(self._column), dtype=list_column.dtype
Expand All @@ -524,9 +524,9 @@ def join(
f"of type: {type(sep_na_rep)}"
)
data = list_column.join_list_elements( # type: ignore[attr-defined]
sep_column, # type: ignore[arg-type]
sep_column,
sep_na_rep,
string_na_rep, # type: ignore[arg-type]
string_na_rep,
)
else:
raise TypeError(
Expand Down Expand Up @@ -753,7 +753,7 @@ def contains(
result_col = self._column.contains_re(pat, flags) # type: ignore[arg-type]
else:
if case is False:
input_column = self._column.to_lower() # type: ignore[union-attr]
input_column = self._column.to_lower()
pat_normed = pat.lower() # type: ignore[union-attr]
else:
input_column = self._column
Expand All @@ -763,7 +763,7 @@ def contains(
# TODO: we silently ignore the `regex=` flag here
col_pat = as_column(pat, dtype=CUDF_STRING_DTYPE)
if case is False:
input_column = self._column.to_lower() # type: ignore[union-attr]
input_column = self._column.to_lower()
col_pat = col_pat.to_lower() # type: ignore[attr-defined]
else:
input_column = self._column
Expand Down Expand Up @@ -990,7 +990,7 @@ def replace(

# Pandas forces non-regex replace when pat is a single-character
if regex is True and len(pat) > 1:
result = self._column.replace_re( # type: ignore[arg-type]
result = self._column.replace_re(
pat, # type: ignore[arg-type]
pa_repl,
n,
Expand Down Expand Up @@ -1106,7 +1106,7 @@ def slice(
dtype: object
"""
return self._return_or_inplace(
self._column.slice_strings(start, stop, step) # type: ignore[arg-type]
self._column.slice_strings(start, stop, step)
)

def isinteger(self) -> Series | Index:
Expand Down Expand Up @@ -2133,7 +2133,7 @@ def slice_from(self, starts: Series, stops: Series) -> Series | Index:
dtype: object
"""
return self._return_or_inplace(
self._column.slice_strings(starts._column, stops._column) # type: ignore[arg-type]
self._column.slice_strings(starts._column, stops._column)
)

def slice_replace(
Expand Down Expand Up @@ -2320,13 +2320,13 @@ def get(self, i: int = 0) -> Series | Index:
if i < 0:
next_index = i - 1
step = -1
to_mask = str_lens < abs(i) # type: ignore[operator]
to_mask = str_lens < abs(i)
else:
next_index = i + 1
step = 1
to_mask = str_lens <= i # type: ignore[operator]
to_mask = str_lens <= i
result = self.slice(i, next_index, step)
if to_mask.any(): # type: ignore[union-attr]
if to_mask.any():
result[to_mask] = pd.NA # type: ignore[index]
return result

Expand Down Expand Up @@ -3796,7 +3796,7 @@ def _starts_ends_with(
pat: str | tuple[str, ...],
) -> Series | Index:
return self._return_or_inplace(
self._column.starts_ends_with(method, pat) # type: ignore[arg-type]
self._column.starts_ends_with(method, pat)
)

def endswith(self, pat: str | tuple[str, ...]) -> Series | Index:
Expand Down Expand Up @@ -3917,10 +3917,10 @@ def removesuffix(self, suffix: str) -> Series | Index:
"""
if suffix is None or len(suffix) == 0:
return self._return_or_inplace(self._column)
ends_column = self.endswith(suffix)._column # type: ignore[union-attr]
removed_column = self.slice(0, -len(suffix), None)._column # type: ignore[union-attr]
ends_column = self.endswith(suffix)._column
removed_column = self.slice(0, -len(suffix), None)._column

result = removed_column.copy_if_else(self._column, ends_column) # type: ignore[arg-type]
result = removed_column.copy_if_else(self._column, ends_column)
return self._return_or_inplace(result)

def removeprefix(self, prefix: str) -> Series | Index:
Expand Down Expand Up @@ -3956,9 +3956,9 @@ def removeprefix(self, prefix: str) -> Series | Index:
"""
if prefix is None or len(prefix) == 0:
return self._return_or_inplace(self._column)
starts_column = self.startswith(prefix)._column # type: ignore[union-attr]
removed_column = self.slice(len(prefix), None, None)._column # type: ignore[union-attr]
result = removed_column.copy_if_else(self._column, starts_column) # type: ignore[arg-type]
starts_column = self.startswith(prefix)._column
removed_column = self.slice(len(prefix), None, None)._column
result = removed_column.copy_if_else(self._column, starts_column)
return self._return_or_inplace(result)

def _find(
Expand Down Expand Up @@ -4125,7 +4125,7 @@ def index(
if end is None:
end = -1

result_col = self.find(sub, start, end)._column # type: ignore[union-attr]
result_col = self.find(sub, start, end)._column

result = self._return_or_inplace(result_col)

Expand Down Expand Up @@ -4187,7 +4187,7 @@ def rindex(
if end is None:
end = -1

result_col = self.rfind(sub, start, end)._column # type: ignore[union-attr]
result_col = self.rfind(sub, start, end)._column

result = self._return_or_inplace(result_col)

Expand Down Expand Up @@ -4494,7 +4494,7 @@ def tokenize(self, delimiter: str = " ") -> Series | Index:

if isinstance(delim, ColumnBase):
result = self._return_or_inplace(
self._column.tokenize_column(delim), # type: ignore[arg-type]
self._column.tokenize_column(delim),
retain_index=False,
)
elif isinstance(delim, plc.Scalar):
Expand All @@ -4508,7 +4508,7 @@ def tokenize(self, delimiter: str = " ") -> Series | Index:
for delimiters, but got {type(delimiter)}"
)
if isinstance(self._parent, cudf.Series):
result.index = self._parent.index.repeat( # type: ignore
result.index = self._parent.index.repeat( # type: ignore[union-attr]
self.token_count(delimiter=delimiter)
)
return result
Expand Down Expand Up @@ -4635,12 +4635,12 @@ def token_count(self, delimiter: str = " ") -> Series | Index:
delim = _massage_string_arg(delimiter, "delimiter", allow_col=True)
if isinstance(delim, ColumnBase):
return self._return_or_inplace(
self._column.count_tokens_column(delim) # type: ignore[arg-type]
self._column.count_tokens_column(delim)
)

elif isinstance(delim, plc.Scalar):
return self._return_or_inplace(
self._column.count_tokens_scalar(delim) # type: ignore[arg-type]
self._column.count_tokens_scalar(delim)
)
else:
raise TypeError(
Expand Down Expand Up @@ -4734,7 +4734,7 @@ def character_ngrams(
if isinstance(result, cudf.Series) and not as_list:
# before exploding, removes those lists which have 0 length
result = result[result.list.len() > 0]
return result.explode() # type: ignore
return result.explode() # type: ignore[union-attr]
return result

def hash_character_ngrams(
Expand Down Expand Up @@ -5032,9 +5032,7 @@ def is_consonant(self, position) -> Series | Index:
"""
if can_convert_to_column(position):
position = as_column(position)
return self._return_or_inplace(
self._column.is_letter(False, position) # type: ignore[arg-type]
)
return self._return_or_inplace(self._column.is_letter(False, position))

def is_vowel(self, position) -> Series | Index:
"""
Expand Down Expand Up @@ -5069,9 +5067,7 @@ def is_vowel(self, position) -> Series | Index:
"""
if can_convert_to_column(position):
position = as_column(position)
return self._return_or_inplace(
self._column.is_letter(True, position) # type: ignore[arg-type]
)
return self._return_or_inplace(self._column.is_letter(True, position))

def build_suffix_array(self, min_width: int) -> Series | Index:
"""
Expand All @@ -5095,7 +5091,7 @@ def build_suffix_array(self, min_width: int) -> Series | Index:
New column of suffix array
"""
return self._return_or_inplace(
self._column.build_suffix_array(min_width), # type: ignore[arg-type]
self._column.build_suffix_array(min_width),
inplace=False,
expand=False,
retain_index=False,
Expand Down Expand Up @@ -5124,7 +5120,7 @@ def resolve_duplicates(self, sa, min_width: int) -> Series | Index:
"""
sa_column = sa._column
return self._return_or_inplace(
self._column.resolve_duplicates(sa_column, min_width), # type: ignore[arg-type]
self._column.resolve_duplicates(sa_column, min_width),
inplace=False,
expand=False,
retain_index=False,
Expand Down Expand Up @@ -5163,7 +5159,7 @@ def resolve_duplicates_pair(
return self._return_or_inplace(
self._column.resolve_duplicates_pair(
sa1_col, input2_col, sa2_col, min_width
), # type: ignore[arg-type]
),
inplace=False,
expand=False,
retain_index=False,
Expand Down Expand Up @@ -5505,5 +5501,5 @@ def jaccard_index(self, input: Series, width: int) -> Series | Index:
dtype: float32
"""
return self._return_or_inplace(
self._column.jaccard_index(input._column, width) # type: ignore[arg-type]
self._column.jaccard_index(input._column, width)
)
8 changes: 4 additions & 4 deletions python/cudf/cudf/core/column/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CategoricalColumn(column.ColumnBase):
"""

dtype: CategoricalDtype
_children: tuple[NumericalColumn] # type: ignore[assignment]
_children: tuple[NumericalColumn]
_VALID_REDUCTIONS = {
"max",
"min",
Expand All @@ -103,7 +103,7 @@ def __init__(
mask: Buffer | None,
offset: int,
null_count: int,
children: tuple[NumericalColumn], # type: ignore[assignment]
children: tuple[NumericalColumn],
):
if data is not None:
raise ValueError(f"{data=} must be None")
Expand Down Expand Up @@ -438,7 +438,7 @@ def find_and_replace(
# However, it seems that this functionality has been broken for a
# long time so for now we're just having mypy ignore and we'll come
# back to this.
if fill_value in self.categories: # type: ignore
if fill_value in self.categories: # type: ignore[operator]
replaced = self.fillna(fill_value)
else:
new_categories = self.categories.append(
Expand Down Expand Up @@ -703,7 +703,7 @@ def _concat(
elif newsize == 0:
codes_col = column.column_empty(0, head.codes.dtype)
else:
codes_col = column.concat_columns(codes) # type: ignore[arg-type]
codes_col = column.concat_columns(codes)

return codes_col._with_type_metadata(CategoricalDtype(categories=cats)) # type: ignore[return-value]

Expand Down
Loading
Loading