Skip to content

Commit

Permalink
robustify extension class loading #821
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Sep 26, 2022
1 parent f6517d0 commit 2bc1323
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drf_spectacular/plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,14 @@ def _load_class(cls):
f'has an installed app but target class was not found.'
)
cls.target_class = None
except Exception as e: # pragma: no cover
installed_apps = apps.app_configs.keys()
if any(cls.target_class.startswith(app + '.') for app in installed_apps):
warn(
f'Unexpected error {e.__class__.__name__} occurred when attempting '
f'to import {cls.target_class} for extension {cls.__name__} ({e}).'
)
cls.target_class = None

@classmethod
def _matches(cls, target) -> bool:
Expand Down

0 comments on commit 2bc1323

Please sign in to comment.