FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Adding __delitem__ to dict by kellrott · Pull Request #215 · go-python/gpython · GitHub

Adding __delitem__ to dict - #215

Merged
sbinet merged 2 commits into
go-python:mainfrom
bmeg:feature/dict-del
Jan 14, 2023
Merged

Adding __delitem__ to dict#215
sbinet merged 2 commits into
go-python:mainfrom
bmeg:feature/dict-del

Conversation

Copy link
Copy Markdown
Contributor

Enables the 'del' command to delete items from a dict

codecov Bot commented Jan 12, 2023
edited
Loading

Copy link
Copy Markdown

Codecov Report

Base: 74.35% // Head: 74.38% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (c89f95c) compared to base (c60d425).
Patch coverage: 100.00% of modified lines in pull request are covered.

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     
Impacted Files Coverage Δ
py/dict.go 79.50% <100.00%> (+1.43%) ⬆️
vm/eval.go 79.53% <0.00%> (+0.18%) ⬆️

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

sbinet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

thanks for the PR.

I have 2 comments.
see below.

Comment thread py/dict.go Outdated
Comment on lines +193 to +201
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
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)

Comment thread py/tests/dict.py
del a["hello"]
assert not a.__contains__('hello')
assert a.__contains__('hi')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

perhaps add a couple of cases that exercize the 2 ExceptionNewf branches ?

sbinet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

(thanks again)

sbinet merged commit 0cc4032 into go-python:main Jan 14, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL