aws / aws-step-functions-data-science-sdk-python

Step Functions Data Science SDK for building machine learning (ML) workflows and pipelines on AWS
Apache License 2.0
285 stars 87 forks source link

chore: fix incorrect comparison operators #195

Open wimlewis-amazon opened 1 year ago

wimlewis-amazon commented 1 year ago

Description

Changes comparisons to use identity-comparison (is) for the singleton None, and value-comparison (==) for strings.

Why is the change necessary?

Python strings do not guarantee object identity for equal strings, so comparing self.type against a string using is might not have the intended effect. (In practice, since both values are short constant string literals from the same source file, it'll work … but it's bad practice, and generates both runtime warnings and linter warnings.)

Using is not None instead of != None is less important, but it's accepted Python style to use is/is not for the None singleton, and linters throw warnings on this as well.

Solution

How was this change tested?

tox tests/unit has the same number of failures after this change as before.


Pull Request Checklist

Please check all boxes (including N/A items)

Testing

Title and description


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.