Skip to content

Commit 10de7be

Browse files
committed
- working on pylint unused-cariable warnings
- working on ruff unused import worning
1 parent 15d1d10 commit 10de7be

22 files changed

+124
-185
lines changed

pyradio/browser.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ def search(self, go_back_in_history=True):
722722

723723
def next_page(self, msg_function=None):
724724
self._page += 1
725-
post_data = self._get_post_data()
725+
# post_data = self._get_post_data()
726726
if self.current_search_limit > len(self._raw_stations):
727727
self._page -= 1
728728
return '___No more results available!___'
@@ -944,7 +944,7 @@ def format_empty_line(self, width):
944944

945945
out = ['', '']
946946
i_out = []
947-
for i, n in enumerate(info[self._output_format]):
947+
for n in info[self._output_format]:
948948
i_out.append(u'│' + ' ' * self._columns_width[n])
949949
out[1] = ''.join(i_out)
950950

@@ -1838,7 +1838,7 @@ def __init__(
18381838
'''
18391839
self._cannot_delete_function = cannot_delete_function
18401840
if len(self._params) == 0:
1841-
for i in range(0, 3):
1841+
for _ in range(0, 3):
18421842
self._params.append(
18431843
{'auto_save': False,
18441844
'server': '',
@@ -3488,7 +3488,7 @@ def _handle_new_or_existing_search_term(self):
34883488
'''
34893489
test_search_term = self._widgets_to_search_term()
34903490
if test_search_term:
3491-
found, index = self._get_search_term_index(test_search_term)
3491+
_, index = self._get_search_term_index(test_search_term)
34923492
# TODO: check if item is altered
34933493
self._selected_history_id = index
34943494
self._print_history_legend()
@@ -3959,7 +3959,7 @@ def set_active_by_value(self, a_string, set_selection=True):
39593959
def show(self, parent=None):
39603960
self._too_small = False
39613961
pY, pX = self._parent.getmaxyx()
3962-
Y, X = self._parent.getbegyx()
3962+
Y, _ = self._parent.getbegyx()
39633963
if self.maxY > pY or self.maxX > pX -2:
39643964
self._too_small = True
39653965
msg = 'Window too small to display content!'
@@ -4135,7 +4135,7 @@ def show(self, parent=None):
41354135
self.servers._parent = parent
41364136
self._too_small = False
41374137
pY, pX = self._parent.getmaxyx()
4138-
Y, X = self._parent.getbegyx()
4138+
Y, _ = self._parent.getbegyx()
41394139
if pX < 80 or pY < 22:
41404140
self._too_small = True
41414141
msg = 'Window too small to display content!'
@@ -4596,7 +4596,6 @@ def selection(self):
45964596

45974597
@selection.setter
45984598
def selection(self, val):
4599-
old_selection = self._selection
46004599
if 0 <= val < len(self._items):
46014600
self._selection = val
46024601
self.show()

pyradio/cjkwrap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import textwrap
3030
import unicodedata
31-
import sys
3231

3332
import locale
3433
locale.setlocale(locale.LC_ALL, "")

pyradio/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
import argparse
32
from argparse import ArgumentParser, SUPPRESS as SUPPRESS
43
from os import path, getenv
54
import sys
@@ -87,7 +86,7 @@ def server_port(self):
8786

8887
@property
8988
def server_found(self):
90-
return False if self._file is None else True
89+
return self._file is not None
9190

9291
@property
9392
def last_command(self):
@@ -241,7 +240,6 @@ def __init(self):
241240
def print_usage(self, file=None):
242241
if file is None:
243242
file = sys.stdout
244-
usage = self.format_usage()
245243
print(self._add_colors(self.format_usage()))
246244

247245
def print_help(self, file=None):

pyradio/common.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
import io
55
import csv
66
import curses
7-
from sys import version as sys_version
87
from os import rename, remove, access, X_OK
98
from os.path import exists, dirname, join
109
from shutil import which
11-
from copy import deepcopy
1210
from rich import print
1311

1412
logger = logging.getLogger(__name__)
1513

1614
locale.setlocale(locale.LC_ALL, "")
1715

1816
""" Theming constants """
19-
def FOREGROUND(): return 0
20-
def BACKGROUND(): return 1
17+
def FOREGROUND():
18+
return 0
19+
def BACKGROUND():
20+
return 1
2121

2222
# for pop up window
2323
CAPTION = 2
@@ -59,7 +59,7 @@ def BACKGROUND(): return 1
5959
': Playback stopped',
6060
': Player terminated abnormally!')
6161

