forked from Github/frigate
Add isort and ruff linter (#6575)
* Add isort and ruff linter Both linters are pretty common among modern python code bases. The isort tool provides stable sorting and grouping, as well as pruning of unused imports. Ruff is a modern linter, that is very fast due to being written in rust. It can detect many common issues in a python codebase. Removes the pylint dev requirement, since ruff replaces it. * treewide: fix issues detected by ruff * treewide: fix bare except clauses * .devcontainer: Set up isort * treewide: optimize imports * treewide: apply black * treewide: make regex patterns raw strings This is necessary for escape sequences to be properly recognized.
This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from typing import Callable
|
||||
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
from ws4py.server.wsgirefserver import (
|
||||
WebSocketWSGIHandler,
|
||||
WebSocketWSGIRequestHandler,
|
||||
@@ -18,7 +17,6 @@ from ws4py.websocket import WebSocket
|
||||
from frigate.comms.dispatcher import Communicator
|
||||
from frigate.config import FrigateConfig
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -45,7 +43,7 @@ class WebSocketClient(Communicator): # type: ignore[misc]
|
||||
"topic": json_message.get("topic"),
|
||||
"payload": json_message.get("payload"),
|
||||
}
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
logger.warning(
|
||||
f"Unable to parse websocket message as valid json: {message.data.decode('utf-8')}"
|
||||
)
|
||||
@@ -82,7 +80,7 @@ class WebSocketClient(Communicator): # type: ignore[misc]
|
||||
"payload": payload,
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
# if the payload can't be decoded don't relay to clients
|
||||
logger.debug(f"payload for {topic} wasn't text. Skipping...")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user