Update helpers.py

Fixes the error

    UnboundLocalError: local variable 'attr' referenced before assignment

which happens when using SQLAlchemy's `hybrid_property`, for example.