diff --git a/dev_tools.py b/dev_tools.py index 0692ea5fe0..c0a0c984af 100644 --- a/dev_tools.py +++ b/dev_tools.py @@ -86,7 +86,10 @@ def download_extract(url, dest_path): shutil.rmtree(app_path) # Just stashed the old webui zip on a random github release for easy hosting. # It doesn't get updated anymore, we should probably stop bundling it with releases soon. - download_extract('https://github.com/Flexget/Flexget/releases/download/v3.0.6/webui_v1.zip', os.path.join(ui_path, 'v1')) + download_extract( + 'https://github.com/Flexget/Flexget/releases/download/v3.0.6/webui_v1.zip', + os.path.join(ui_path, 'v1'), + ) except OSError as e: click.echo('Unable to download and extract WebUI v1 due to %e' % str(e)) raise click.Abort() diff --git a/flexget/components/archive/cli.py b/flexget/components/archive/cli.py index 8d36de7bc0..bf630c98ba 100644 --- a/flexget/components/archive/cli.py +++ b/flexget/components/archive/cli.py @@ -41,7 +41,7 @@ def consolidate(): logger.verbose('Found {} items to migrate, this can be aborted with CTRL-C safely.', count) # consolidate old data - from progressbar import ProgressBar, Percentage, Bar, ETA + from progressbar import ETA, Bar, Percentage, ProgressBar widgets = ['Process - ', ETA(), ' ', Percentage(), ' ', Bar(left='[', right=']')] bar = ProgressBar(widgets=widgets, maxval=count).start() diff --git a/flexget/components/ftp/ftp_list.py b/flexget/components/ftp/ftp_list.py index 9d44365754..044ab14b4b 100644 --- a/flexget/components/ftp/ftp_list.py +++ b/flexget/components/ftp/ftp_list.py @@ -9,9 +9,9 @@ from flexget.plugin import DependencyError, PluginError try: - from ftputil.error import FTPOSError import ftputil import ftputil.session + from ftputil.error import FTPOSError imported = True except ImportError: diff --git a/flexget/components/imdb/imdb_lookup.py b/flexget/components/imdb/imdb_lookup.py index cb9e7c3536..2b39caf1e7 100644 --- a/flexget/components/imdb/imdb_lookup.py +++ b/flexget/components/imdb/imdb_lookup.py @@ -45,7 +45,9 @@ class ImdbLookup: (writer.imdb_id, writer.name) for writer in movie.writers ), 'imdb_mpaa_rating': 'mpaa_rating', - 'imdb_plot_keywords': lambda movie: [plot_keyword.name for plot_keyword in movie.plot_keywords], + 'imdb_plot_keywords': lambda movie: [ + plot_keyword.name for plot_keyword in movie.plot_keywords + ], # Generic fields filled by all movie lookup plugins: 'movie_name': 'title', 'movie_year': 'year', @@ -301,7 +303,9 @@ def _parse_new_movie(self, imdb_url, session): writer = db.Writer(imdb_id, name) movie.writers.append(writer) # pylint:disable=E1101 for name in parser.plot_keywords: - plot_keyword = session.query(db.PlotKeyword).filter(db.PlotKeyword.name == name).first() + plot_keyword = ( + session.query(db.PlotKeyword).filter(db.PlotKeyword.name == name).first() + ) if not plot_keyword: plot_keyword = db.PlotKeyword(name) movie.plot_keywords.append(plot_keyword) # pylint:disable=E1101 diff --git a/flexget/components/imdb/utils.py b/flexget/components/imdb/utils.py index 3cc180d7d5..4db2d437eb 100644 --- a/flexget/components/imdb/utils.py +++ b/flexget/components/imdb/utils.py @@ -270,7 +270,7 @@ def __init__(self): self.imdb_id = None self.photo = None self.mpaa_rating = '' - self.plot_keywords=[] + self.plot_keywords = [] def __str__(self): return '' % (self.name, self.imdb_id) @@ -399,7 +399,9 @@ def parse(self, imdb_id, soup=None): keyword_elem = storyline.find('h4').parent if keyword_elem: # The last "a" tag is a link to the full list - self.plot_keywords = [keyword_elem.text.strip() for keyword_elem in keyword_elem.find_all("a")[:-1]] + self.plot_keywords = [ + keyword_elem.text.strip() for keyword_elem in keyword_elem.find_all("a")[:-1] + ] genres = data.get('genre', []) if not isinstance(genres, list): diff --git a/flexget/components/irc/irc.py b/flexget/components/irc/irc.py index 9f760b071b..e6124c7cae 100644 --- a/flexget/components/irc/irc.py +++ b/flexget/components/irc/irc.py @@ -17,8 +17,8 @@ from flexget.utils.tools import get_config_hash try: - from irc_bot.simple_irc_bot import SimpleIRCBot, partial from irc_bot import utils as irc_bot + from irc_bot.simple_irc_bot import SimpleIRCBot, partial except ImportError as e: irc_bot = None SimpleIRCBot = object diff --git a/flexget/components/notify/notifiers/toast.py b/flexget/components/notify/notifiers/toast.py index cd413e93f4..dc6dfac300 100644 --- a/flexget/components/notify/notifiers/toast.py +++ b/flexget/components/notify/notifiers/toast.py @@ -106,20 +106,16 @@ def windows_notify(self, title, message, config): from win32api import GetModuleHandle, PostQuitMessage from win32con import ( CW_USEDEFAULT, - IMAGE_ICON, IDI_APPLICATION, + IMAGE_ICON, LR_DEFAULTSIZE, LR_LOADFROMFILE, WM_DESTROY, + WM_USER, WS_OVERLAPPED, WS_SYSMENU, - WM_USER, ) from win32gui import ( - CreateWindow, - DestroyWindow, - LoadIcon, - LoadImage, NIF_ICON, NIF_INFO, NIF_MESSAGE, @@ -127,10 +123,14 @@ def windows_notify(self, title, message, config): NIM_ADD, NIM_DELETE, NIM_MODIFY, + WNDCLASS, + CreateWindow, + DestroyWindow, + LoadIcon, + LoadImage, RegisterClass, Shell_NotifyIcon, UpdateWindow, - WNDCLASS, ) except ImportError: raise DependencyError( diff --git a/flexget/components/seen/cli.py b/flexget/components/seen/cli.py index 06b7b9138d..d0786eba16 100644 --- a/flexget/components/seen/cli.py +++ b/flexget/components/seen/cli.py @@ -7,7 +7,7 @@ try: # NOTE: Importing other plugins is discouraged! - from flexget.components.imdb.utils import is_imdb_url, extract_id + from flexget.components.imdb.utils import extract_id, is_imdb_url except ImportError: raise plugin.DependencyError(issued_by=__name__, missing='imdb') diff --git a/flexget/components/sites/sites/filelist.py b/flexget/components/sites/sites/filelist.py index 91658b5a1e..e31d2cf91a 100644 --- a/flexget/components/sites/sites/filelist.py +++ b/flexget/components/sites/sites/filelist.py @@ -148,16 +148,14 @@ def get_login_cookie(self, username, password, force=False): # get validator token response = requests.get(BASE_URL + 'login.php') soup = get_soup(response.content) - + login_validator = soup.find("input", {"name": "validator"}) - + if not login_validator: - raise plugin.PluginError( - 'FileList.ro could not get login validator' - ) + raise plugin.PluginError('FileList.ro could not get login validator') logger.debug('Login Validator: {}'.format(login_validator.get('value'))) logger.debug('Attempting to retrieve FileList.ro cookie') - + response = requests.post( url, data={ diff --git a/flexget/components/sites/sites/filelist_api.py b/flexget/components/sites/sites/filelist_api.py index 21720925e3..5e6465b279 100644 --- a/flexget/components/sites/sites/filelist_api.py +++ b/flexget/components/sites/sites/filelist_api.py @@ -1,5 +1,7 @@ from http import HTTPStatus + from loguru import logger + from flexget import plugin from flexget.config_schema import one_or_more from flexget.entry import Entry @@ -49,7 +51,7 @@ class SearchFileList: } valid_extras = ['internal', 'moderated', 'freeleech', 'doubleup'] - + schema = { 'type': 'object', 'properties': { @@ -76,7 +78,9 @@ def get(self, url, params): http_status = HTTPStatus(response.status_code) error_message = response.json().get('error', http_status.description) - raise plugin.PluginError(f'FileList request failed; err code: {http_status}; err msg: `{error_message}`') + raise plugin.PluginError( + f'FileList request failed; err code: {http_status}; err msg: `{error_message}`' + ) return response @@ -88,7 +92,11 @@ def search(self, task, entry, config): entries = [] # mandatory params - params = {'username': config['username'], 'passkey': config['passkey'], 'action': 'search-torrents'} + params = { + 'username': config['username'], + 'passkey': config['passkey'], + 'action': 'search-torrents', + } # category if config.get('category'): @@ -127,7 +135,9 @@ def search(self, task, entry, config): if not results: logger.verbose('No torrent found on Filelist for `{}`', search_title) else: - logger.verbose('{} torrent(s) were found on Filelist for `{}`', len(results), search_title) + logger.verbose( + '{} torrent(s) were found on Filelist for `{}`', len(results), search_title + ) for result in results: entry = Entry() @@ -143,7 +153,9 @@ def search(self, task, entry, config): entry['torrent_internal'] = bool(result['internal']) entry['torrent_moderated'] = bool(result['moderated']) entry['torrent_freeleech'] = bool(result['freeleech']) - entry['torrent_genres'] = [genres.strip() for genres in result['small_description'].split(',')] + entry['torrent_genres'] = [ + genres.strip() for genres in result['small_description'].split(',') + ] entries.append(entry) diff --git a/flexget/components/sites/sites/iptorrents.py b/flexget/components/sites/sites/iptorrents.py index 3e9f46ba87..24a88d1e44 100644 --- a/flexget/components/sites/sites/iptorrents.py +++ b/flexget/components/sites/sites/iptorrents.py @@ -57,6 +57,7 @@ SEARCH_URL = 'https://iptorrents.com/t?' FREE_SEARCH_URL = 'https://iptorrents.com/t?free=on' + class UrlRewriteIPTorrents: """ IpTorrents urlrewriter and search plugin. @@ -128,24 +129,28 @@ def search(self, task, entry, config=None): # If there are any text categories, turn them into their id number categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories] - category_params = {str(c):'' for c in categories if str(c)} + category_params = {str(c): '' for c in categories if str(c)} entries = set() for search_string in entry.get('search_strings', [entry['title']]): - search_params = {key:value for (key,value) in category_params.items()} + search_params = {key: value for (key, value) in category_params.items()} query = normalize_unicode(search_string) - search_params.update({'q':query, 'qf':''}) + search_params.update({'q': query, 'qf': ''}) logger.debug('searching with params: {}', search_params) if config.get('free'): req = requests.get( - FREE_SEARCH_URL, params=search_params, cookies={'uid': str(config['uid']), 'pass': config['password']} + FREE_SEARCH_URL, + params=search_params, + cookies={'uid': str(config['uid']), 'pass': config['password']}, ) else: req = requests.get( - SEARCH_URL, params=search_params, cookies={'uid': str(config['uid']), 'pass': config['password']} + SEARCH_URL, + params=search_params, + cookies={'uid': str(config['uid']), 'pass': config['password']}, ) logger.debug('full search URL: {}', req.url) diff --git a/flexget/components/sites/sites/newznab.py b/flexget/components/sites/sites/newznab.py index d205fe61e7..253e0b0e41 100644 --- a/flexget/components/sites/sites/newznab.py +++ b/flexget/components/sites/sites/newznab.py @@ -30,7 +30,10 @@ class Newznab: schema = { 'type': 'object', 'properties': { - 'category': {'type': 'string', 'enum': ['movie', 'tvsearch', 'tv', 'music', 'book', 'all']}, + 'category': { + 'type': 'string', + 'enum': ['movie', 'tvsearch', 'tv', 'music', 'book', 'all'], + }, 'url': {'type': 'string', 'format': 'url'}, 'website': {'type': 'string', 'format': 'url'}, 'apikey': {'type': 'string'}, @@ -49,7 +52,11 @@ def build_config(self, config): if 'url' not in config: if 'apikey' in config and 'website' in config: - config['params'] = {'t': config['category'], 'apikey': config['apikey'], 'extended': 1} + config['params'] = { + 't': config['category'], + 'apikey': config['apikey'], + 'extended': 1, + } config['url'] = f"{config['website']}/api" return config @@ -92,7 +99,9 @@ def search(self, task, entry, config=None): return self.do_search_all(entry, task, config) else: entries = [] - logger.warning("Work in progress. Searching for the specified category is not supported yet...") + logger.warning( + "Work in progress. Searching for the specified category is not supported yet..." + ) return entries def do_search_tvsearch(self, arg_entry, task, config=None): diff --git a/flexget/components/sites/sites/site_rutracker.py b/flexget/components/sites/sites/site_rutracker.py index d4df4f0e83..8d383dea0a 100644 --- a/flexget/components/sites/sites/site_rutracker.py +++ b/flexget/components/sites/sites/site_rutracker.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +from urllib.parse import parse_qs, urlencode, urlparse + from loguru import logger from requests.exceptions import RequestException @@ -7,9 +9,6 @@ from flexget.components.sites.urlrewriting import UrlRewritingError from flexget.event import event -from urllib.parse import urlparse, parse_qs, urlencode - - logger = logger.bind(name='rutracker') @@ -49,7 +48,7 @@ def url_rewrite(self, task, entry): magnet = { 'xt': f"urn:btih:{topic['info_hash']}", 'tr': [f'http://bt{i}.t-ru.org/ann?magnet' for i in ['', '2', '3', '4']], - 'dn': topic['topic_title'] + 'dn': topic['topic_title'], } magnet_qs = urlencode(magnet, doseq=True, safe=':') magnet_uri = f"magnet:?{magnet_qs}" diff --git a/flexget/components/thetvdb/api_tvdb.py b/flexget/components/thetvdb/api_tvdb.py index 37a303f143..7a1d72316e 100644 --- a/flexget/components/thetvdb/api_tvdb.py +++ b/flexget/components/thetvdb/api_tvdb.py @@ -481,7 +481,11 @@ def find_series_id(name, language=None): try: s['firstAired'] = datetime.strptime(s['firstAired'], "%Y-%m-%d") except ValueError: - logger.warning('Invalid firstAired date "{}" when parsing series {} ', s['firstAired'], s['seriesName']) + logger.warning( + 'Invalid firstAired date "{}" when parsing series {} ', + s['firstAired'], + s['seriesName'], + ) s['firstAired'] = datetime(1970, 1, 1) else: s['firstAired'] = datetime(1970, 1, 1) diff --git a/flexget/components/trakt/trakt_calendar.py b/flexget/components/trakt/trakt_calendar.py index bf1477bcc8..c5e68c7678 100644 --- a/flexget/components/trakt/trakt_calendar.py +++ b/flexget/components/trakt/trakt_calendar.py @@ -112,7 +112,9 @@ def on_task_input(self, task, config): try: results = ( - db.get_session(config.get('account')).get(url, params={'extended': 'full'}).json() + db.get_session(config.get('account')) + .get(url, params={'extended': 'full'}) + .json() ) logger.debug('Found {} calendar entries', len(results)) except RequestException as e: diff --git a/flexget/plugins/cli/perf_tests.py b/flexget/plugins/cli/perf_tests.py index 99554a8827..1eb59a7faa 100644 --- a/flexget/plugins/cli/perf_tests.py +++ b/flexget/plugins/cli/perf_tests.py @@ -25,12 +25,13 @@ def cli_perf_test(manager, options): def imdb_query(session): import time + from progressbar import ETA, Bar, Percentage, ProgressBar + from sqlalchemy.orm import joinedload_all + from sqlalchemy.sql.expression import select + # NOTE: importing other plugins directly is discouraged from flexget.components.imdb.db import Movie from flexget.plugins.cli.performance import log_query_count - from sqlalchemy.sql.expression import select - from progressbar import ProgressBar, Percentage, Bar, ETA - from sqlalchemy.orm import joinedload_all imdb_urls = [] diff --git a/flexget/plugins/clients/pyload.py b/flexget/plugins/clients/pyload.py index bb780c483f..366f14f2dc 100644 --- a/flexget/plugins/clients/pyload.py +++ b/flexget/plugins/clients/pyload.py @@ -8,6 +8,7 @@ from flexget.event import event from flexget.utils import json from flexget.utils.template import RenderError + logger = logger.bind(name='pyload') @@ -175,11 +176,7 @@ def add_entries(self, task, config): content = json.dumps(content) if is_pyload_ng: - url = ( - entry['url'] - if config.get('parse_url', self.DEFAULT_PARSE_URL) - else '' - ) + url = entry['url'] if config.get('parse_url', self.DEFAULT_PARSE_URL) else '' else: url = ( json.dumps(entry['url']) @@ -251,7 +248,7 @@ def add_entries(self, task, config): 'name': json.dumps(name.encode('ascii', 'ignore').decode()), 'links': json.dumps(urls), 'dest': json.dumps(dest), - 'session': session + 'session': session, } pid = api.post(add_package_command, data=data).text diff --git a/flexget/plugins/clients/transmission.py b/flexget/plugins/clients/transmission.py index 1db3212e79..51361e67bd 100644 --- a/flexget/plugins/clients/transmission.py +++ b/flexget/plugins/clients/transmission.py @@ -19,8 +19,7 @@ try: import transmissionrpc - from transmissionrpc import TransmissionError - from transmissionrpc import HTTPHandlerError + from transmissionrpc import HTTPHandlerError, TransmissionError except ImportError: # If transmissionrpc is not found, errors will be shown later pass @@ -124,8 +123,8 @@ def check_seed_limits(self, torrent, session): def on_task_start(self, task, config): try: import transmissionrpc - from transmissionrpc import TransmissionError # noqa from transmissionrpc import HTTPHandlerError # noqa + from transmissionrpc import TransmissionError # noqa except: raise plugin.PluginError( 'Transmissionrpc module version 0.11 or higher required.', logger diff --git a/flexget/plugins/filter/crossmatch.py b/flexget/plugins/filter/crossmatch.py index 75e602bfeb..2b25742682 100644 --- a/flexget/plugins/filter/crossmatch.py +++ b/flexget/plugins/filter/crossmatch.py @@ -44,9 +44,9 @@ def on_task_filter(self, task, config): all_fields = config['all_fields'] if not task.entries: - logger.trace('Stopping crossmatch filter because of no entries to check') - return - + logger.trace('Stopping crossmatch filter because of no entries to check') + return + match_entries = aggregate_inputs(task, config['from']) # perform action on intersecting entries diff --git a/flexget/plugins/input/filmweb_watchlist.py b/flexget/plugins/input/filmweb_watchlist.py index 7b57652bb3..7168fd1d08 100644 --- a/flexget/plugins/input/filmweb_watchlist.py +++ b/flexget/plugins/input/filmweb_watchlist.py @@ -6,9 +6,9 @@ from flexget.utils.cached_input import cached try: + from filmweb.exceptions import RequestFailed from filmweb.filmweb import Filmweb as FilmwebAPI from filmweb.items import LoggedUser - from filmweb.exceptions import RequestFailed except ImportError: # Errors are handled later pass diff --git a/flexget/plugins/input/generate.py b/flexget/plugins/input/generate.py index 2c67e4284e..4d00c10eed 100644 --- a/flexget/plugins/input/generate.py +++ b/flexget/plugins/input/generate.py @@ -17,8 +17,8 @@ def on_task_input(self, task, config): entries = [] for i in range(amount): entry = Entry() - import string import random + import string entry['url'] = 'http://localhost/generate/%s/%s' % ( i, diff --git a/flexget/plugins/input/json.py b/flexget/plugins/input/json.py index 2b23788870..4ecff399b0 100644 --- a/flexget/plugins/input/json.py +++ b/flexget/plugins/input/json.py @@ -1,13 +1,13 @@ """Plugin for json files.""" -from loguru import logger from pathlib import Path import dateutil.parser as parser +from loguru import logger from flexget import plugin -from flexget.utils import json from flexget.entry import Entry from flexget.event import event +from flexget.utils import json logger = logger.bind(name='json') @@ -41,10 +41,7 @@ class Json: 'properties': { 'file': {'type': 'string', 'format': 'file'}, 'encoding': {'type': 'string'}, - 'field_map': { - 'type': 'object', - 'additionalProperties': {'type': 'string'} - }, + 'field_map': {'type': 'object', 'additionalProperties': {'type': 'string'}}, }, 'required': ['file'], 'additionalProperties': False, @@ -72,7 +69,9 @@ def on_task_input(self, task, config): else: entry[field] = self.ds_dt(value) if not entry.isvalid(): - logger.error('No title and url defined for entry, you may need to use field_map to map them.') + logger.error( + 'No title and url defined for entry, you may need to use field_map to map them.' + ) yield Entry(item) diff --git a/flexget/plugins/input/torznab.py b/flexget/plugins/input/torznab.py index 40db890f1c..b0df4b498f 100644 --- a/flexget/plugins/input/torznab.py +++ b/flexget/plugins/input/torznab.py @@ -49,19 +49,19 @@ def search(self, task, entry, config=None): params = self._convert_query_parameters( entry, ['rid', 'tvdbid', 'traktid', 'tvmazeid', 'imdbid', 'tmdbid', 'season', 'ep'] ) - + if 'q' not in params.keys(): query = entry['title'] else: query = params['q'] - + entries = [] for search_string in entry.get('search_strings', [query]): params['q'] = search_string results = self.create_entries_from_query(self._build_url(**params), task) entries.extend(results) return entries - + def _build_url(self, **kwargs): """Builds the url with query parameters from the arguments""" params = self.params.copy() diff --git a/flexget/plugins/metainfo/subtitles_check.py b/flexget/plugins/metainfo/subtitles_check.py index c69f9425a6..6535f40528 100644 --- a/flexget/plugins/metainfo/subtitles_check.py +++ b/flexget/plugins/metainfo/subtitles_check.py @@ -29,8 +29,8 @@ def on_task_start(self, task, config): raise plugin.DependencyError( 'subliminal', 'subliminal', 'Subliminal module required. ImportError: %s' % e ) - from subliminal.cli import MutexLock from dogpile.cache.exception import RegionAlreadyConfigured + from subliminal.cli import MutexLock try: subliminal.region.configure( @@ -62,7 +62,7 @@ def get_subtitles(self, entry): ): return from subliminal import scan_video - from subliminal.core import search_external_subtitles, refine + from subliminal.core import refine, search_external_subtitles try: video = scan_video(entry['location']) diff --git a/flexget/plugins/output/subtitles_subliminal.py b/flexget/plugins/output/subtitles_subliminal.py index b3b33346ec..72211c90b7 100644 --- a/flexget/plugins/output/subtitles_subliminal.py +++ b/flexget/plugins/output/subtitles_subliminal.py @@ -106,15 +106,15 @@ def on_task_output(self, task, config): if not task.accepted: logger.debug('nothing accepted, aborting') return + import subliminal from babelfish import Language from dogpile.cache.exception import RegionAlreadyConfigured - import subliminal - from subliminal import scan_video, save_subtitles + from subliminal import save_subtitles, scan_video from subliminal.cli import MutexLock from subliminal.core import ( ARCHIVE_EXTENSIONS, - scan_archive, refine, + scan_archive, search_external_subtitles, ) from subliminal.score import episode_scores, movie_scores diff --git a/flexget/task.py b/flexget/task.py index ec38794202..78ffd5a60d 100644 --- a/flexget/task.py +++ b/flexget/task.py @@ -6,13 +6,13 @@ import string import threading from functools import total_ordering, wraps -from typing import Union, Iterable, List +from typing import Iterable, List, Union from loguru import logger from sqlalchemy import Column, Integer, String, Unicode from flexget import config_schema, db_schema -from flexget.entry import EntryUnicodeError, EntryState, Entry +from flexget.entry import Entry, EntryState, EntryUnicodeError from flexget.event import event, fire_event from flexget.manager import Session from flexget.plugin import ( @@ -131,8 +131,12 @@ def __init__(self, iterable=None): list.__init__(self, iterable or []) self._entries = EntryIterator(self, [EntryState.UNDECIDED, EntryState.ACCEPTED]) - self._accepted = EntryIterator(self, EntryState.ACCEPTED) # accepted entries, can still be rejected - self._rejected = EntryIterator(self, EntryState.REJECTED) # rejected entries, can not be accepted + self._accepted = EntryIterator( + self, EntryState.ACCEPTED + ) # accepted entries, can still be rejected + self._rejected = EntryIterator( + self, EntryState.REJECTED + ) # rejected entries, can not be accepted self._failed = EntryIterator(self, EntryState.FAILED) # failed entries self._undecided = EntryIterator(self, EntryState.UNDECIDED) # undecided entries (default) diff --git a/flexget/tests/api_tests/test_series_api.py b/flexget/tests/api_tests/test_series_api.py index 72c2239f2c..edcedbaecf 100644 --- a/flexget/tests/api_tests/test_series_api.py +++ b/flexget/tests/api_tests/test_series_api.py @@ -3,6 +3,7 @@ from flexget.api.app import base_message from flexget.components.seen.db import SeenEntry from flexget.components.series.api import ObjectsContainer as OC + # TODO: would be nicer to import db module from flexget.components.series.db import ( AlternateNames, diff --git a/flexget/tests/test_imdb_parser.py b/flexget/tests/test_imdb_parser.py index 3788c7cefc..b955462ec4 100644 --- a/flexget/tests/test_imdb_parser.py +++ b/flexget/tests/test_imdb_parser.py @@ -49,11 +49,19 @@ def test_parsed_data(self): assert parser.url == 'https://www.imdb.com/title/tt0114814/', 'URL not parsed correctly' assert 400000 < parser.votes < 1000000, 'Votes not parsed correctly' assert parser.year == 1995, 'Year not parsed correctly' - expected_keywords = {'criminal', 'suspect', 'criminal mastermind', 'dirty cop', 'burying a body'} - assert len(expected_keywords.intersection(parser.plot_keywords)) == len(expected_keywords),\ - 'Parsed plot keywords missing items from the expected result' - assert len(expected_keywords) == len(parser.plot_keywords),\ - 'Parsed plot keyword count does not match expected.' + expected_keywords = { + 'criminal', + 'suspect', + 'criminal mastermind', + 'dirty cop', + 'burying a body', + } + assert len(expected_keywords.intersection(parser.plot_keywords)) == len( + expected_keywords + ), 'Parsed plot keywords missing items from the expected result' + assert len(expected_keywords) == len( + parser.plot_keywords + ), 'Parsed plot keyword count does not match expected.' def test_no_plot(self): # Make sure parser doesn't crash for movies with no plot diff --git a/flexget/tests/test_serialization.py b/flexget/tests/test_serialization.py index 043a8ac320..b196e7d849 100644 --- a/flexget/tests/test_serialization.py +++ b/flexget/tests/test_serialization.py @@ -44,7 +44,7 @@ def test_builtin_serialization(self): 'a': 'aoeu', 'b': [1, 2, 3.5], 'c': (1, datetime.datetime(2019, 12, 12, 12, 12)), - 'd': {'a', 1, datetime.date(2019, 11, 11)} + 'd': {'a', 1, datetime.date(2019, 11, 11)}, } out = serialization.dumps(value) backin = serialization.loads(out) @@ -56,4 +56,4 @@ def test_unserializable(self): with pytest.raises(TypeError): serialization.serialize(value) with pytest.raises(TypeError): - serialization.dumps(value) \ No newline at end of file + serialization.dumps(value) diff --git a/flexget/tests/test_urlrewriting.py b/flexget/tests/test_urlrewriting.py index 7c8254a5dc..9a6c989686 100644 --- a/flexget/tests/test_urlrewriting.py +++ b/flexget/tests/test_urlrewriting.py @@ -80,8 +80,7 @@ def test_rutracker(self, execute_task): urlrewriter.url_rewrite(task, entry) assert ( entry['url'] - == - 'magnet:?xt=urn:btih:38527C88CFE76411EF0C20FDF36B84DFE2C2D210&tr=http:%2F%2Fbt.t-ru.org%2Fann%3Fmagnet&tr=http:%2F%2Fbt2.t-ru.org%2Fann%3Fmagnet&tr=http:%2F%2Fbt3.t-ru.org%2Fann%3Fmagnet&tr=http:%2F%2Fbt4.t-ru.org%2Fann%3Fmagnet&dn=%D0%9F%D0%A0%D0%AB%D0%96%D0%9A%D0%98+%D0%9D%D0%90+%D0%9B%D0%AB%D0%96%D0%90%D0%A5+%D0%A1+%D0%A2%D0%A0%D0%90%D0%9C%D0%9F%D0%9B%D0%98%D0%9D%D0%90.+%D0%A1%D0%B5%D0%B7%D0%BE%D0%BD+2008-2009.+%D0%92%D0%A1%D0%95+%D0%A1%D0%9E%D0%A0%D0%95%D0%92%D0%9D%D0%9E%D0%92%D0%90%D0%9D%D0%98%D0%AF.+%D0%A1+%D1%80%D0%B0%D0%B7%D0%BD%D1%8B%D1%85+%D0%BA%D0%B0%D0%BD%D0%B0%D0%BB%D0%BE%D0%B2.%5B%D0%A1%D0%B5%D0%B7%D0%BE%D0%BD+2008-2009%2C+%D1%80%D0%B0%D0%B7%D0%BD%D0%BE%D0%B3%D0%BE+%D0%BA%D0%B0%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%B0.%5D' + == 'magnet:?xt=urn:btih:38527C88CFE76411EF0C20FDF36B84DFE2C2D210&tr=http:%2F%2Fbt.t-ru.org%2Fann%3Fmagnet&tr=http:%2F%2Fbt2.t-ru.org%2Fann%3Fmagnet&tr=http:%2F%2Fbt3.t-ru.org%2Fann%3Fmagnet&tr=http:%2F%2Fbt4.t-ru.org%2Fann%3Fmagnet&dn=%D0%9F%D0%A0%D0%AB%D0%96%D0%9A%D0%98+%D0%9D%D0%90+%D0%9B%D0%AB%D0%96%D0%90%D0%A5+%D0%A1+%D0%A2%D0%A0%D0%90%D0%9C%D0%9F%D0%9B%D0%98%D0%9D%D0%90.+%D0%A1%D0%B5%D0%B7%D0%BE%D0%BD+2008-2009.+%D0%92%D0%A1%D0%95+%D0%A1%D0%9E%D0%A0%D0%95%D0%92%D0%9D%D0%9E%D0%92%D0%90%D0%9D%D0%98%D0%AF.+%D0%A1+%D1%80%D0%B0%D0%B7%D0%BD%D1%8B%D1%85+%D0%BA%D0%B0%D0%BD%D0%B0%D0%BB%D0%BE%D0%B2.%5B%D0%A1%D0%B5%D0%B7%D0%BE%D0%BD+2008-2009%2C+%D1%80%D0%B0%D0%B7%D0%BD%D0%BE%D0%B3%D0%BE+%D0%BA%D0%B0%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%B0.%5D' ) diff --git a/flexget/utils/json.py b/flexget/utils/json.py index 013829f263..73a2e46c26 100644 --- a/flexget/utils/json.py +++ b/flexget/utils/json.py @@ -5,7 +5,7 @@ Also allows date and datetime objects to be encoded/decoded. """ import datetime -from collections import Mapping, Iterable +from collections import Iterable, Mapping from flexget.plugin import DependencyError diff --git a/flexget/utils/serialization.py b/flexget/utils/serialization.py index ea7cf44d2d..1a1fafa21e 100644 --- a/flexget/utils/serialization.py +++ b/flexget/utils/serialization.py @@ -1,6 +1,6 @@ import datetime from abc import ABC, abstractmethod -from typing import Any, Type, Optional +from typing import Any, Optional, Type from flexget.utils import json diff --git a/flexget/utils/sqlalchemy_utils.py b/flexget/utils/sqlalchemy_utils.py index 34765341df..a32302145f 100644 --- a/flexget/utils/sqlalchemy_utils.py +++ b/flexget/utils/sqlalchemy_utils.py @@ -1,7 +1,7 @@ """ Miscellaneous SQLAlchemy helpers. """ -from typing import Any, List, Union, Optional +from typing import Any, List, Optional, Union from loguru import logger from sqlalchemy import ColumnDefault, Index, Sequence