-
Notifications
You must be signed in to change notification settings - Fork 97
Adding __delitem__ to dict #215
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Codecov ReportBase: 74.35% // Head: 74.38% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #215 +/- ##
==========================================
+ Coverage 74.35% 74.38% +0.03%
==========================================
Files 76 76
Lines 12617 12625 +8
==========================================
+ Hits 9381 9391 +10
+ Misses 2563 2562 -1
+ Partials 673 672 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR.
I have 2 comments.
see below.
py/dict.go
Outdated
str, ok := key.(String) | ||
if ok { | ||
_, ok := d[string(str)] | ||
if ok { | ||
delete(d, string(str)) | ||
return None, nil | ||
} | ||
} | ||
return nil, ExceptionNewf(KeyError, "%v", key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str, ok := key.(String) | |
if ok { | |
_, ok := d[string(str)] | |
if ok { | |
delete(d, string(str)) | |
return None, nil | |
} | |
} | |
return nil, ExceptionNewf(KeyError, "%v", key) | |
str, ok := key.(String) | |
if !ok { | |
return nil, ExceptionNewf(KeyError, "%v", key) | |
} | |
_, ok = d[string(str)] | |
if !ok { | |
return nil, ExceptionNewf(KeyError, "%v", key) | |
} | |
delete(d, string(str)) | |
return None, nil |
yes, it's longer, but only in the vertical dimension (however, it's less indented)
del a["hello"] | ||
assert not a.__contains__('hello') | ||
assert a.__contains__('hi') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps add a couple of cases that exercize the 2 ExceptionNewf
branches ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
(thanks again)
Enables the 'del' command to delete items from a dict