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:
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
import paho.mqtt.client as mqtt
|
||||
@@ -8,7 +7,6 @@ import paho.mqtt.client as mqtt
|
||||
from frigate.comms.dispatcher import Communicator
|
||||
from frigate.config import FrigateConfig
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -177,10 +175,10 @@ class MqttClient(Communicator): # type: ignore[misc]
|
||||
f"{self.mqtt_config.topic_prefix}/restart", self.on_mqtt_command
|
||||
)
|
||||
|
||||
if not self.mqtt_config.tls_ca_certs is None:
|
||||
if self.mqtt_config.tls_ca_certs is not None:
|
||||
if (
|
||||
not self.mqtt_config.tls_client_cert is None
|
||||
and not self.mqtt_config.tls_client_key is None
|
||||
self.mqtt_config.tls_client_cert is not None
|
||||
and self.mqtt_config.tls_client_key is not None
|
||||
):
|
||||
self.client.tls_set(
|
||||
self.mqtt_config.tls_ca_certs,
|
||||
@@ -189,9 +187,9 @@ class MqttClient(Communicator): # type: ignore[misc]
|
||||
)
|
||||
else:
|
||||
self.client.tls_set(self.mqtt_config.tls_ca_certs)
|
||||
if not self.mqtt_config.tls_insecure is None:
|
||||
if self.mqtt_config.tls_insecure is not None:
|
||||
self.client.tls_insecure_set(self.mqtt_config.tls_insecure)
|
||||
if not self.mqtt_config.user is None:
|
||||
if self.mqtt_config.user is not None:
|
||||
self.client.username_pw_set(
|
||||
self.mqtt_config.user, password=self.mqtt_config.password
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user