Fix Python PEP8 linting fails with AttributeError

Fixes #512