Skip to content

Commit d039e37

Browse files
authored
change: enable consider-using-ternary Pylint check (#942)
This commit will add an exclusion for all auto-generated files. I chose to ignore the single violation, because the alternative is confusingly convoluted: `(hasattr(obj, '__getitem__') if hasattr(obj, '__iter__') else isinstance(obj, str))`
1 parent 36bbf8a commit d039e37

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.pylintrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ profile=no
1919
# paths.
2020
ignore=CVS,tensorflow_serving
2121

22-
# Add files or directories matching the regex patterns to the blacklist. The
23-
# regex matches against base names, not paths.
22+
# Add files or directories matching the regex patterns to the blacklist.
23+
# The regex matches against base names, not paths.
24+
# Regex patterns can be comma(and newline)-separated
2425
ignore-patterns=
26+
.*_pb2.py, # Ignore all files generated by the protocol buffer compiler
2527

2628
# Pickle collected data for later comparisons.
2729
persistent=yes
@@ -89,7 +91,6 @@ disable=
8991
useless-object-inheritance, # TODO: Remove unnecessary imports
9092
cyclic-import, # TODO: Resolve cyclic imports
9193
no-self-use, # TODO: Convert methods to functions where appropriate
92-
consider-using-ternary, # TODO: Consider ternary expressions
9394
too-many-branches, # TODO: Simplify or ignore as appropriate
9495
missing-docstring, # TODO: Fix missing docstring
9596

src/sagemaker/predictor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def _is_mutable_sequence_like(obj):
231231

232232
def _is_sequence_like(obj):
233233
# Need to explicitly check on str since str lacks the iterable magic methods in Python 2
234-
return (hasattr(obj, "__iter__") and hasattr(obj, "__getitem__")) or isinstance(obj, str)
234+
return ( # pylint: disable=consider-using-ternary
235+
hasattr(obj, "__iter__") and hasattr(obj, "__getitem__")
236+
) or isinstance(obj, str)
235237

236238

237239
def _row_to_csv(obj):

0 commit comments

Comments
 (0)