Skip to content

Conversation

@kellrott
Copy link
Contributor

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

@codecov
Copy link

codecovbot commented Jan 12, 2023

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 FilesCoverage Δ
py/dict.go79.50% <100.00%> (+1.43%)⬆️
vm/eval.go79.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.

Copy link
Member

@sbinetsbinet left a 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
Comment on lines 193 to 201
str, ok:=key.(String)
ifok{
_, ok:=d[string(str)]
ifok{
delete(d, string(str))
returnNone, nil
}
}
returnnil, ExceptionNewf(KeyError, "%v", key)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
str, ok:=key.(String)
ifok{
_, ok:=d[string(str)]
ifok{
delete(d, string(str))
returnNone, nil
}
}
returnnil, ExceptionNewf(KeyError, "%v", key)
str, ok:=key.(String)
if!ok{
returnnil, ExceptionNewf(KeyError, "%v", key)
}
_, ok=d[string(str)]
if!ok{
returnnil, ExceptionNewf(KeyError, "%v", key)
}
delete(d, string(str))
returnNone, nil

yes, it's longer, but only in the vertical dimension (however, it's less indented)

dela["hello"]
assertnota.__contains__('hello')
asserta.__contains__('hi')

Copy link
Member

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 ?

Copy link
Member

@sbinetsbinet left a comment

Choose a reason for hiding this comment

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

LGTM

(thanks again)

@sbinetsbinet merged commit 0cc4032 into go-python:mainJan 14, 2023
Sign up for freeto 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

@kellrott@sbinet