Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: accessing an unset struct_pb2.Value field does not raise #140

Merged
merged 1 commit into from Oct 1, 2020
Merged

fix: accessing an unset struct_pb2.Value field does not raise #140

merged 1 commit into from Oct 1, 2020

Conversation

software-dov
Copy link
Contributor

@software-dov software-dov commented Oct 1, 2020

class Foo(proto.Message):
    value = proto.Field(struct_pb2.Value, number=1)

f = Foo()
assert f.value is None          # This should not raise an exception.
assert "value" not in f         # The attribute has _not_ been set.
f.value = None
assert f.value is None
assert "value" in f             # The attribute _has_ been set.

None of the above should raise an exception.

Closes #139

@software-dov software-dov requested review from a team as code owners October 1, 2020 20:18
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 1, 2020
class Foo(proto.Message):
    value = proto.Field(struct_pb2.Value, number=1)

f = Foo()
assert f.value is None          # This should not raise an exception.
assert "value" not in f         # The attribute has _not_ been set.
f.value = None
assert f.value is None
assert "value" in f             # The attribute _has_ been set.

None of the above should raise an exception.
@codecov
Copy link

codecov bot commented Oct 1, 2020

Codecov Report

Merging #140 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #140   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines          857       856    -1     
  Branches       149       148    -1     
=========================================
- Hits           857       856    -1     
Impacted Files Coverage Δ
proto/marshal/rules/struct.py 100.00% <100.00%> (ø)

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 6888d71...dfe264d. Read the comment docs.

@software-dov software-dov merged commit d045cbf into googleapis:master Oct 1, 2020
@software-dov software-dov deleted the null-struct-value branch October 1, 2020 21:54
@software-dov software-dov self-assigned this Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

struct.Value fields raise an AttributeError when empty
2 participants