mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 00:55:07 +08:00
🎨 fix linter error
This commit is contained in:
parent
da16bdbb96
commit
8e915f808b
@ -195,8 +195,9 @@ class Driver(ReverseDriver):
|
||||
self, http_request)
|
||||
|
||||
if not x_self_id:
|
||||
raise HTTPException(response and response.status or 401,
|
||||
response.body)
|
||||
raise HTTPException(
|
||||
response and response.status or 401, response and
|
||||
response.body and response.body.decode("utf-8"))
|
||||
|
||||
if x_self_id in self._clients:
|
||||
logger.warning("There's already a reverse websocket connection,"
|
||||
|
@ -48,11 +48,11 @@ class Filter:
|
||||
self.level: Union[int, str] = "DEBUG"
|
||||
|
||||
def __call__(self, record):
|
||||
module = sys.modules.get(record["name"])
|
||||
module_name: str = record["name"]
|
||||
module = sys.modules.get(module_name)
|
||||
if module:
|
||||
module_name = getattr(module, "__module_name__", record["name"])
|
||||
record["name"] = module_name
|
||||
record["name"] = record["name"].split(".")[0]
|
||||
module_name = getattr(module, "__module_name__", module_name)
|
||||
record["name"] = module_name.split(".")[0]
|
||||
levelno = logger.level(self.level).no if isinstance(self.level,
|
||||
str) else self.level
|
||||
return record["level"].no >= levelno
|
||||
@ -67,7 +67,7 @@ class LoguruHandler(logging.Handler):
|
||||
level = record.levelno
|
||||
|
||||
frame, depth = logging.currentframe(), 2
|
||||
while frame.f_code.co_filename == logging.__file__:
|
||||
while frame and frame.f_code.co_filename == logging.__file__:
|
||||
frame = frame.f_back
|
||||
depth += 1
|
||||
|
||||
|
@ -141,8 +141,8 @@ def USER(*user: str, perm: Optional[Permission] = None):
|
||||
"""
|
||||
|
||||
async def _user(bot: "Bot", event: "Event") -> bool:
|
||||
return event.get_session_id() in user and bool(perm) and await perm(
|
||||
bot, event)
|
||||
return bool(event.get_session_id() in user and perm and
|
||||
await perm(bot, event))
|
||||
|
||||
return Permission(_user)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user