Rearrange code to remove an analyser warning.

The block for adding attributes was only run under one condition. Is it
worth declaring it as a block?
Merge pull request #3 from Abizern/removeAnalyserWarning

Rearrange code to remove an analyser warning.