Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

fix issue 49 get/mget with empty series #50

Merged
merged 6 commits into from
Feb 19, 2020

Conversation

ashtul
Copy link
Contributor

@ashtul ashtul commented Feb 13, 2020

fix #49
Made the fix but it should probably be fixed at the module level as well.
Created PR RedisTimeSeries/RedisTimeSeries#346 which requires another change here

@ashtul ashtul requested a review from gkorland February 13, 2020 12:13
Copy link

@AlKorochkin AlKorochkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "is" is used for comparison?

def parse_m_get(response):
res = []
for item in response:
res.append({ nativestr(item[0]) : [list_to_dict(item[1]),
item[2][0], float(item[2][1])]})
if len(item[2]) is 2:
Copy link

@AlKorochkin AlKorochkin Feb 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are numerical values compared via the "is" operator and not through "=="?
In this case, it will give the correct result, but it seems to me that using "is" is conceptually wrong here.
If I'm not mistaken, then python keeps an array of integer objects for all integers between -5 and 256.
This may lead to an unexpected result if the numerical variable is not in the range of -5..256.

l1 = list(range(2))
l2 = list(range(257))

print(len(l1) == 2) #True
print(len(l1) is 2) #True

print(len(l2) == 257) #True
print(len(l2) is 257) #False

I do not have much experience with this, but it seems to me to use "==" to compare numerical values.

@codecov
Copy link

codecov bot commented Feb 16, 2020

Codecov Report

Merging #50 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #50   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          310       322   +12     
=========================================
+ Hits           310       322   +12     

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9a2246...0ce7c20. Read the comment docs.

@lgtm-com
Copy link

lgtm-com bot commented Feb 19, 2020

This pull request introduces 1 alert when merging 2e23dc8 into d9a2246 - view on LGTM.com

new alerts:

  • 1 for Testing equality to None

@@ -42,11 +42,19 @@ def parse_m_range(response):
parse_range(item[2])]})
return res

def parse_get(response):
if response[0] == None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashtul the LGTM bot complains about this because python linting rules prefer to use if response[0] is None.

@ashtul ashtul merged commit 73dfcc4 into master Feb 19, 2020
@ashtul ashtul deleted the fix-empty-response-of-get/mget branch February 19, 2020 11:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List index out of range in parse_m_get() for emty series.
3 participants