It looks like you're new here. If you want to get involved, click one of these buttons!
I may be mistaken, but is_cell_inst() seems excessive for me. In case when this condition is true, shape and layer attributes should just return None instead of assert in C++ code and this should be enough to filter shapes for further processing.
you're right - this is owed to the specifics of script mapping of the C++ API. This is a nice suggestion. If have created a ticket for this: https://github.com/KLayout/klayout/issues/521