Skip to content

Commit 7adabc9

Browse files
committed
add stacklevel=2 in warning calls (flake8-bugbear's B028)
1 parent 8bf994e commit 7adabc9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

djangosaml2/backends.py

+8
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)