Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
odelcroi committed Dec 9, 2024
1 parent 332cc85 commit 6bf4a00
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions synapse_sso_proconnect/proconnect_mapping.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import string

import attr
from authlib.oidc.core import UserInfo # type: ignore
from authlib.oidc.core import UserInfo # type: ignore
from typing import Any, Dict, List

from synapse.handlers.oidc import OidcMappingProvider, Token, UserAttributeDict
Expand All @@ -15,12 +15,12 @@

@attr.s(slots=True, frozen=True, auto_attribs=True)
class ProConnectMappingConfig:
user_id_lookup_fallback_rules:List[Dict[str, str]]= []
user_id_lookup_fallback_rules: List[Dict[str, str]]= []

class ProConnectMappingProvider(OidcMappingProvider[ProConnectMappingConfig]):
def __init__(self, config: ProConnectMappingConfig, module_api: ModuleApi):
self.module_api = module_api
self._config=config
self._config = config

@staticmethod
def parse_config(config: Dict[str, Any]) -> ProConnectMappingConfig:
Expand Down Expand Up @@ -48,7 +48,9 @@ async def map_user_attributes(
if not await self.module_api._password_auth_provider.is_3pid_allowed(
"email", userinfo.email, True
):
raise MappingException("Votre administration n'est pas encore présente sur Tchap, inscrivez-la sur https://tchap.beta.gouv.fr/")
raise MappingException(
"Votre administration n'est pas encore présente sur Tchap, inscrivez-la sur https://tchap.beta.gouv.fr/"
)

# filter out invalid characters
filtered = filter(
Expand Down Expand Up @@ -81,8 +83,7 @@ async def map_user_attributes(
)

# Search user ID by its email, retrying with replacements if necessary.
async def search_user_id_by_threepid(self, email: str
)-> str | None:
async def search_user_id_by_threepid(self, email: str)-> str | None:
# Try to find the user ID using the provided email
userId = await self.module_api._store.get_user_id_by_threepid("email", email)

Expand All @@ -98,7 +99,9 @@ async def search_user_id_by_threepid(self, email: str

# Retry lookup if the email was modified
if replaced_email != email:
userId = await self.module_api._store.get_user_id_by_threepid("email", replaced_email)
userId = await self.module_api._store.get_user_id_by_threepid(
"email", replaced_email
)

# Stop if a userId is found
if userId:
Expand Down

0 comments on commit 6bf4a00

Please sign in to comment.