From eade3e7e559edb55b7144cde4371e180daa5de14 Mon Sep 17 00:00:00 2001 From: Karim Nakad Date: Wed, 3 Jul 2019 13:27:43 -0700 Subject: [PATCH] change: correct code per len-as-condition Pylint check The Pylint check is not actually enabled in this commit as it conflicts directly with NumPy. Pylint has corrected this, and it will be included in their next release (2.4.0): https://github.com/PyCQA/pylint/issues/2684 Once Pylint 2.4.0 is released, we can consume it and remove this check. A summary of this information is included in a TODO near the relevant Pylint disable rule (len-as-condition). --- .pylintrc | 2 +- src/sagemaker/predictor.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 5699045bec..c836b5269e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -82,7 +82,7 @@ disable= invalid-name, too-many-instance-attributes, line-too-long, # We let Flake8 take care of this # TODO: Fix these and stop relying on flake8 - len-as-condition, # TODO: Use if seq: and if not seq: instead + len-as-condition, # TODO: Enable this check once pylint 2.4.0 is released and consumed due to the fix in https://github.com/PyCQA/pylint/issues/2684 logging-format-interpolation, # TODO: Fix logging so as to remove this. import-error, # TODO: Fix import errors logging-not-lazy, # TODO: Fix logging diff --git a/src/sagemaker/predictor.py b/src/sagemaker/predictor.py index 9b4f777178..e7d43e1925 100644 --- a/src/sagemaker/predictor.py +++ b/src/sagemaker/predictor.py @@ -195,7 +195,7 @@ def _serialize_row(data): if isinstance(data, np.ndarray): data = np.ndarray.flatten(data) if hasattr(data, "__len__"): - if len(data): + if len(data) > 0: return _csv_serialize_python_array(data) else: raise ValueError("Cannot serialize empty array")