From 900cdf21bdad1259416854c9fddc4b58c774f2fa Mon Sep 17 00:00:00 2001 From: Matvey Kukuy Date: Wed, 20 Nov 2024 17:21:23 +0200 Subject: [PATCH] cleaning --- keep/api/background_server_jobs.py | 17 ++++++++--------- keep/api/config.py | 1 - keep/api/core/demo_mode.py | 2 +- keep/api/core/posthog.py | 1 - .../versions/2024-11-20-15-50_192157fd5788.py | 2 -- scripts/shoot_alerts_from_dump.py | 8 +++----- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/keep/api/background_server_jobs.py b/keep/api/background_server_jobs.py index 14ffd4f46..5787de43f 100644 --- a/keep/api/background_server_jobs.py +++ b/keep/api/background_server_jobs.py @@ -1,6 +1,12 @@ +import os import sys +import time +import requests -# It's a dirty hack to exclude current directory from sys.path +from keep.api.core.demo_mode import launch_demo_mode_thread +from keep.api.core.report_uptime import launch_uptime_reporting_thread + +# It's a hack to exclude current directory from sys.path # to avoid importing "logging.py" located in the same directory # instead of the standard library "logging" module. # TODO: rename logging.py @@ -9,14 +15,7 @@ sys.path.pop(i) break -import os -import time -import logging -import requests - -from keep.api.core.demo_mode import launch_demo_mode_thread -from keep.api.core.report_uptime import launch_uptime_reporting_thread - +import logging # noqa: E402 logger = logging.getLogger(__name__) diff --git a/keep/api/config.py b/keep/api/config.py index c6c502e22..54387cf86 100644 --- a/keep/api/config.py +++ b/keep/api/config.py @@ -4,7 +4,6 @@ import keep.api.logging from keep.api.api import AUTH_TYPE from keep.api.core.db_on_start import migrate_db, try_create_single_tenant -from keep.api.core.report_uptime import launch_uptime_reporting_thread from keep.api.core.dependencies import SINGLE_TENANT_UUID from keep.identitymanager.identitymanagerfactory import IdentityManagerTypes diff --git a/keep/api/core/demo_mode.py b/keep/api/core/demo_mode.py index 07e44ac3f..26ec63add 100644 --- a/keep/api/core/demo_mode.py +++ b/keep/api/core/demo_mode.py @@ -382,7 +382,7 @@ def simulate_alerts( try: env = random.choice(["production", "staging", "development"]) - if not "provider_id" in send_alert_url_params: + if "provider_id" not in send_alert_url_params: send_alert_url_params["provider_id"] = f"{provider_type}-{env}" prepared_request = PreparedRequest() diff --git a/keep/api/core/posthog.py b/keep/api/core/posthog.py index 3a6982e14..ec6d1e31b 100644 --- a/keep/api/core/posthog.py +++ b/keep/api/core/posthog.py @@ -1,5 +1,4 @@ import os -import uuid import posthog import requests from posthog import Posthog diff --git a/keep/api/models/db/migrations/versions/2024-11-20-15-50_192157fd5788.py b/keep/api/models/db/migrations/versions/2024-11-20-15-50_192157fd5788.py index 33e6cbad6..0d79398b8 100644 --- a/keep/api/models/db/migrations/versions/2024-11-20-15-50_192157fd5788.py +++ b/keep/api/models/db/migrations/versions/2024-11-20-15-50_192157fd5788.py @@ -7,10 +7,8 @@ """ import sqlalchemy as sa -import sqlalchemy_utils import sqlmodel from alembic import op -from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = "192157fd5788" diff --git a/scripts/shoot_alerts_from_dump.py b/scripts/shoot_alerts_from_dump.py index ebb18c327..7239c6fde 100644 --- a/scripts/shoot_alerts_from_dump.py +++ b/scripts/shoot_alerts_from_dump.py @@ -1,16 +1,14 @@ -import logging -import os import sys import json import copy import csv - +import logging +import argparse from keep.api.core.db import get_session_sync from keep.api.models.alert import AlertDto from keep.api.tasks.process_event_task import __handle_formatted_events -import sys -import argparse + # configure logging logging.basicConfig(