62-
def erase_curses_win(self, Y, X, beginY, beginX, char=' ', color=5):
62+
def erase_curses_win(Y, X, beginY, beginX, char=' ', color=5):
6363
''' empty a part of the screen
6464
'''
6565
empty_win = curses.newwin(
@@ -199,8 +199,8 @@ def _read_synced_version(self, asked=False):
199199
# print('in_file = "{}"'.format(in_file))
200200
if exists(in_file):
201201
try:
202-
with open(in_file, 'r', encoding='utf-8') as l:
203-
line = l.readline().strip()
202+
with open(in_file, 'r', encoding='utf-8') as sync_file:
203+
line = sync_file.readline().strip()
204204
return eval(line)
205205
except:
206206
pass
@@ -209,8 +209,8 @@ def _read_synced_version(self, asked=False):
209209
def write_synced_version(self, asked=False):
210210
out_file = self._asked_sync_file if asked else self._last_sync_file
211211
try:
212-
with open(out_file, 'w', encoding='utf-8') as l:
213-
l.write(self.version_to_write)
212+
with open(out_file, 'w', encoding='utf-8') as sync_file:
213+
sync_file.write(self.version_to_write)
214214
except:
215215
return -5 if asked else -6
216216
return -3 if asked else 0
@@ -346,8 +346,8 @@ def stations_csv_needs_sync(self, print_messages=True, stop=None):
346346
return False
347347
if exists(self._last_sync_file):
348348
try:
349-
with open(self._last_sync_file, 'r', encoding='utf-8') as l:
350-
line = l.readline().strip()
349+
with open(self._last_sync_file, 'r', encoding='utf-8') as sync_file:
350+
line = sync_file.readline().strip()
351351
self.last_sync = eval(line)
352352
except:
353353
ret = False

pyradio/config.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import collections
99
import json
1010
# import socket
11-
from os import path, getenv, makedirs, remove, rename, readlink, SEEK_END, SEEK_CUR, environ, getpid, listdir, rmdir
11+
from os import path, getenv, makedirs, remove, rename, readlink, SEEK_END, SEEK_CUR, getpid, listdir
1212
from sys import platform
1313
from time import ctime, sleep
1414
from datetime import datetime
@@ -23,7 +23,7 @@
2323
from pyradio import version, stations_updated
2424
from .common import validate_resource_opener_path
2525
from .keyboard import kbkey, read_keyboard_shortcuts
26-
from .browser import PyRadioStationsBrowser, probeBrowsers
26+
from .browser import probeBrowsers
2727
from .install import get_github_long_description
2828
from .common import is_rasberrypi
2929
from .player import pywhich
@@ -602,7 +602,7 @@ def _get_playlist_abspath_from_data(self, stationFile=''):
602602
''' negative playlist number '''
603603
return '', -3
604604
else:
605-
n, f = self.read_playlists()
605+
n, _ = self.read_playlists()
606606
if sel <= n-1:
607607
stationFile = self.playlists[sel][-1]
608608
return stationFile, 0
@@ -1108,10 +1108,6 @@ def move_station(self, source, target):
11081108
self.number_of_stations == 0:
11091109
# logger.error('DE \n\nreturning False\n\n')
11101110
return False
1111-
if source < target:
1112-
step = 1
1113-
else:
1114-
step = 0
11151111
d = collections.deque(self.stations)
11161112
d.rotate(-source)
11171113
source_item = d.popleft()
@@ -1178,7 +1174,7 @@ def read_playlists(self):
11781174
return len(self.playlists), self.selected_playlist
11791175

11801176
def list_playlists(self):
1181-
num_of_playlists, selected_playlist = self.read_playlists()
1177+
self.read_playlists()
11821178
console = Console()
11831179

11841180
table = Table(show_header=True, header_style="bold magenta")
@@ -1466,9 +1462,6 @@ def __init__(self, user_config_dir=None, headless=False):
14661462

14671463
self._read_notification_command()
14681464

1469-
''' function to return a player instance '''
1470-
player_instance = None
1471-
14721465
@property
14731466
def linux_resource_opener(self):
14741467
return self._linux_resource_opener
@@ -1605,7 +1598,7 @@ def calculated_color_factor(self):
16051598
@calculated_color_factor.setter
16061599
def calculated_color_factor(self, value):
16071600
try:
1608-
test = float(str(value))
1601+
float(str(value))
16091602
self.opts['calculated_color_factor'][1] = str(value)
16101603
except (ValueError, TypeError, NameError):
16111604
self.opts['calculated_color_factor'][1] = '0'
@@ -1979,7 +1972,7 @@ def _get_lock_file(self):
19791972
else:
19801973
if not self.headless:
19811974
try:
1982-
with open(self._session_lock_file, 'w', encoding='utf-8') as f:
1975+
with open(self._session_lock_file, 'w', encoding='utf-8'):
19831976
pass
19841977
except:
19851978
pass
@@ -2095,7 +2088,6 @@ def _validate_remote_control_server_ip(self, val):
20952088
''' is server valid '''
20962089
if sp[0].startswith('*'):
20972090
sp[0] = sp[0][1:]
2098-
auto = True
20992091
x = [r for r in hosts if r == sp[0]]
21002092
if not x:
21012093
return default_remote_control_server
@@ -2164,7 +2156,7 @@ def _read_config(self, distro_config=False):
21642156
return -2
21652157
if sp[1] == '':
21662158
return -2
2167-
for i, n in enumerate(sp):
2159+
for i in range(len(sp)):
21682160
sp[i] = sp[i].strip()
21692161
if sp[0] == 'show_no_themes_message':
21702162
self.show_no_themes_message = True
@@ -2800,7 +2792,7 @@ def save_config(self, from_command_line=False):
28002792
# fix self.saved_params (remove profiles)
28012793
profiles_params_changed = False
28022794
for a_key in self.saved_params.keys():
2803-
the_id = self.saved_params[a_key][0]
2795+
# the_id = self.saved_params[a_key][0]
28042796
the_profile = self.saved_params[a_key][self.saved_params[a_key][0]]
28052797
# logger.error('\n\na_key = {0}\nthe_id = {1}\nthe_profile = {2}\n\n'.format(a_key, the_id, the_profile))
28062798
for i in range(len(self.saved_params[a_key])-1, 0, -1):
@@ -2872,7 +2864,6 @@ def is_blacklisted_terminal(self):
28722864
read ~/.config/pyradio/no-themes-terminals
28732865
'''
28742866
term_file = path.join(self.stations_dir, 'no-themes-terminals')
2875-
user_terminal = []
28762867
if path.exists(term_file):
28772868
try:
28782869
with open(term_file, 'r', encoding='utf-8') as term:
@@ -3568,7 +3559,6 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
35683559
# logger.error('w_path = {}'.format(w_path))
35693560
requests_response = None
35703561
written = False
3571-
line_num = 1
35723562
for n in range(0,5):
35733563
requests_response = None
35743564
try:
@@ -3583,7 +3573,7 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
35833573
if print_errors is not None:
35843574
print_errors.addstr(n + 1, 0, ' download failed, retrying...', curses.color_pair(0))
35853575
print_errors.refresh()
3586-
except requests.exceptions.RequestException as e:
3576+
except requests.exceptions.RequestException:
35873577
if print_errors is not None:
35883578
print_errors.addstr(n + 1, 0, ' download failed, retrying...', curses.color_pair(0))
35893579
print_errors.refresh()

pyradio/config_window.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from textwrap import wrap
77
import glob
88
import csv
9-
from os import path, sep, remove
9+
from os import path, sep
1010
from sys import platform, version_info
1111

1212
from .common import *
@@ -469,8 +469,8 @@ def _put_cursor(self, jump):
469469
return
470470
visible_items = self.maxY - 3
471471
last_item = self._start + visible_items
472-
old_selection = self.__selection
473-
old_start = self._start
472+
# old_selection = self.__selection
473+
# old_start = self._start
474474
self.__selection += jump
475475
if jump >= 0:
476476
if self.__selection in self._headers:
@@ -648,8 +648,8 @@ def _go_default(self):
648648

649649
def _go_saved(self):
650650
self.load_default_or_saved_parameters = True
651-
old_theme = self._config_options['theme'][1]
652-
old_transparency = self._config_options['use_transparency'][1]
651+
# old_theme = self._config_options['theme'][1]
652+
# old_transparency = self._config_options['use_transparency'][1]
653653
self._config_options = deepcopy(self._saved_config_options)
654654
self._config_options['recording_dir'][1] = self._orig_redording_dir
655655
if self._cnf.use_themes:
@@ -1799,7 +1799,7 @@ def _list_to_dict(self):
17991799
self._working_params[a_params_set] = the_list[:]
18001800

18011801
def _get_width(self):
1802-
Y, X = self._win.getmaxyx()
1802+
_, X = self._win.getmaxyx()
18031803
self._width = X - self.startX - 2
18041804

18051805
def refresh_win(self, do_show=True):
@@ -2569,7 +2569,7 @@ def _set_startPos(self):
25692569
self.startPos = 0
25702570

25712571
def _resize(self, init=False):
2572-
col, row = self._selection_to_col_row(self.selection)
2572+
_, row = self._selection_to_col_row(self.selection)
25732573
if not (self.startPos <= row <= self.startPos + self.list_maxY - 1):
25742574
while row > self.startPos:
25752575
self.startPos += 1
@@ -2610,7 +2610,7 @@ def in_alias(a_list, a_string):
26102610
return -1
26112611

26122612
def _fix_startPos(self, direction=1):
2613-
col, row = self._selection_to_col_row(self.selection)
2613+
_, row = self._selection_to_col_row(self.selection)
26142614
startRow = self.startPos
26152615
endRow = self.startPos + self.list_maxY - 1
26162616
if not (startRow <= row <= endRow):

pyradio/edit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,9 @@ def _string_changed(self):
914914
if stripped_string.startswith(self._orig_path + sep):
915915
self._error_string = 'Invalid dir_path!!!'
916916
else:
917-
l = [x for x in self._invalid_chars if x in stripped_string]
917+
err_list = [x for x in self._invalid_chars if x in stripped_string]
918918
# logger.error('l = {}'.format(l))
919-
if l:
919+
if err_list:
920920
self._error_string = 'Invalid dir_path!!!'
921921
self._widgets[-2].enabled = False
922922
if stripped_string and self._error_string == '':
@@ -1347,9 +1347,9 @@ def _string_changed(self):
13471347
if w_file is None:
13481348
self._error_string = 'Invalid opener!!!'
13491349
else:
1350-
l = [x for x in self._invalid_chars if x in stripped_string]
1350+
err_list = [x for x in self._invalid_chars if x in stripped_string]
13511351
# logger.error('l = {}'.format(l))
1352-
if l:
1352+
if err_list:
13531353
self._error_string = 'Invalid opener!!!'
13541354
self._widgets[-2].enabled = False
13551355
if w_file and self._error_string == '':

pyradio/html_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _open_file(self, a_file, linux_resource_opener=None):
128128
if logger.isEnabledFor(logging.DEBUG):
129129
logger.debug('HtmlHelp: executing: "{}"'.format(cmd))
130130
try:
131-
p = subprocess.Popen(
131+
subprocess.Popen(
132132
cmd,
133133
shell=False,
134134
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)