Fix unnecessary f-strings and enable flake8 rule (#2653)
This commit is contained in:
parent
62b4099c8d
commit
35c8eb3394
2
.flake8
2
.flake8
|
|
@ -1,7 +1,7 @@
|
|||
[flake8]
|
||||
count = True
|
||||
# Several of the following could be autofixed or improved by running the code through psf/black
|
||||
ignore = E123,E128,E722,F541,W191,W503,W504
|
||||
ignore = E123,E128,E722,W191,W503,W504
|
||||
max-complexity = 40
|
||||
max-line-length = 220
|
||||
show-source = True
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
on: [ push, pull_request ]
|
||||
name: flake8 linting (7 ignores)
|
||||
name: flake8 linting (6 ignores)
|
||||
jobs:
|
||||
flake8:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ def _check_new_version() -> None:
|
|||
Pacman.run("-Sy")
|
||||
except Exception as e:
|
||||
debug(f'Failed to perform version check: {e}')
|
||||
info(f'Arch Linux mirrors are not reachable. Please check your internet connection')
|
||||
info('Arch Linux mirrors are not reachable. Please check your internet connection')
|
||||
exit(1)
|
||||
|
||||
upgrade = None
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ class DeviceHandler(object):
|
|||
|
||||
for report in reports['report']:
|
||||
if len(report[info_type]) != 1:
|
||||
raise ValueError(f'Report does not contain any entry')
|
||||
raise ValueError('Report does not contain any entry')
|
||||
|
||||
entry = report[info_type][0]
|
||||
|
||||
|
|
@ -334,12 +334,12 @@ class DeviceHandler(object):
|
|||
return LvmVolumeInfo(
|
||||
lv_name=entry['lv_name'],
|
||||
vg_name=entry['vg_name'],
|
||||
lv_size=Size(int(entry[f'lv_size'][:-1]), Unit.B, SectorSize.default())
|
||||
lv_size=Size(int(entry['lv_size'][:-1]), Unit.B, SectorSize.default())
|
||||
)
|
||||
case 'vg':
|
||||
return LvmGroupInfo(
|
||||
vg_uuid=entry['vg_uuid'],
|
||||
vg_size=Size(int(entry[f'vg_size'][:-1]), Unit.B, SectorSize.default())
|
||||
vg_size=Size(int(entry['vg_size'][:-1]), Unit.B, SectorSize.default())
|
||||
)
|
||||
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class Fido2:
|
|||
worker.write(bytes(password, 'UTF-8'))
|
||||
pw_inputted = True
|
||||
elif pin_inputted is False:
|
||||
if bytes(f"please enter security token pin", 'UTF-8') in worker._trace_log.lower():
|
||||
if bytes("please enter security token pin", 'UTF-8') in worker._trace_log.lower():
|
||||
worker.write(bytes(getpass.getpass(" "), 'UTF-8'))
|
||||
pin_inputted = True
|
||||
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ class SysCommand:
|
|||
|
||||
def __getitem__(self, key: slice) -> Optional[bytes]:
|
||||
if not self.session:
|
||||
raise KeyError(f"SysCommand() does not have an active session.")
|
||||
raise KeyError("SysCommand() does not have an active session.")
|
||||
elif type(key) is slice:
|
||||
start = key.start or 0
|
||||
end = key.stop or len(self.session._trace_log)
|
||||
|
|
|
|||
|
|
@ -242,12 +242,12 @@ class SysInfo:
|
|||
|
||||
@staticmethod
|
||||
def sys_vendor() -> str:
|
||||
with open(f"/sys/devices/virtual/dmi/id/sys_vendor") as vendor:
|
||||
with open("/sys/devices/virtual/dmi/id/sys_vendor") as vendor:
|
||||
return vendor.read().strip()
|
||||
|
||||
@staticmethod
|
||||
def product_name() -> str:
|
||||
with open(f"/sys/devices/virtual/dmi/id/product_name") as product:
|
||||
with open("/sys/devices/virtual/dmi/id/product_name") as product:
|
||||
return product.read().strip()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ class Installer:
|
|||
fp.write(gen_fstab)
|
||||
|
||||
if not fstab_path.is_file():
|
||||
raise RequirementError(f'Could not create fstab file')
|
||||
raise RequirementError('Could not create fstab file')
|
||||
|
||||
for plugin in plugins.values():
|
||||
if hasattr(plugin, 'on_genfstab'):
|
||||
|
|
@ -893,7 +893,7 @@ class Installer:
|
|||
|
||||
def setup_swap(self, kind: str = 'zram') -> None:
|
||||
if kind == 'zram':
|
||||
info(f"Setting up swap on zram")
|
||||
info("Setting up swap on zram")
|
||||
self.pacman.strap('zram-generator')
|
||||
|
||||
# We could use the default example below, but maybe not the best idea: https://github.com/archlinux/archinstall/pull/678#issuecomment-962124813
|
||||
|
|
@ -906,7 +906,7 @@ class Installer:
|
|||
|
||||
self._zram_enabled = True
|
||||
else:
|
||||
raise ValueError(f"Archinstall currently only supports setting up swap on zram")
|
||||
raise ValueError("Archinstall currently only supports setting up swap on zram")
|
||||
|
||||
def _get_efi_partition(self) -> Optional[disk.PartitionModification]:
|
||||
for layout in self._disk_config.device_modifications:
|
||||
|
|
@ -1307,7 +1307,7 @@ Exec = /bin/sh -c "{hook_command}"
|
|||
for kernel in self.kernels:
|
||||
for variant in ('', '-fallback'):
|
||||
entry = [
|
||||
f'protocol: linux',
|
||||
'protocol: linux',
|
||||
f'kernel_path: boot():/vmlinuz-{kernel}',
|
||||
f'kernel_cmdline: {kernel_params}',
|
||||
f'module_path: boot():/initramfs-{kernel}{variant}.img',
|
||||
|
|
@ -1620,7 +1620,7 @@ Exec = /bin/sh -c "{hook_command}"
|
|||
except SysCallError as err:
|
||||
raise ServiceException(f"Unable to set locale '{language}' for X11: {err}")
|
||||
else:
|
||||
info(f'X11-Keyboard language was not changed from default (no language specified)')
|
||||
info('X11-Keyboard language was not changed from default (no language specified)')
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ def ask_additional_packages_to_install(preset: List[str] = []) -> List[str]:
|
|||
|
||||
def add_number_of_parallel_downloads(input_number: Optional[int] = None) -> Optional[int]:
|
||||
max_recommended = 5
|
||||
print(_(f"This option enables the number of parallel downloads that can occur during package downloads"))
|
||||
print(_("This option enables the number of parallel downloads that can occur during package downloads"))
|
||||
print(_("Enter the number of parallel downloads to be enabled.\n\nNote:\n"))
|
||||
print(str(_(" - Maximum recommended value : {} ( Allows {} parallel downloads at a time )")).format(max_recommended, max_recommended))
|
||||
print(_(" - Disable/Default : 0 ( Disables parallel downloading, allows only 1 download at a time )\n"))
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class MirrorStatusEntryV3(pydantic.BaseModel):
|
|||
self._speed = size / timer.time
|
||||
debug(f" speed: {self._speed} ({int(self._speed / 1024 / 1024 * 100) / 100}MiB/s)")
|
||||
except http.client.IncompleteRead:
|
||||
debug(f" speed: <undetermined>")
|
||||
debug(" speed: <undetermined>")
|
||||
self._speed = 0
|
||||
except urllib.error.URLError as error:
|
||||
debug(f" speed: <undetermined> ({error})")
|
||||
|
|
@ -101,4 +101,4 @@ class MirrorStatusListV3(pydantic.BaseModel):
|
|||
if data.get('version') == 3:
|
||||
return data
|
||||
|
||||
raise ValueError(f"MirrorStatusListV3 only accepts version 3 data from https://archlinux.org/mirrors/status/json/")
|
||||
raise ValueError("MirrorStatusListV3 only accepts version 3 data from https://archlinux.org/mirrors/status/json/")
|
||||
|
|
|
|||
Loading…
Reference in New Issue