I have the following method:
async def get_by_email(self, email: str) -> User | None:
"""Get a user by email."""
return await self.session.scalar(select(User).where(User.email == email))
And mypy gives the following error:
error: Returning Any from function declared to return "User | None" [no-any-return]
If i change it to this though:
async def get_by_email(self, email: str) -> User | None:
"""Get a user by email."""
result = await self.session.scalar(select(User).where(User.email == email))
return result
The error disappears. I cant seem to find any information about why this happens. Any help would be appreciated 