Add type annotations to remove optimization warning