I do a lot of coding in python and got a lot of if
conditions without an else
statement so to say partial branches.
E.g.:
# if a certain kwarg was passed to a function call
if kwargs.get('a_option'):
# overwrite an entry in an already existing dict:
config['a_option'] = kwargs['a_option']
This always shows up in my test coverage as a partial hit unless I mark it with a pragma: no branch
.
So my question is, is it considered bad practice to use partial branches? And if it is, are there any popular ways how to avoid them? (not something like "just add else without any statements like in python else: pass
")
Note that this is refering to branching in general and not only python. I just used that as example but I'm interested in general how such things are handled in no matter what language.