-
Notifications
You must be signed in to change notification settings - Fork 229
Lazy initialisation of default values can cause unexpected behaviour #347
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
Labels
bug
Something isn't working
Comments
cc: @Gobot1234 @nat-n @chris-chambers as this stems from the code introduced in #130 to handle recursive message types as far as I can tell. |
abn
added a commit
to abn/python-betterproto
that referenced
this issue
Mar 2, 2022
This change ensures that deprecation warnings are only raised when either a deprecated field is explicitly set or a deprecated message is initialised. Resolves: danielgtaylor#347
@Gobot1234 I have proposed a fixe for this at b1fd73d. However, will wait till #345 and #346 to be merged before creating the pull request as CI will fail without #345. |
abn
added a commit
to abn/python-betterproto
that referenced
this issue
Mar 3, 2022
This change ensures that deprecation warnings are only raised when either a deprecated field is explicitly set or a deprecated message is initialised. Resolves: danielgtaylor#347
abn
added a commit
to abn/python-betterproto
that referenced
this issue
Mar 3, 2022
This change ensures that deprecation warnings are only raised when either a deprecated field is explicitly set or a deprecated message is initialised. Resolves: danielgtaylor#347
Gobot1234
pushed a commit
that referenced
this issue
Mar 11, 2022
This change ensures that deprecation warnings are only raised when either a deprecated field is explicitly set or a deprecated message is initialised. Resolves: #347
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the following code genereated from the openconfig/gnmi proto files.
Field
value
is deprecated in favour ofval
. See relevant content from proto files.Due to the changes introduced in #130, specifically in
Message.__getattribute__
, when the deprecation logic checks value (Update.value
), this value gets set via this logic.python-betterproto/src/betterproto/__init__.py
Lines 684 to 695 in 74205e3
The side-effects of this are the following:
Update.value
is not raised.Value()
is initialised. This raises a deprecation warning for the message itself. This happens in cases where this is not set explicitly.Update.value
andUpdate.val
, we could end up with unexpected behaviour as the values contained in these might differ as one is default and the other is not.Expected Behaviour
None
.The text was updated successfully, but these errors were encountered: