Skip to content

Commit

Permalink
add stacklevel=2 in warning calls (flake8-bugbear's B028)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-as committed Dec 3, 2024
1 parent 8bf994e commit 7adabc9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions djangosaml2/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,31 @@ def get_attribute_value(self, django_field, attributes, attribute_mapping):
warnings.warn(
"get_attribute_value() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return self._get_attribute_value(django_field, attributes, attribute_mapping)

def get_django_user_main_attribute(self):
warnings.warn(
"get_django_user_main_attribute() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return self._user_lookup_attribute

def get_django_user_main_attribute_lookup(self):
warnings.warn(
"get_django_user_main_attribute_lookup() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return getattr(settings, "SAML_DJANGO_USER_MAIN_ATTRIBUTE_LOOKUP", "")

def get_user_query_args(self, main_attribute):
warnings.warn(
"get_user_query_args() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return {
self.get_django_user_main_attribute()
Expand All @@ -353,20 +357,23 @@ def configure_user(self, user, attributes, attribute_mapping):
warnings.warn(
"configure_user() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return self._update_user(user, attributes, attribute_mapping)

def update_user(self, user, attributes, attribute_mapping, force_save=False):
warnings.warn(
"update_user() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return self._update_user(user, attributes, attribute_mapping)

def _set_attribute(self, obj, attr, value):
warnings.warn(
"_set_attribute() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return set_attribute(obj, attr, value)

Expand All @@ -375,5 +382,6 @@ def get_saml_user_model():
warnings.warn(
"_set_attribute() is deprecated, look at the Saml2Backend on how to subclass it",
DeprecationWarning,
stacklevel=2,
)
return Saml2Backend()._user_model

0 comments on commit 7adabc9

Please sign in to comment.