From cc4fe49aa0462358d0a8ba47faaba0fcceff3581 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Date: Fri, 8 Mar 2024 22:09:32 +0000 Subject: [PATCH] chore(refactor): Sort imports --- app/config.py | 12 +++++++----- app/deleterr.py | 11 ++++++----- app/logger.py | 2 +- app/media_cleaner.py | 11 ++++++----- app/modules/tautulli.py | 4 +++- app/modules/trakt.py | 4 +++- tests/test_config.py | 3 ++- tests/test_config_files.py | 5 +++-- tests/test_deleterr.py | 3 ++- tests/test_logger.py | 3 ++- tests/test_media_cleaner.py | 14 ++++++++------ tests/test_sort_media.py | 1 + tests/test_tautulli.py | 6 ++++-- tests/test_utils.py | 3 ++- tox.ini | 2 +- 15 files changed, 51 insertions(+), 33 deletions(-) diff --git a/app/config.py b/app/config.py index 168be21..af1e40e 100644 --- a/app/config.py +++ b/app/config.py @@ -1,13 +1,15 @@ # encoding: utf-8 -import yaml -from app import logger -import sys import os +import sys + import requests -from app.modules.trakt import Trakt +import yaml + +from app import logger +from app.constants import VALID_ACTION_MODES, VALID_SORT_FIELDS, VALID_SORT_ORDERS from app.modules.tautulli import Tautulli -from app.constants import VALID_SORT_FIELDS, VALID_SORT_ORDERS, VALID_ACTION_MODES +from app.modules.trakt import Trakt from app.utils import validate_units diff --git a/app/deleterr.py b/app/deleterr.py index 0074c1a..9c0935c 100644 --- a/app/deleterr.py +++ b/app/deleterr.py @@ -1,16 +1,17 @@ # encoding: utf-8 +import argparse import locale import os -import argparse -from pyarr.sonarr import SonarrAPI +from pyarr.exceptions import PyarrResourceNotFound, PyarrServerError from pyarr.radarr import RadarrAPI +from pyarr.sonarr import SonarrAPI + from app import logger -from app.utils import print_readable_freed_space -from app.media_cleaner import MediaCleaner from app.config import load_config -from pyarr.exceptions import PyarrResourceNotFound, PyarrServerError +from app.media_cleaner import MediaCleaner +from app.utils import print_readable_freed_space class Deleterr: diff --git a/app/logger.py b/app/logger.py index 2129d0f..5b91200 100644 --- a/app/logger.py +++ b/app/logger.py @@ -1,7 +1,7 @@ -from logging import handlers import logging import os import sys +from logging import handlers # These settings are for file logging only FILENAME = "deleterr.log" diff --git a/app/media_cleaner.py b/app/media_cleaner.py index c7fd486..8bca2ca 100644 --- a/app/media_cleaner.py +++ b/app/media_cleaner.py @@ -1,12 +1,13 @@ -import requests import time - -from app import logger -from app.utils import print_readable_freed_space, parse_size_to_bytes from datetime import datetime + +import requests from plexapi.server import PlexServer -from app.modules.trakt import Trakt + +from app import logger from app.modules.tautulli import Tautulli +from app.modules.trakt import Trakt +from app.utils import parse_size_to_bytes, print_readable_freed_space DEFAULT_MAX_ACTIONS_PER_RUN = 10 DEFAULT_SONARR_SERIES_TYPE = "standard" diff --git a/app/modules/tautulli.py b/app/modules/tautulli.py index db47325..40dc531 100644 --- a/app/modules/tautulli.py +++ b/app/modules/tautulli.py @@ -1,7 +1,9 @@ # encoding: utf-8 -from tautulli import RawAPI from datetime import datetime, timedelta + +from tautulli import RawAPI + from app import logger HISTORY_PAGE_SIZE = 300 diff --git a/app/modules/trakt.py b/app/modules/trakt.py index d3952d2..930078d 100644 --- a/app/modules/trakt.py +++ b/app/modules/trakt.py @@ -1,5 +1,7 @@ -import trakt import re + +import trakt + from app import logger diff --git a/tests/test_config.py b/tests/test_config.py index 95c4151..c7ec8f2 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,6 +1,7 @@ import pytest + from app.config import Config -from app.constants import VALID_SORT_FIELDS, VALID_SORT_ORDERS, VALID_ACTION_MODES +from app.constants import VALID_ACTION_MODES, VALID_SORT_FIELDS, VALID_SORT_ORDERS # Test case for validate_libraries diff --git a/tests/test_config_files.py b/tests/test_config_files.py index c899724..63bd6b0 100644 --- a/tests/test_config_files.py +++ b/tests/test_config_files.py @@ -1,9 +1,10 @@ import os import unittest from unittest.mock import patch -from app.deleterr import load_config + from app.config import Config -from app.modules import trakt, tautulli +from app.deleterr import load_config +from app.modules import tautulli, trakt class TestConfigFiles(unittest.TestCase): diff --git a/tests/test_deleterr.py b/tests/test_deleterr.py index d1f2237..08edefa 100644 --- a/tests/test_deleterr.py +++ b/tests/test_deleterr.py @@ -1,5 +1,6 @@ import unittest -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch + from app.deleterr import main diff --git a/tests/test_logger.py b/tests/test_logger.py index dbf0280..5c5aebd 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -1,5 +1,6 @@ import unittest -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch + from app import logger diff --git a/tests/test_media_cleaner.py b/tests/test_media_cleaner.py index 06306b8..54c45e3 100644 --- a/tests/test_media_cleaner.py +++ b/tests/test_media_cleaner.py @@ -1,15 +1,17 @@ import unittest +from unittest.mock import MagicMock, Mock, patch + import pytest +from plexapi.server import PlexServer + +from app.config import Config from app.media_cleaner import ( + DEFAULT_MAX_ACTIONS_PER_RUN, + MediaCleaner, find_watched_data, library_meets_disk_space_threshold, - MediaCleaner, - DEFAULT_MAX_ACTIONS_PER_RUN, ) -from unittest.mock import Mock, patch, MagicMock -from app.config import Config -from app.modules import trakt, tautulli -from plexapi.server import PlexServer +from app.modules import tautulli, trakt @pytest.fixture diff --git a/tests/test_sort_media.py b/tests/test_sort_media.py index 87dfd3d..7542a39 100644 --- a/tests/test_sort_media.py +++ b/tests/test_sort_media.py @@ -1,4 +1,5 @@ import pytest + from app.media_cleaner import sort_media diff --git a/tests/test_tautulli.py b/tests/test_tautulli.py index c1fd736..fb1a44b 100644 --- a/tests/test_tautulli.py +++ b/tests/test_tautulli.py @@ -1,7 +1,9 @@ +from datetime import datetime, timedelta +from unittest.mock import Mock, patch + import pytest -from unittest.mock import patch, Mock + from app.modules.tautulli import Tautulli, filter_by_most_recent -from datetime import datetime, timedelta @pytest.mark.parametrize( diff --git a/tests/test_utils.py b/tests/test_utils.py index 4fb26f1..75acda1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,6 @@ import pytest -from app.utils import print_readable_freed_space, parse_size_to_bytes, validate_units + +from app.utils import parse_size_to_bytes, print_readable_freed_space, validate_units @pytest.mark.parametrize( diff --git a/tox.ini b/tox.ini index 63ae200..c52b511 100644 --- a/tox.ini +++ b/tox.ini @@ -2,4 +2,4 @@ max-line-length = 200 extend-ignore = E203 exclude = tests/* -max-complexity = 15 \ No newline at end of file +max-complexity = 10 \ No newline at end of file