Skip to content

Commit 8983b55

Browse files
uzzellMarcoGorelli
andauthored
Enable Pylint warning consider-using-ternary (#51051)
* Enable the Pylint check "consider-using-ternary" * Reformat file * Fix error in ternary statement --------- Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent 780bec2 commit 8983b55

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

pandas/core/algorithms.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,10 @@ def is_valid_dtype_n_method(dtype: DtypeObj) -> bool:
11971197
nsmallest/nlargest methods
11981198
"""
11991199
return (
1200-
is_numeric_dtype(dtype) and not is_complex_dtype(dtype)
1201-
) or needs_i8_conversion(dtype)
1200+
not is_complex_dtype(dtype)
1201+
if is_numeric_dtype(dtype)
1202+
else needs_i8_conversion(dtype)
1203+
)
12021204

12031205

12041206
class SelectNSeries(SelectN):

pandas/io/stata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ def _read_new_header(self) -> None:
12211221
raise ValueError(_version_error.format(version=self.format_version))
12221222
self._set_encoding()
12231223
self.path_or_buf.read(21) # </release><byteorder>
1224-
self.byteorder = self.path_or_buf.read(3) == b"MSF" and ">" or "<"
1224+
self.byteorder = ">" if self.path_or_buf.read(3) == b"MSF" else "<"
12251225
self.path_or_buf.read(15) # </byteorder><K>
12261226
nvar_type = "H" if self.format_version <= 118 else "I"
12271227
nvar_size = 2 if self.format_version <= 118 else 4
@@ -1413,7 +1413,7 @@ def _read_old_header(self, first_char: bytes) -> None:
14131413
raise ValueError(_version_error.format(version=self.format_version))
14141414
self._set_encoding()
14151415
self.byteorder = (
1416-
struct.unpack("b", self.path_or_buf.read(1))[0] == 0x1 and ">" or "<"
1416+
">" if struct.unpack("b", self.path_or_buf.read(1))[0] == 0x1 else "<"
14171417
)
14181418
self.filetype = struct.unpack("b", self.path_or_buf.read(1))[0]
14191419
self.path_or_buf.read(1) # unused

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ disable = [
314314
"unnecessary-lambda-assignment",
315315

316316
# pylint type "R": refactor, for bad code smell
317-
"consider-using-ternary",
318317
"consider-using-with",
319318
"cyclic-import",
320319
"duplicate-code",

0 commit comments

Comments
 (0)