TypeError exception in path_or()
SergeKu opened this issue · 1 comments
ramda version 0.6.0
When I try to work with none field value in source object I get such exception:
TypeError: 'NoneType' object is not subscriptable
Example source:
import ramda as R
conc={'_id': '605c5122de4f9070960f2b0e', 'deviceIndex': 0, 'concentrator': {'type': 'MK-01', 'number': '48376021016855'}, 'commissioningData': None}
print (R.path_or([], ['commissioningData', 'channelsField'], conc))
Output is
Traceback (most recent call last):
File "/home/kss/tmp/py/ramda_test.py", line 9, in
print (R.path_or([], ['commissioningData', 'channelsField'], conc))
File "/usr/lib/python3.9/site-packages/toolz/functoolz.py", line 303, in call
return self._partial(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/ramda/path_or.py", line 11, in path_or
return default_to(default, _path(path, value))
File "/usr/lib/python3.9/site-packages/toolz/functoolz.py", line 303, in call
return self._partial(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/ramda/path.py", line 11, in path
current_value = current_value[key]
TypeError: 'NoneType' object is not subscriptable
In JavaScript Ramda all works well
const R=require('ramda')
let conc={'_id': '605c5122de4f9070960f2b0e', 'deviceIndex': 0, 'concentrator': {'type': 'MK-01', 'number': '48376021016855'}, 'commissioningData': null}
console.log (R.pathOr([], ['commissioningData', 'channelsField'], conc))
Output is []
As far as I can see, this issue closed by https://github.com/slavaGanzin/ramda.py/commit/982b2172f4bb95b9a5b09eff8077362d6f2f0920.
Only the problem is in pip.