Fix false positive E711/E712; issue #336

Fixes #336 and review/refactor the patch for #347