Uh oh!
There was an error while loading. Please reload this page.
feature: raise error for unknown properties in job config - #446
Conversation
| def __setattr__(self, name, value): | ||
| """Override to be able to warn if an uknown property is being set""" | ||
| if not name.startswith("_") and name not in type(self).__dict__: | ||
| warnings.warn("Property {} is unknown for {}.".format(name, type(self))) |
There was a problem hiding this comment.
On second thought, I think we can go a step further and throw AttributeError, just like object() instances do.
tswast
commented
Jan 8, 2021
|
tswast
commented
Jan 8, 2021
It appears you've uncovered a bug in the client. I don't see a setter for labels! |
tswast
commented
Jan 8, 2021
Nevermind, there is a setter: Perhaps this logic needs to be adjusted in order to account for properties defined in the superclass? |
| def __setattr__(self, name, value): | ||
| """Override to be able to raise error if an unknown property is being set""" | ||
| if not name.startswith("_") and name not in type(self).__dict__: |
There was a problem hiding this comment.
Let's try using hasattr to see if that accounts for superclass properties.
| ifnotname.startswith("_") andnamenotintype(self).__dict__: | |
| ifnotname.startswith("_") andnothasattr(self, name): |
There was a problem hiding this comment.
Ok, but we have to use type(self), because if not the properties are looked up on the instance.
tswast
commented
Jan 13, 2021
One of our system tests actually had a mistake, which this change caught. There is no "destination" property on LoadJobConfig https://googleapis.dev/python/bigquery/latest/generated/google.cloud.bigquery.job.LoadJobConfig.html |
Re: labels error - as discussed offline, it's actually a bug in the base |
As far as I can tell, this has never been a valid config value here. But prior to the merging of [this PR][1] in v2.7.0, invalid attributes were silently ignored. [1]: googleapis/python-bigquery#446
As far as I can tell, this has never been a valid config value here. But prior to the merging of [this PR][1] in v2.7.0, invalid attributes were silently ignored. [1]: googleapis/python-bigquery#446
As far as I can tell, this has never been a valid config value here. But prior to the merging of [this PR][1] in v2.7.0, invalid attributes were silently ignored. [1]: googleapis/python-bigquery#446
As far as I can tell, this has never been a valid config value here. But prior to the merging of [this PR][1] in v2.7.0, invalid attributes were silently ignored. [1]: googleapis/python-bigquery#446
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Simple feature to raise warning if unknown property is set on job_config instances.
Fixes#303 🦕