1515
1616import logging
1717import warnings
18- from typing import Any , Optional , Tuple
18+ from typing import Any , Optional
1919
2020from django .apps import apps
2121from django .conf import settings
@@ -72,7 +72,7 @@ def _user_lookup_attribute(self) -> str:
7272
7373 def _extract_user_identifier_params (
7474 self , session_info : dict , attributes : dict , attribute_mapping : dict
75- ) -> Tuple [str , Optional [Any ]]:
75+ ) -> tuple [str , Optional [Any ]]:
7676 """Returns the attribute to perform a user lookup on, and the value to use for it.
7777 The value could be the name_id, or any other saml attribute from the request.
7878 """
@@ -262,7 +262,7 @@ def get_or_create_user(
262262 attributes : dict ,
263263 attribute_mapping : dict ,
264264 request ,
265- ) -> Tuple [Optional [settings .AUTH_USER_MODEL ], bool ]:
265+ ) -> tuple [Optional [settings .AUTH_USER_MODEL ], bool ]:
266266 """Look up the user to authenticate. If he doesn't exist, this method creates him (if so desired).
267267 The default implementation looks only at the user_identifier. Override this method in order to do more complex behaviour,
268268 e.g. customize this per IdP.
@@ -322,27 +322,31 @@ def get_attribute_value(self, django_field, attributes, attribute_mapping):
322322 warnings .warn (
323323 "get_attribute_value() is deprecated, look at the Saml2Backend on how to subclass it" ,
324324 DeprecationWarning ,
325+ stacklevel = 2 ,
325326 )
326327 return self ._get_attribute_value (django_field , attributes , attribute_mapping )
327328
328329 def get_django_user_main_attribute (self ):
329330 warnings .warn (
330331 "get_django_user_main_attribute() is deprecated, look at the Saml2Backend on how to subclass it" ,
331332 DeprecationWarning ,
333+ stacklevel = 2 ,
332334 )
333335 return self ._user_lookup_attribute
334336
335337 def get_django_user_main_attribute_lookup (self ):
336338 warnings .warn (
337339 "get_django_user_main_attribute_lookup() is deprecated, look at the Saml2Backend on how to subclass it" ,
338340 DeprecationWarning ,
341+ stacklevel = 2 ,
339342 )
340343 return getattr (settings , "SAML_DJANGO_USER_MAIN_ATTRIBUTE_LOOKUP" , "" )
341344
342345 def get_user_query_args (self , main_attribute ):
343346 warnings .warn (
344347 "get_user_query_args() is deprecated, look at the Saml2Backend on how to subclass it" ,
345348 DeprecationWarning ,
349+ stacklevel = 2 ,
346350 )
347351 return {
348352 self .get_django_user_main_attribute ()
@@ -353,20 +357,23 @@ def configure_user(self, user, attributes, attribute_mapping):
353357 warnings .warn (
354358 "configure_user() is deprecated, look at the Saml2Backend on how to subclass it" ,
355359 DeprecationWarning ,
360+ stacklevel = 2 ,
356361 )
357362 return self ._update_user (user , attributes , attribute_mapping )
358363
359364 def update_user (self , user , attributes , attribute_mapping , force_save = False ):
360365 warnings .warn (
361366 "update_user() is deprecated, look at the Saml2Backend on how to subclass it" ,
362367 DeprecationWarning ,
368+ stacklevel = 2 ,
363369 )
364370 return self ._update_user (user , attributes , attribute_mapping )
365371
366372 def _set_attribute (self , obj , attr , value ):
367373 warnings .warn (
368374 "_set_attribute() is deprecated, look at the Saml2Backend on how to subclass it" ,
369375 DeprecationWarning ,
376+ stacklevel = 2 ,
370377 )
371378 return set_attribute (obj , attr , value )
372379
@@ -375,5 +382,6 @@ def get_saml_user_model():
375382 warnings .warn (
376383 "_set_attribute() is deprecated, look at the Saml2Backend on how to subclass it" ,
377384 DeprecationWarning ,
385+ stacklevel = 2 ,
378386 )
379387 return Saml2Backend ()._user_model
0 commit comments