Skip to content

Commit

Permalink
feat: give helpful error when worker class doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
MHajoha committed Aug 22, 2024
1 parent 5365b15 commit 9361794
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion questionpy_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ class WorkerSettings(BaseModel):
@classmethod
def _load_worker_class(cls, value: object) -> builtins.type[Worker]:
if isinstance(value, str):
value = locate(value)
klass = locate(value)

if klass is None:
msg = f"Could not locate class '{value}'"
raise TypeError(msg)

value = klass

if not isinstance(value, type) or not issubclass(value, Worker):
msg = f"{value} is not a subclass of Worker"
Expand Down

0 comments on commit 9361794

Please sign in to comment.