Improve NotConfigured handling when clspath is a class.

This commit is contained in:
Andrey Rakhmatullin 2023-08-01 20:20:15 +04:00
parent f803ad63f3
commit e58b8078f0
3 changed files with 5 additions and 9 deletions

View File

@ -40,12 +40,9 @@ class AddonManager:
self.addons.append(addon)
except NotConfigured as e:
if e.args:
clsname = (
clspath.split(".")[-1] if isinstance(clspath, str) else clspath
)
logger.warning(
"Disabled %(clsname)s: %(eargs)s",
{"clsname": clsname, "eargs": e.args[0]},
"Disabled %(clspath)s: %(eargs)s",
{"clspath": clspath, "eargs": e.args[0]},
extra={"crawler": self.crawler},
)
logger.info(

View File

@ -46,10 +46,9 @@ class MiddlewareManager:
enabled.append(clspath)
except NotConfigured as e:
if e.args:
clsname = clspath.split(".")[-1]
logger.warning(
"Disabled %(clsname)s: %(eargs)s",
{"clsname": clsname, "eargs": e.args[0]},
"Disabled %(clspath)s: %(eargs)s",
{"clspath": clspath, "eargs": e.args[0]},
extra={"crawler": crawler},
)

View File

@ -39,7 +39,7 @@ class MOff:
pass
def __init__(self):
raise NotConfigured
raise NotConfigured("foo")
class TestMiddlewareManager(MiddlewareManager):