Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply some fixes for flake8 #672

Merged
merged 13 commits into from
Jun 27, 2023
2 changes: 1 addition & 1 deletion chirp/chirp_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def format_freq(self):
def parse_freq(self, freqstr):
"""Set the frequency from a string"""
self.freq = parse_freq(freqstr)
return self.freqx
return self.freq
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes! Not sure this ever got used, but better that it's right. Looks like an errant typo on my part :(


def __str__(self):
if self.tmode == "Tone":
Expand Down
2 changes: 1 addition & 1 deletion chirp/drivers/alinco.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from chirp import chirp_common, bitwise, memmap, errors, directory, util
from chirp.settings import RadioSettingGroup, RadioSetting
from chirp.settings import RadioSettingValueBoolean, RadioSettings
from chirp.settings import RadioSettingValueBoolean


import time
Expand Down
7 changes: 3 additions & 4 deletions chirp/drivers/anytone778uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
from chirp import bitwise
from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList, \
RadioSettingValueString, RadioSettingValueInteger, \
RadioSettingValueFloat, RadioSettings, InvalidValueError
RadioSettingValueString, RadioSettings

import struct
import time
Expand Down Expand Up @@ -691,7 +690,7 @@ def get_features(self):
try:
rf.valid_bands = get_band_limits_Hz(
int(self._memobj.radio_settings.bandlimit))
except AttributeError as e:
except AttributeError:
# If we're asked without memory loaded, assume the most permissive
rf.valid_bands = get_band_limits_Hz(1)
except Exception as e:
Expand Down Expand Up @@ -1725,7 +1724,7 @@ def set_settings(self, settings):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
4 changes: 2 additions & 2 deletions chirp/drivers/anytone_ht.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString, \
RadioSettingValueFloat, InvalidValueError, RadioSettings
RadioSettings

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -938,7 +938,7 @@ def set_settings(self, settings):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
2 changes: 1 addition & 1 deletion chirp/drivers/anytone_iii.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString, \
RadioSettingValueFloat, InvalidValueError, RadioSettings
RadioSettingValueFloat, RadioSettings


class ATBankModel(chirp_common.BankModel):
Expand Down
6 changes: 3 additions & 3 deletions chirp/drivers/ap510.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def set_smartbeacon(self, d):
'TEMP1-1,WIDE 2-1',
'WIDE2-1',
]
TABLE = "/\#&0>AW^_acnsuvz"
TABLE = r"/\#&0>AW^_acnsuvz"
SYMBOL = "".join(map(chr, range(ord("!"), ord("~")+1)))
BEACON = ['manual', 'auto', 'auto + manual', 'smart', 'smart + manual']
ALIAS = ['WIDE1-N', 'WIDE2-N', 'WIDE1-N + WIDE2-N']
Expand Down Expand Up @@ -404,7 +404,7 @@ def sync_out(self):

def load_mmap(self, filename):
"""Load the radio's memory map from @filename"""
mapfile = file(filename, "rb")
mapfile = open(filename, "rb")
data = mapfile.read()
if data.startswith('\r\n00=%s 20141215' % self._model):
self._mmap = AP510Memory20141215(data)
Expand Down Expand Up @@ -753,7 +753,7 @@ def set_settings(self, settings):
multiple = self._mmap.multiple
multiple['tf_card'] = TF_CARD.index(str(setting.value))
self._mmap.multiple = multiple
except:
except Exception:
LOG.debug(setting.get_name())
raise

Expand Down
10 changes: 5 additions & 5 deletions chirp/drivers/baofeng_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import time
import struct
import logging
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp import chirp_common, memmap
from chirp import errors, util
from chirp import bandplan_na
from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList
Expand Down Expand Up @@ -366,7 +366,7 @@ def sync_out(self):
_upload(self)
except errors.RadioError:
raise
except Exception as e:
except Exception:
# If anything unexpected happens, make sure we raise
# a RadioError and log the problem
LOG.exception('Unexpected error during upload')
Expand Down Expand Up @@ -734,7 +734,7 @@ def set_settings(self, settings):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand All @@ -750,6 +750,6 @@ def _set_fm_preset(self, settings):
if self._bw_shift:
value = ((value & 0x00FF) << 8) | ((value & 0xFF00) >> 8)
self._memobj.fm_presets = value
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise
6 changes: 3 additions & 3 deletions chirp/drivers/baofeng_uv3r.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def uv3r_prep(radio):
for _i in range(0, 10):
try:
return _uv3r_prep(radio)
except errors.RadioError as e:
except errors.RadioError:
time.sleep(1)

raise e
Expand Down Expand Up @@ -623,7 +623,7 @@ def set_settings(self, settings):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand All @@ -639,7 +639,7 @@ def _set_fm_preset(self, settings):
LOG.debug("Setting fm_presets[%1i] = %s" % (index, value))
setting = self._memobj.fm_presets
setting[index] = value
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
5 changes: 2 additions & 3 deletions chirp/drivers/baofeng_wp970i.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
import logging

from chirp.drivers import baofeng_common
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp import bandplan_na
from chirp import chirp_common, directory
from chirp import bitwise
from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList, \
RadioSettingValueString, RadioSettingValueInteger, \
Expand Down
6 changes: 3 additions & 3 deletions chirp/drivers/bf_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from chirp import bitwise, errors, util
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueBoolean, RadioSettingValueList, \
RadioSettingValueInteger, RadioSettingValueString, \
RadioSettingValueFloat, RadioSettings
RadioSettingValueInteger, RadioSettingValueFloat, \
RadioSettings

import struct
import logging
Expand Down Expand Up @@ -904,7 +904,7 @@ def set_settings(self, uisettings):
setattr(_settings, name, value)

