Skip to content

Commit 13cf782

Browse files
committed
Use != instead of is not for values.
This uses the `==`/`!=` operators instead of `is`/`is not` when checking the return value of RPC calls. In Python, `is not` tests if the two operands are the same object whereas `!=` test that they have the same value. `is not` just happens to work for small inters due to an implementation detail in CPython (e.g. see [StackOverflow]). StackOverflow: https://stackoverflow.com/a/133024/1976323
1 parent ded17f0 commit 13cf782

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

other/templates/py/call.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ async def {{ name.lower_snake_case }}(self{% for param in params %}, {{ param.na
4848
{% if has_result %}
4949
result = self._extract_result(response)
5050

51-
if result.result is not {{ plugin_name.upper_camel_case }}Result.Result.SUCCESS:
51+
if result.result != {{ plugin_name.upper_camel_case }}Result.Result.SUCCESS:
5252
raise {{ plugin_name.upper_camel_case }}Error(result, "{{ name.lower_snake_case }}()"{% for param in params %}, {{ param.name.lower_snake_case }}{% endfor %})
5353
{% endif %}

other/templates/py/request.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def {{ name.lower_snake_case }}(self{% for param in params %}, {{ param.na
5252
{% if has_result %}
5353
result = self._extract_result(response)
5454

55-
if result.result is not {{ plugin_name.upper_camel_case }}Result.Result.SUCCESS:
55+
if result.result != {{ plugin_name.upper_camel_case }}Result.Result.SUCCESS:
5656
raise {{ plugin_name.upper_camel_case }}Error(result, "{{ name.lower_snake_case }}()"{% for param in params %}, {{ param.name.lower_snake_case }}{% endfor %})
5757
{% endif %}
5858

other/templates/py/stream.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async def {{ name.lower_snake_case }}(self{% for param in params %}, {{ param.na
6161
if result.result not in success_codes:
6262
raise {{ plugin_name.upper_camel_case }}Error(result, "{{ name.lower_snake_case }}()"{% for param in params %}, {{ param.name.lower_snake_case }}{% endfor %})
6363

64-
if result.result is {{ plugin_name.upper_camel_case }}Result.Result.SUCCESS:
64+
if result.result == {{ plugin_name.upper_camel_case }}Result.Result.SUCCESS:
6565
{{ name.lower_snake_case }}_stream.cancel();
6666
return
6767
{% endif %}

0 commit comments

Comments
 (0)