Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.8+ complains about using "is" with literals in api_helper.py #80

Open
rspellman opened this issue Nov 3, 2023 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@rspellman
Copy link

rspellman commented Nov 3, 2023

🐛 Bug Report

I'm running Python 3.9.6 on OSX. I have installed the managemeht-sdk-python module from cohesity github according to the instructions. When running any of the samples, Python complains with a warming for all uses of the syntax 'if variable is "something"' where "something" is a string literal or number.

One solution is to find all instances in api_helper.py and replace "is" with "==". Here's output from a git diff with the changes:

--- a/cohesity_management_sdk/api_helper.py
+++ b/cohesity_management_sdk/api_helper.py
@@ -119,11 +119,11 @@ class APIHelper(object):
             serializable_types = (str, int, float, bool, datetime.date, APIHelper.CustomDate)

         if isinstance(array[0], serializable_types):
-            if formatting is "unindexed":
+            if formatting == "unindexed":
                 tuples += [("{0}[]".format(key), element) for element in array]
-            elif formatting is "indexed":
+            elif formatting == "indexed":
                 tuples += [("{0}[{1}]".format(key, index), element) for index, element in enumerate(array)]
-            elif formatting is "plain":
+            elif formatting == "plain":
                 tuples += [(key, element) for element in array]
             else:
                 raise ValueError("Invalid format provided.")
@@ -193,13 +193,13 @@ class APIHelper(object):
             if value is not None:
                 if isinstance(value, list):
                     value = [element for element in value if element]
-                    if array_serialization is "csv":
+                    if array_serialization == "csv":
                         url += "{0}{1}={2}".format(seperator, key,
                             ",".join(quote(str(x), safe='') for x in value))
-                    elif array_serialization is "psv":
+                    elif array_serialization == "psv":
                         url += "{0}{1}={2}".format(seperator, key,
                             "|".join(quote(str(x), safe='') for x in value))
-                    elif array_serialization is "tsv":
+                    elif array_serialization == "tsv":
                         url += "{0}{1}={2}".format(seperator, key,
                             "\t".join(quote(str(x), safe='') for x in value))
                     else:
@rspellman rspellman changed the title Python 3.8+ complaints about using "is" with literals in api_helper.py Python 3.8+ complains about using "is" with literals in api_helper.py Nov 3, 2023
@NikithaTJ-Cohesity NikithaTJ-Cohesity added the bug Something isn't working label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants