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]
|
[flake8]
|
||||||
count = True
|
count = True
|
||||||
# Several of the following could be autofixed or improved by running the code through psf/black
|
# 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-complexity = 40
|
||||||
max-line-length = 220
|
max-line-length = 220
|
||||||
show-source = True
|
show-source = True
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
on: [ push, pull_request ]
|
on: [ push, pull_request ]
|
||||||
name: flake8 linting (7 ignores)
|
name: flake8 linting (6 ignores)
|
||||||
jobs:
|
jobs:
|
||||||
flake8:
|
flake8:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ def _check_new_version() -> None:
|
||||||
Pacman.run("-Sy")
|
Pacman.run("-Sy")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug(f'Failed to perform version check: {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)
|
exit(1)
|
||||||
|
|
||||||
upgrade = None
|
upgrade = None
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ class DeviceHandler(object):
|
||||||
|
|
||||||
for report in reports['report']:
|
for report in reports['report']:
|
||||||
if len(report[info_type]) != 1:
|
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]
|
entry = report[info_type][0]
|
||||||
|
|
||||||
|
|
@ -334,12 +334,12 @@ class DeviceHandler(object):
|
||||||
return LvmVolumeInfo(
|
return LvmVolumeInfo(
|
||||||
lv_name=entry['lv_name'],
|
lv_name=entry['lv_name'],
|
||||||
vg_name=entry['vg_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':
|
case 'vg':
|
||||||
return LvmGroupInfo(
|
return LvmGroupInfo(
|
||||||
vg_uuid=entry['vg_uuid'],
|
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
|
return None
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class Fido2:
|
||||||
worker.write(bytes(password, 'UTF-8'))
|
worker.write(bytes(password, 'UTF-8'))
|
||||||
pw_inputted = True
|
pw_inputted = True
|
||||||
elif pin_inputted is False:
|
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'))
|
worker.write(bytes(getpass.getpass(" "), 'UTF-8'))
|
||||||
pin_inputted = True
|
pin_inputted = True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -382,7 +382,7 @@ class SysCommand:
|
||||||
|
|
||||||
def __getitem__(self, key: slice) -> Optional[bytes]:
|
def __getitem__(self, key: slice) -> Optional[bytes]:
|
||||||
if not self.session:
|
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:
|
elif type(key) is slice:
|
||||||
start = key.start or 0
|
start = key.start or 0
|
||||||
end = key.stop or len(self.session._trace_log)
|
end = key.stop or len(self.session._trace_log)
|
||||||
|
|
|
||||||
|
|
@ -242,12 +242,12 @@ class SysInfo:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sys_vendor() -> str:
|
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()
|
return vendor.read().strip()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def product_name() -> str:
|
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()
|
return product.read().strip()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ class Installer:
|
||||||
fp.write(gen_fstab)
|
fp.write(gen_fstab)
|
||||||
|
|
||||||
if not fstab_path.is_file():
|
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():
|
for plugin in plugins.values():
|
||||||
if hasattr(plugin, 'on_genfstab'):
|
if hasattr(plugin, 'on_genfstab'):
|
||||||
|
|
@ -893,7 +893,7 @@ class Installer:
|
||||||
|
|
||||||
def setup_swap(self, kind: str = 'zram') -> None:
|
def setup_swap(self, kind: str = 'zram') -> None:
|
||||||
if kind == 'zram':
|
if kind == 'zram':
|
||||||
info(f"Setting up swap on zram")
|
info("Setting up swap on zram")
|
||||||
self.pacman.strap('zram-generator')
|
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
|
# 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
|
self._zram_enabled = True
|
||||||
else:
|
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]:
|
def _get_efi_partition(self) -> Optional[disk.PartitionModification]:
|
||||||
for layout in self._disk_config.device_modifications:
|
for layout in self._disk_config.device_modifications:
|
||||||
|
|
@ -1307,7 +1307,7 @@ Exec = /bin/sh -c "{hook_command}"
|
||||||
for kernel in self.kernels:
|
for kernel in self.kernels:
|
||||||
for variant in ('', '-fallback'):
|
for variant in ('', '-fallback'):
|
||||||
entry = [
|
entry = [
|
||||||
f'protocol: linux',
|
'protocol: linux',
|
||||||
f'kernel_path: boot():/vmlinuz-{kernel}',
|
f'kernel_path: boot():/vmlinuz-{kernel}',
|
||||||
f'kernel_cmdline: {kernel_params}',
|
f'kernel_cmdline: {kernel_params}',
|
||||||
f'module_path: boot():/initramfs-{kernel}{variant}.img',
|
f'module_path: boot():/initramfs-{kernel}{variant}.img',
|
||||||
|
|
@ -1620,7 +1620,7 @@ Exec = /bin/sh -c "{hook_command}"
|
||||||
except SysCallError as err:
|
except SysCallError as err:
|
||||||
raise ServiceException(f"Unable to set locale '{language}' for X11: {err}")
|
raise ServiceException(f"Unable to set locale '{language}' for X11: {err}")
|
||||||
else:
|
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
|
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]:
|
def add_number_of_parallel_downloads(input_number: Optional[int] = None) -> Optional[int]:
|
||||||
max_recommended = 5
|
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(_("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(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"))
|
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
|
self._speed = size / timer.time
|
||||||
debug(f" speed: {self._speed} ({int(self._speed / 1024 / 1024 * 100) / 100}MiB/s)")
|
debug(f" speed: {self._speed} ({int(self._speed / 1024 / 1024 * 100) / 100}MiB/s)")
|
||||||
except http.client.IncompleteRead:
|
except http.client.IncompleteRead:
|
||||||
debug(f" speed: <undetermined>")
|
debug(" speed: <undetermined>")
|
||||||
self._speed = 0
|
self._speed = 0
|
||||||
except urllib.error.URLError as error:
|
except urllib.error.URLError as error:
|
||||||
debug(f" speed: <undetermined> ({error})")
|
debug(f" speed: <undetermined> ({error})")
|
||||||
|
|
@ -101,4 +101,4 @@ class MirrorStatusListV3(pydantic.BaseModel):
|
||||||
if data.get('version') == 3:
|
if data.get('version') == 3:
|
||||||
return data
|
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