Skip to content

Commit 2be9661

Browse files
fabincacarlotta
andauthored
STYLE fix: pylint "consider-using-in" warning (#49213)
* consider-using-in * consider-using-in * remove consider using in from pyproject.toml to add it to pylint * after running pre-commit chacks Co-authored-by: carlotta <c.fabian@turbit.de>
1 parent 1ceaee3 commit 2be9661

31 files changed

+50
-57
lines changed

pandas/core/computation/pytables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,15 @@ def stringify(value):
211211

212212
kind = ensure_decoded(self.kind)
213213
meta = ensure_decoded(self.meta)
214-
if kind == "datetime64" or kind == "datetime":
214+
if kind in ("datetime64", "datetime"):
215215
if isinstance(v, (int, float)):
216216
v = stringify(v)
217217
v = ensure_decoded(v)
218218
v = Timestamp(v)
219219
if v.tz is not None:
220220
v = v.tz_convert("UTC")
221221
return TermValue(v, v.value, kind)
222-
elif kind == "timedelta64" or kind == "timedelta":
222+
elif kind in ("timedelta64", "timedelta"):
223223
if isinstance(v, str):
224224
v = Timedelta(v).value
225225
else:

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ def from_dict(
17541754
# error: Incompatible types in assignment (expression has type
17551755
# "List[Any]", variable has type "Dict[Any, Any]")
17561756
data = list(data.values()) # type: ignore[assignment]
1757-
elif orient == "columns" or orient == "tight":
1757+
elif orient in ("columns", "tight"):
17581758
if columns is not None:
17591759
raise ValueError(f"cannot use columns parameter with orient='{orient}'")
17601760
else: # pragma: no cover

pandas/core/indexes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4066,7 +4066,7 @@ def _check_indexing_method(
40664066
"method='nearest' not implemented yet "
40674067
"for MultiIndex; see GitHub issue 9365"
40684068
)
4069-
elif method == "pad" or method == "backfill":
4069+
elif method in ("pad", "backfill"):
40704070
if tolerance is not None:
40714071
raise NotImplementedError(
40724072
"tolerance not implemented yet for MultiIndex"

pandas/core/indexes/datetimelike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def _get_insert_freq(self, loc: int, item):
663663
if self.size:
664664
if item is NaT:
665665
pass
666-
elif (loc == 0 or loc == -len(self)) and item + self.freq == self[0]:
666+
elif loc in (0, -len(self)) and item + self.freq == self[0]:
667667
freq = self.freq
668668
elif (loc == len(self)) and item - self.freq == self[-1]:
669669
freq = self.freq

pandas/core/indexes/range.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,11 @@ def delete(self, loc) -> Index: # type: ignore[override]
833833
# In some cases we can retain RangeIndex, see also
834834
# DatetimeTimedeltaMixin._get_delete_Freq
835835
if is_integer(loc):
836-
if loc == 0 or loc == -len(self):
836+
if loc in (0, -len(self)):
837837
return self[1:]
838-
if loc == -1 or loc == len(self) - 1:
838+
if loc in (-1, len(self) - 1):
839839
return self[:-1]
840-
if len(self) == 3 and (loc == 1 or loc == -2):
840+
if len(self) == 3 and loc in (1, -2):
841841
return self[::2]
842842

843843
elif lib.is_list_like(loc):

pandas/core/nanops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def _bn_ok_dtype(dtype: DtypeObj, name: str) -> bool:
183183

184184
def _has_infs(result) -> bool:
185185
if isinstance(result, np.ndarray):
186-
if result.dtype == "f8" or result.dtype == "f4":
186+
if result.dtype in ("f8", "f4"):
187187
# Note: outside of an nanops-specific test, we always have
188188
# result.ndim == 1, so there is no risk of this ravel making a copy.
189189
return lib.has_infs(result.ravel("K"))

pandas/core/ops/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def _maybe_align_series_as_frame(frame: DataFrame, series: Series, axis: AxisInt
397397
rvalues = series._values
398398
if not isinstance(rvalues, np.ndarray):
399399
# TODO(EA2D): no need to special-case with 2D EAs
400-
if rvalues.dtype == "datetime64[ns]" or rvalues.dtype == "timedelta64[ns]":
400+
if rvalues.dtype in ("datetime64[ns]", "timedelta64[ns]"):
401401
# We can losslessly+cheaply cast to ndarray
402402
rvalues = np.asarray(rvalues)
403403
else:

pandas/io/formats/excel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def _border_style(self, style: str | None, width: str | None, color: str | None)
277277
# Return "none" will keep "border" in style dictionary
278278
return "none"
279279

280-
if style == "none" or style == "hidden":
280+
if style in ("none", "hidden"):
281281
return "none"
282282

283283
width_name = self._get_width_name(width)

pandas/io/formats/style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4210,7 +4210,7 @@ def css_calc(x, left: float, right: float, align: str, color: str | list | tuple
42104210
z, align = align(values), "zero"
42114211
elif isinstance(align, (float, int)):
42124212
z, align = float(align), "zero"
4213-
elif not (align == "left" or align == "right" or align == "zero"):
4213+
elif align not in ("left", "right", "zero"):
42144214
raise ValueError(
42154215
"`align` should be in {'left', 'right', 'mid', 'mean', 'zero'} or be a "
42164216
"value defining the center line or a callable that returns a float"

pandas/io/formats/style_render.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,14 +2228,14 @@ def _parse_latex_css_conversion(styles: CSSList) -> CSSList:
22282228
"""
22292229

22302230
def font_weight(value, arg):
2231-
if value == "bold" or value == "bolder":
2231+
if value in ("bold", "bolder"):
22322232
return "bfseries", f"{arg}"
22332233
return None
22342234

22352235
def font_style(value, arg):
22362236
if value == "italic":
22372237
return "itshape", f"{arg}"
2238-
elif value == "oblique":
2238+
if value == "oblique":
22392239
return "slshape", f"{arg}"
22402240
return None
22412241

0 commit comments

Comments
 (0)