Closed kan-fu closed 5 months ago
One thing that bothers me is that all the public methods in ONC class can modify the filter parameter in place. For example
params = {"deviceCode": "BPR-Folger-59",}
onc.getLocations(params)
print(params)
params
will have "token" and "method" as the new key. Most of time it should not cause any issues, but in getSensorCategoryCodes (a wrapper of the scalardata service with an extra "returnOptions": "excludeScalarData" in the query parameter), the expected usage is to run it before running the scalardata service, so
params = {
"deviceCode": "BPR-Folger-59",
"dateFrom": "2019-11-23T00:00:00.000Z",
"dateTo": "2019-11-23T00:01:00.000Z",
}
onc.getSensorCategoryCodes(params)
params = params | {'sensorCategoryCodes': 'warn_watcher'} # get it from the previous line
onc.getDirectByDevice(params)
will not work as expected. I force pushed a commit to fix it by using a copy of the input dict.
My question is, do users care about the immutability of this paramter? Is it worth the effort to make the filter
paramter of all the public methods immutable?
Fix #26