Before 3.7, you cant refer to the self.class definition. You have to wrap the class name with single quotes.
class Policy(object):
def __enter__(self) -> 'Policy':
pass
This is fixed in python 3.7
from __future__ import annotations
class Policy(object):
def __enter__(self) -> Policy:
pass