refactor: clean up code by adding missing commas and improving import order
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import os
|
||||
from typing import Dict, Optional
|
||||
|
||||
from authlib.integrations.flask_client import OAuth
|
||||
|
||||
from .base import OAuthProvider
|
||||
from .google import GoogleOAuthProvider
|
||||
from .github import GitHubOAuthProvider
|
||||
from .google import GoogleOAuthProvider
|
||||
|
||||
|
||||
class OAuthProviderRegistry:
|
||||
@@ -11,7 +12,7 @@ class OAuthProviderRegistry:
|
||||
|
||||
def __init__(self, oauth: OAuth):
|
||||
self.oauth = oauth
|
||||
self._providers: Dict[str, OAuthProvider] = {}
|
||||
self._providers: dict[str, OAuthProvider] = {}
|
||||
self._initialize_providers()
|
||||
|
||||
def _initialize_providers(self):
|
||||
@@ -21,7 +22,7 @@ class OAuthProviderRegistry:
|
||||
google_client_secret = os.getenv("GOOGLE_CLIENT_SECRET")
|
||||
if google_client_id and google_client_secret:
|
||||
self._providers["google"] = GoogleOAuthProvider(
|
||||
self.oauth, google_client_id, google_client_secret
|
||||
self.oauth, google_client_id, google_client_secret,
|
||||
)
|
||||
|
||||
# GitHub OAuth
|
||||
@@ -29,14 +30,14 @@ class OAuthProviderRegistry:
|
||||
github_client_secret = os.getenv("GITHUB_CLIENT_SECRET")
|
||||
if github_client_id and github_client_secret:
|
||||
self._providers["github"] = GitHubOAuthProvider(
|
||||
self.oauth, github_client_id, github_client_secret
|
||||
self.oauth, github_client_id, github_client_secret,
|
||||
)
|
||||
|
||||
def get_provider(self, name: str) -> Optional[OAuthProvider]:
|
||||
def get_provider(self, name: str) -> OAuthProvider | None:
|
||||
"""Get OAuth provider by name."""
|
||||
return self._providers.get(name)
|
||||
|
||||
def get_available_providers(self) -> Dict[str, OAuthProvider]:
|
||||
def get_available_providers(self) -> dict[str, OAuthProvider]:
|
||||
"""Get all available providers."""
|
||||
return self._providers.copy()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user