-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Labels
P2A nice-to-fix bugA nice-to-fix bugtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
user_id field is deprecated but it still causes us problems. TransferConfig.to_dict creates a dictionary that has the wrong type of this field. This type of this field should be one of: int, long, but this field has type str. This is especially problematic because to_dict method set this field to default value - "0", so I need to convert this field to the correct type on my side.
It would be great if TransferConfig.to_dict returned the correct representation for this object
Environment details
- OS type and version:
- Python version:
Python 3.6.12 - pip version:
pip 20.2.4 google-cloud-bigquery-datatransferversion:google-cloud-bigquery-datatransfer==3.0.0
Steps to reproduce
- Run code example
Code example
from google.cloud.bigquery_datatransfer_v1.types import TransferConfig
a = TransferConfig(user_id=123)
b = TransferConfig.to_dict(a)
c = TransferConfig(**b)Workaround:
from google.cloud.bigquery_datatransfer_v1.types import TransferConfig
a = TransferConfig(user_id=123)
b = TransferConfig.to_dict(a)
# HACK: TransferConfig.to_dict returns invalid representation
b['user_id'] = int(b['user_id'])
c = TransferConfig(**b)Stack trace
Traceback (most recent call last):
File "/files/bigquery_dts.py", line 7, in <module>
c = TransferConfig(**b)
File "/usr/local/lib/python3.6/site-packages/proto/message.py", line 466, in __init__
self.__dict__["_pb"] = self._meta.pb(**params)
TypeError: '123' has type str, but expected one of: int, long
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
Metadata
Metadata
Assignees
Labels
P2A nice-to-fix bugA nice-to-fix bugtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.