Boy scout rule

This is branched from https://github.com/pyinvoke/invoke/pull/197, so please take a look at that one first.

This PR just removes some unused imports and makes a conditional more pythonic.