arvindshmicrosoft commented on issue #319: Correctly handle @default decorator 
for boolean
URL: https://github.com/apache/fluo-muchos/pull/319#issuecomment-581681219
 
 
   More details: 
   The current code was found to return a default value for use_adlsg2 even if 
that was a valid (boolean) setting I tracked the issue down this expression:
   
   ``` 
                    if res in [None, 0, ''] or isinstance(res, str) and 
len(res) == 0:
                        return val
                    return res
   ```
    
   What the above code is _intended_ to do is detect an empty or a missing 
value for a setting (identified by 'res'), and in that case return the default 
value (identified by 'val'). Unfortunately, the expression is flawed because it 
does not correctly handle the case when res is boolean, and specifically if it 
is set to the Python intrinsic False. In that case, the above condition returns 
True and ends up therefore returning the default (val). I believe the 
simplification in the PR is accurate and complete.
   
   Also to preempt a likely question, the original condition has a flawed check 
for res being 0 - which might be a valid config value and hence should not be 
treated as missing data. Functionally, from a Muchos p.o.v. it is a valid case 
to have 0 as a value (for example num_disks could be 0).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to