LOG.debug("Setting %s: %s" % (name, value))
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
17 changes: 1 addition & 16 deletions chirp/drivers/bf_t8.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
RadioSettingValueFloat,
RadioSettingValueInteger,
RadioSettingValueList,
RadioSettingValueString,
)

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -114,20 +113,6 @@
"CH11 - 162.000"
]

SETTING_LISTS = {
"ab": AB_LIST,
"abr": ABR_LIST,
"area": AREA_LIST,
"mdf": MDF_LIST,
"ring": RING_LIST,
"tot": TOT_LIST,
"tot": TOT2_LIST,
"voice": VOICE_LIST,
"vox": VOX_LIST,
"workmode": WORKMODE_LIST,
"wx": WX_LIST,
}

FRS_FREQS1 = [462562500, 462587500, 462612500, 462637500, 462662500,
462687500, 462712500]
FRS_FREQS2 = [467562500, 467587500, 467612500, 467637500, 467662500,
Expand Down Expand Up @@ -826,7 +811,7 @@ def set_settings(self, settings):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
4 changes: 0 additions & 4 deletions chirp/drivers/bj9900.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
"""Baojie BJ-9900 management module"""

from chirp import chirp_common, util, memmap, errors, directory, bitwise
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString, \
RadioSettings
import struct
import time
import logging
Expand Down
4 changes: 2 additions & 2 deletions chirp/drivers/bjuv55.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import logging

from chirp.drivers import uv5r
from chirp import chirp_common, errors, util, directory, memmap
from chirp import chirp_common, directory
from chirp import bitwise
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
Expand Down Expand Up @@ -643,6 +643,6 @@ def _set_fm_preset(self, settings):
value = int(val.get_value() * 10 - 870)
LOG.debug("Setting fm_preset = %s" % (value))
self._memobj.fm_preset = value
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise
4 changes: 2 additions & 2 deletions chirp/drivers/btech.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def _encode_tone(self, memval, mode, val, pol):
index += 0x6A
memval.set_value(index)
except:
msg = "Digital Tone '%d' is not supported" % value
msg = "Digital Tone '%d' is not supported" % val
LOG.error(msg)
raise errors.RadioError(msg)
else:
Expand Down Expand Up @@ -3120,7 +3120,7 @@ def set_settings(self, settings):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
6 changes: 3 additions & 3 deletions chirp/drivers/fd268.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def handle_warning(_settings, settings):
try:
element.run_apply_callback()
continue
except NotImplementedError as e:
except NotImplementedError:
raise

elif sett == "none":
Expand All @@ -776,11 +776,11 @@ def handle_warning(_settings, settings):
obj = getattr(_mem, sett)
setattr(obj, name, element.value)

except AttributeError as e:
except AttributeError:
m = "Setting %s is not in this setting block" % name
LOG.debug(m)

except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
11 changes: 2 additions & 9 deletions chirp/drivers/ft1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
_adms_ext = '.ft1d'

_SG_RE = re.compile(r"(?P<sign>[-+NESW]?)(?P<d>[\d]+)[\s\.,]*"
"(?P<m>[\d]*)[\s\']*(?P<s>[\d]*)")
r"(?P<m>[\d]*)[\s\']*(?P<s>[\d]*)")

_RX_BAUD = ("off", "1200 baud", "9600 baud")
_TX_DELAY = ("100ms", "150ms", "200ms", "250ms", "300ms",
Expand Down Expand Up @@ -2471,7 +2471,7 @@ def set_settings(self, settings):
except AttributeError as e:
LOG.error("Setting %s is not in the memory map: %s" %
(element.get_name(), e))
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down Expand Up @@ -2525,13 +2525,6 @@ def apply_WEhemi(cls, setting, obj):
hemi = ' '
setattr(obj, "WEhemi", hemi)

def apply_WEhemi(cls, setting, obj):
hemi = setting.value.get_value().upper()

if hemi != 'W' and hemi != 'E':
hemi = ' '
setattr(obj, "WEhemi", hemi)

def apply_bt_lat(cls, setting, obj):
val = setting.value.get_value()
val = cls.backtrack_zero_pad(val, 3)
Expand Down
2 changes: 1 addition & 1 deletion chirp/drivers/ft2900.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ def set_settings(self, uisettings):
setattr(_settings, name, value)

LOG.debug("Setting %s: %s" % (name, value))
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
6 changes: 3 additions & 3 deletions chirp/drivers/ft2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import logging

from chirp.drivers import yaesu_clone, ft1d
from chirp import chirp_common, directory, bitwise
from chirp.drivers import ft1d
from chirp import chirp_common, directory
from chirp import errors
from chirp import memmap
from chirp.settings import RadioSetting, RadioSettings
from chirp.settings import RadioSetting
from chirp.settings import RadioSettingValueString
from chirp import util

Expand Down
4 changes: 2 additions & 2 deletions chirp/drivers/ft450d.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString, \
RadioSettingValueFloat, RadioSettings
RadioSettings
import time
import struct
import logging
Expand Down Expand Up @@ -1486,6 +1486,6 @@ def set_settings(self, settings):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise
7 changes: 3 additions & 4 deletions chirp/drivers/ft60.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
from chirp.drivers import yaesu_clone
from chirp import chirp_common, memmap, bitwise, directory, errors
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString, \
RadioSettingValueFloat, RadioSettings
RadioSettingValueList, RadioSettingValueString, \
RadioSettings

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -717,7 +716,7 @@ def set_settings(self, uisettings):
setattr(_settings, name, value)

LOG.debug("Setting %s: %s" % (name, value))
except Exception as e:
except Exception:
LOG.debug(element.get_name())
raise

Expand Down
Loading