Use double-underscore versions of func_* attributes throughout.
Update annotations for Python 3.