fix getattr useage

This commit is contained in:
Matthias Mair 2024-01-07 19:46:35 +01:00
parent cb80c73bc6
commit a2e54a760e
No known key found for this signature in database
GPG Key ID: A593429DDA23B66A
3 changed files with 4 additions and 4 deletions

View File

@ -336,9 +336,9 @@ def trigger_notification(obj, category=None, obj_ref='pk', **kwargs):
# Try with some defaults
if not obj_ref_value:
obj_ref_value = getattr(obj, 'pk')
obj_ref_value = getattr(obj, 'pk', None)
if not obj_ref_value:
obj_ref_value = getattr(obj, 'id')
obj_ref_value = getattr(obj, 'id', None)
if not obj_ref_value:
raise KeyError(f"Could not resolve an object reference for '{str(obj)}' with {obj_ref}, pk, id")

View File

@ -93,7 +93,7 @@ class APICallMixin:
Check the mixin class docstring for a full example.
"""
headers = {'Content-Type': 'application/json'}
if getattr(self, 'API_TOKEN_SETTING'):
if getattr(self, 'API_TOKEN_SETTING', None):
token = self.get_setting(self.API_TOKEN_SETTING)
if token:

View File

@ -189,7 +189,7 @@ class PluginSetting(common.models.BaseInvenTreeSetting):
plugin = kwargs.pop('plugin', None)
if plugin:
mixin_settings = getattr(registry, 'mixins_settings')
mixin_settings = getattr(registry, 'mixins_settings', None)
if mixin_settings:
kwargs['settings'] = mixin_settings.get(plugin.key, {})