Open
Description
Add a py.typed file
Describe the chore
The library is missing a py.typed file. This adds friction when using it with a type checker like mypy as the type-checker will not recognise the types of the imported classes and methods.
Additional context
I'm using supabase_auth to implement authentication for my python app:
from fastapi import Depends, HTTPException, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from supabase_auth import User
from supabase_auth.errors import AuthApiError
from supabase_auth.types import UserResponse
from supabase import Client, create_client
from myproject.config import get_supabase_settings
def get_client() -> Client:
settings = get_supabase_settings()
client = create_client(
supabase_url=settings.supabase_url,
supabase_key=settings.supabase_service_role_key,
)
return client
async def get_current_user(
credentials: HTTPAuthorizationCredentials = Depends(HTTPBearer()),
) -> User:
token = credentials.credentials
client = get_client()
try:
user_response: UserResponse = client.auth.get_user(token)
return user_response.user
except AuthApiError as e:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=f"Invalid authentication credentials: {e}",
)
except Exception as e:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"An error occurred while authenticating: {e}",
)
When I run mypy with the following settings in my mypy.ini file:
[mypy]
disallow_untyped_defs = True
disallow_any_unimported = True
no_implicit_optional = True
check_untyped_defs = True
warn_return_any = True
warn_unused_ignores = True
show_error_codes = True
I get the following error:
mypy src/
src/myproject/auth.py:3: error: Skipping analyzing "supabase_auth": module is installed, but missing library stubs or py.typed marker [import-untyped]
src/myproject/auth.py:4: error: Skipping analyzing "supabase_auth.errors": module is installed, but missing library stubs or py.typed marker [import-untyped]
src/myproject/auth.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
src/myproject/auth.py:5: error: Skipping analyzing "supabase_auth.types": module is installed, but missing library stubs or py.typed marker [import-untyped]
src/myproject/auth.py:21: error: Return type becomes "Coroutine[Any, Any, Any]" due to an unfollowed import [no-any-unimported]
src/myproject/auth.py:27: error: Type of variable becomes "Any" due to an unfollowed import [no-any-unimported]
Found 5 errors in 1 file (checked 12 source files)
I'm trying to work around this by autogenerating the types for mypy with stubgen, but that seems to fail as well.