Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 25, 2023
1 parent b71a39f commit 7e5bf6b
Show file tree
Hide file tree
Showing 30 changed files with 99 additions and 118 deletions.
2 changes: 1 addition & 1 deletion flexget/api/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def stream_response():
except Empty:
pass

if queue.empty() and all([task['event'].is_set() for task in tasks_queued]):
if queue.empty() and all(task['event'].is_set() for task in tasks_queued):
for task in tasks_queued:
del _streams[task['id']]
break
Expand Down
3 changes: 1 addition & 2 deletions flexget/components/failed/retry_failed.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def on_task_filter(self, task, config):
if item:
if item.count > max_count:
entry.reject(
'Has already failed %s times in the past. (failure reason: %s)'
% (item.count, item.reason)
f'Has already failed {item.count} times in the past. (failure reason: {item.reason})'
)
elif item.retry_time and item.retry_time > datetime.now():
entry.reject(
Expand Down
5 changes: 3 additions & 2 deletions flexget/components/imdb/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ def on_task_filter(self, task, config):
if 'min_meta_score' in config:
if entry.get('imdb_meta_score', 0) < config['min_meta_score']:
reasons.append(
'min_meta_score (%s < %s)'
% (entry.get('imdb_meta_score'), config['min_meta_score'])
'min_meta_score ({} < {})'.format(
entry.get('imdb_meta_score'), config['min_meta_score']
)
)
if 'min_year' in config:
if entry.get('imdb_year', 0) < config['min_year']:
Expand Down
5 changes: 3 additions & 2 deletions flexget/components/imdb/imdb_watchlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ def parse_html_list(self, task, config, url, params, headers):
except (ValueError, TypeError) as e:
# TODO Something is wrong if we get a ValueError, I think
raise plugin.PluginError(
'Received invalid movie count: %s ; %s'
% (soup.find('div', class_='lister-total-num-results').string, e)
'Received invalid movie count: {} ; {}'.format(
soup.find('div', class_='lister-total-num-results').string, e
)
)

if not total_item_count:
Expand Down
3 changes: 1 addition & 2 deletions flexget/components/irc/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ def __init__(self, config, config_name):

if self.config.get(value_name) is None:
raise MissingConfigOption(
'missing configuration option on irc config %s: %s'
% (self.connection_name, value_name)
f'missing configuration option on irc config {self.connection_name}: {value_name}'
)

# Get the tracker name, for use in the connection name
Expand Down
3 changes: 1 addition & 2 deletions flexget/components/managed_lists/lists/imdb_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ def items(self):
logger.debug('fetching items from IMDB')
try:
r = self.session.get(
'https://www.imdb.com/list/export?list_id=%s&author_id=%s'
% (self.list_id, self.user_id),
f'https://www.imdb.com/list/export?list_id={self.list_id}&author_id={self.user_id}',
cookies=self.cookies,
)
lines = list(r.iter_lines(decode_unicode=True))
Expand Down
26 changes: 11 additions & 15 deletions flexget/components/parsing/parsers/parser_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,15 @@ def fields(self) -> dict:

def __str__(self) -> str:
valid = 'OK' if self.valid else 'INVALID'
return (
'<MovieParseResult(data=%s,name=%s,year=%s,id=%s,quality=%s,proper=%s,release_group=%s,status=%s)>'
% (
self.data,
self.name,
self.year,
self.identifier,
self.quality,
self.proper_count,
self.release_group,
valid,
)
return '<MovieParseResult(data={},name={},year={},id={},quality={},proper={},release_group={},status={})>'.format(
self.data,
self.name,
self.year,
self.identifier,
self.quality,
self.proper_count,
self.release_group,
valid,
)


Expand Down Expand Up @@ -209,9 +206,8 @@ def pack_identifier(self) -> str:
def __str__(self) -> str:
valid = 'OK' if self.valid else 'INVALID'
return (
'<SeriesParseResult(data=%s,name=%s,id=%s,season=%s,season_pack=%s,episode=%s,quality=%s,proper=%s,'
'special=%s,status=%s)>'
% (
'<SeriesParseResult(data={},name={},id={},season={},season_pack={},episode={},quality={},proper={},'
'special={},status={})>'.format(
self.data,
self.name,
str(self.id),
Expand Down
3 changes: 1 addition & 2 deletions flexget/components/rejected/remember_rejected.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def on_task_filter(self, task, config):
).first()
if reject_entry:
entry.reject(
'Rejected on behalf of %s plugin: %s'
% (reject_entry.rejected_by, reject_entry.reason)
f'Rejected on behalf of {reject_entry.rejected_by} plugin: {reject_entry.reason}'
)

def on_entry_reject(self, entry, remember=None, remember_time=None, **kwargs):
Expand Down
5 changes: 3 additions & 2 deletions flexget/components/seen/seen.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ def on_task_filter(self, task, config, remember_rejected=False):
.one()
)
entry.reject(
'Entry with %s `%s` is already marked seen in the task %s at %s'
% (found.field, found.value, se.task, se.added.strftime('%Y-%m-%d %H:%M')),
'Entry with {} `{}` is already marked seen in the task {} at {}'.format(
found.field, found.value, se.task, se.added.strftime('%Y-%m-%d %H:%M')
),
remember=remember_rejected,
)

Expand Down
6 changes: 2 additions & 4 deletions flexget/components/series/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,7 @@ def put(self, show_id, season_id, session):
release.downloaded = False

return success_response(
'successfully reset download status for all releases for season %s from show %s'
% (season_id, show_id)
f'successfully reset download status for all releases for season {season_id} from show {show_id}'
)


Expand Down Expand Up @@ -1134,8 +1133,7 @@ def put(self, show_id, ep_id, session):
release.downloaded = False

return success_response(
'successfully reset download status for all releases for episode %s from show %s'
% (ep_id, show_id)
f'successfully reset download status for all releases for episode {ep_id} from show {show_id}'
)


Expand Down
3 changes: 1 addition & 2 deletions flexget/components/series/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def remove(manager, options, forget=False):
console(e.args[0])
else:
console(
'Removed entities(s) matching `%s` from series `%s`.'
% (identifier, name.capitalize())
f'Removed entities(s) matching `{identifier}` from series `{name.capitalize()}`.'
)
else:
# remove whole series
Expand Down
3 changes: 1 addition & 2 deletions flexget/components/series/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,7 @@ def set_series_begin(series: Series, ep_id: Union[str, int]) -> Tuple[str, str]:
if series.identified_by not in ['auto', '', None]:
if identified_by != series.identified_by:
raise ValueError(
'`begin` value `%s` does not match identifier type for identified_by `%s`'
% (ep_id, series.identified_by)
f'`begin` value `{ep_id}` does not match identifier type for identified_by `{series.identified_by}`'
)
series.identified_by = identified_by
episode = (
Expand Down
3 changes: 1 addition & 2 deletions flexget/components/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,7 @@ def _exclude_season_on_accept(
if entity < entity.series.begin:
for entry in entries:
entry.reject(
'Entity `%s` is before begin value of `%s`'
% (entity.identifier, entity.series.begin.identifier)
f'Entity `{entity.identifier}` is before begin value of `{entity.series.begin.identifier}`'
)
continue

Expand Down
23 changes: 10 additions & 13 deletions flexget/components/status/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,16 @@ class TaskExecution(Base):
abort_reason = Column(String, nullable=True)

def __repr__(self):
return (
'<TaskExecution(task_id=%s,start=%s,end=%s,succeeded=%s,p=%s,a=%s,r=%s,f=%s,reason=%s)>'
% (
self.task_id,
self.start,
self.end,
self.succeeded,
self.produced,
self.accepted,
self.rejected,
self.failed,
self.abort_reason,
)
return '<TaskExecution(task_id={},start={},end={},succeeded={},p={},a={},r={},f={},reason={})>'.format(
self.task_id,
self.start,
self.end,
self.succeeded,
self.produced,
self.accepted,
self.rejected,
self.failed,
self.abort_reason,
)

def to_dict(self):
Expand Down
9 changes: 3 additions & 6 deletions flexget/components/trakt/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,7 @@ def get_trakt_id_from_id(trakt_ids, media_type):
).json()
except requests.RequestException as e:
raise LookupError(
'Searching trakt for %s=%s failed with error: %s'
% (stripped_id_type, identifier, e)
f'Searching trakt for {stripped_id_type}={identifier} failed with error: {e}'
)
for result in results:
if result['type'] != media_type:
Expand Down Expand Up @@ -1073,8 +1072,7 @@ def get_trakt_data(media_type, title=None, year=None, trakt_ids=None):

if not trakt_id:
raise LookupError(
'No results on Trakt.tv, title=%s, ids=%s.'
% (title, trakt_ids.to_dict if trakt_ids else None)
f'No results on Trakt.tv, title={title}, ids={trakt_ids.to_dict if trakt_ids else None}.'
)

# Get actual data from trakt
Expand Down Expand Up @@ -1129,8 +1127,7 @@ def get_user_data(data_type, media_type, session, username):

except requests.RequestException as e:
raise plugin.PluginError(
'Error fetching data from trakt.tv endpoint %s for user %s: %s'
% (endpoint, username, e)
f'Error fetching data from trakt.tv endpoint {endpoint} for user {username}: {e}'
)


Expand Down
3 changes: 1 addition & 2 deletions flexget/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def add_event_handler(name: str, func: Callable, priority: int = 128) -> Event:
for event in events:
if event.func == func:
raise ValueError(
'%s has already been registered as event listener under name %s'
% (func.__name__, name)
f'{func.__name__} has already been registered as event listener under name {name}'
)
logger.trace('registered function {} to event {}', func.__name__, name)
event = Event(name, func, priority)
Expand Down
12 changes: 4 additions & 8 deletions flexget/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,12 @@ def load_config(self, output_to_console: bool = True, config_file_hash: str = No
print('')
if e.context_mark is not None:
print(
' Check configuration near line %s, column %s'
% (e.context_mark.line, e.context_mark.column)
f' Check configuration near line {e.context_mark.line}, column {e.context_mark.column}'
)
lines += 1
if e.problem_mark is not None:
print(
' Check configuration near line %s, column %s'
% (e.problem_mark.line, e.problem_mark.column)
f' Check configuration near line {e.problem_mark.line}, column {e.problem_mark.column}'
)
lines += 1
if lines:
Expand Down Expand Up @@ -811,14 +809,12 @@ def init_sqlalchemy(self) -> None:
except OperationalError as e:
if os.path.exists(self.db_filename):
print(
'%s - make sure you have write permissions to file %s'
% (e.message, self.db_filename),
f'{e.message} - make sure you have write permissions to file {self.db_filename}',
file=sys.stderr,
)
else:
print(
'%s - make sure you have write permissions to directory %s'
% (e.message, self.config_base),
f'{e.message} - make sure you have write permissions to directory {self.config_base}',
file=sys.stderr,
)
raise
Expand Down
3 changes: 1 addition & 2 deletions flexget/plugins/cli/try_regexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def on_task_filter(self, task, config):
'Press ^D or type \'exit\' to continue. Type \'continue\' to continue non-interactive execution.'
)
console(
'Task \'%s\' has %s entries, enter regexp to see what matches it.'
% (task.name, len(task.entries))
f'Task \'{task.name}\' has {len(task.entries)} entries, enter regexp to see what matches it.'
)
while True:
try:
Expand Down
6 changes: 2 additions & 4 deletions flexget/plugins/clients/aria2.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,12 @@ def __init__(self, server, port, scheme, rpc_path, username=None, password=None,
self._aria2 = xmlrpc.client.ServerProxy(self.url, context=schemes[scheme]).aria2
except xmlrpc.client.ProtocolError as exc:
raise plugin.PluginError(
'Could not connect to aria2 at %s. Protocol error %s: %s'
% (self.url, exc.errcode, exc.errmsg),
f'Could not connect to aria2 at {self.url}. Protocol error {exc.errcode}: {exc.errmsg}',
logger,
) from exc
except xmlrpc.client.Fault as exc:
raise plugin.PluginError(
'XML-RPC fault: Unable to connect to aria2 daemon at %s: %s'
% (self.url, exc.faultString),
f'XML-RPC fault: Unable to connect to aria2 daemon at {self.url}: {exc.faultString}',
logger,
) from exc
except OSError as exc:
Expand Down
25 changes: 15 additions & 10 deletions flexget/plugins/filter/rottentomatoes.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,23 @@ def on_task_filter(self, task, config):
if 'min_critics_score' in config:
if entry.get('rt_critics_score', 0) < config['min_critics_score']:
reasons.append(
'min_critics_score (%s < %s)'
% (entry.get('rt_critics_score'), config['min_critics_score'])
'min_critics_score ({} < {})'.format(
entry.get('rt_critics_score'), config['min_critics_score']
)
)
if 'min_audience_score' in config:
if entry.get('rt_audience_score', 0) < config['min_audience_score']:
reasons.append(
'min_audience_score (%s < %s)'
% (entry.get('rt_audience_score'), config['min_audience_score'])
'min_audience_score ({} < {})'.format(
entry.get('rt_audience_score'), config['min_audience_score']
)
)
if 'min_average_score' in config:
if entry.get('rt_average_score', 0) < config['min_average_score']:
reasons.append(
'min_average_score (%s < %s)'
% (entry.get('rt_average_score'), config['min_average_score'])
'min_average_score ({} < {})'.format(
entry.get('rt_average_score'), config['min_average_score']
)
)
if 'min_critics_rating' in config:
if not entry.get('rt_critics_rating'):
Expand All @@ -130,8 +133,9 @@ def on_task_filter(self, task, config):
< self.critics_ratings[config['min_critics_rating']]
):
reasons.append(
'min_critics_rating (%s < %s)'
% (entry.get('rt_critics_rating').lower(), config['min_critics_rating'])
'min_critics_rating ({} < {})'.format(
entry.get('rt_critics_rating').lower(), config['min_critics_rating']
)
)
if 'min_audience_rating' in config:
if not entry.get('rt_audience_rating'):
Expand All @@ -141,8 +145,9 @@ def on_task_filter(self, task, config):
< self.audience_ratings[config['min_audience_rating']]
):
reasons.append(
'min_audience_rating (%s < %s)'
% (entry.get('rt_audience_rating').lower(), config['min_audience_rating'])
'min_audience_rating ({} < {})'.format(
entry.get('rt_audience_rating').lower(), config['min_audience_rating']
)
)
if 'min_year' in config:
if entry.get('rt_year', 0) < config['min_year']:
Expand Down
16 changes: 8 additions & 8 deletions flexget/plugins/filter/thetvdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,29 +141,29 @@ def on_task_filter(self, task, config):
if 'min_series_rating' in config:
if entry['tvdb_rating'] < config['min_series_rating']:
reasons.append(
'series_rating (%s < %s)'
% (entry['tvdb_rating'], config['min_series_rating'])
'series_rating ({} < {})'.format(
entry['tvdb_rating'], config['min_series_rating']
)
)
if 'min_episode_rating' in config:
if entry['tvdb_ep_rating'] < config['min_episode_rating']:
reasons.append(
'tvdb_ep_rating (%s < %s)'
% (entry['tvdb_ep_rating'], config['min_episode_rating'])
'tvdb_ep_rating ({} < {})'.format(
entry['tvdb_ep_rating'], config['min_episode_rating']
)
)
if 'min_episode_air_year' in config:
if entry['tvdb_ep_air_date'].strftime("%Y") < config['min_episode_air_year']:
reasons.append(
'tvdb_ep_air_date (%s < %s)'
% (
'tvdb_ep_air_date ({} < {})'.format(
entry['tvdb_ep_air_date'].strftime("%Y"),
config['min_episode_air_year'],
)
)
if 'max_episode_air_year' in config:
if entry['tvdb_ep_air_date'].strftime("%Y") > config['max_episode_air_year']:
reasons.append(
'tvdb_ep_air_date (%s < %s)'
% (
'tvdb_ep_air_date ({} < {})'.format(
entry['tvdb_ep_air_date'].strftime("%Y"),
config['max_episode_air_year'],
)
Expand Down
Loading

0 comments on commit 7e5bf6b

Please sign in to comment.