Skip to content

Commit

Permalink
Fix unnecessary f-strings and enable flake8 rule (#2653)
Browse files Browse the repository at this point in the history
  • Loading branch information
correctmost authored Aug 28, 2024
1 parent 62b4099 commit 35c8eb3
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on: [ push, pull_request ]
name: flake8 linting (7 ignores)
name: flake8 linting (6 ignores)
jobs:
flake8:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _lvm_info(

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]

Expand All @@ -334,12 +334,12 @@ def _lvm_info(
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
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/disk/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def fido2_enroll(
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

Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __iter__(self, *args: List[Any], **kwargs: Dict[str, Any]) -> Iterator[bytes

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)
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ def cpu_model() -> Optional[str]:

@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
Expand Down
10 changes: 5 additions & 5 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def genfstab(self, flags: str = '-pU') -> None:
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'):
Expand Down Expand Up @@ -893,7 +893,7 @@ def minimal_installation(

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
Expand All @@ -906,7 +906,7 @@ def setup_swap(self, kind: str = 'zram') -> None:

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:
Expand Down Expand Up @@ -1307,7 +1307,7 @@ def _add_limine_bootloader(
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',
Expand Down Expand Up @@ -1620,7 +1620,7 @@ def set_x11_keyboard_language(self, language: str) -> bool:
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

Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/interactions/general_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def read_packages(p: 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"))
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/models/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def speed(self) -> float | None:
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})")
Expand Down Expand Up @@ -101,4 +101,4 @@ def check_model(cls, data: Dict[str, int | datetime.datetime | List[MirrorStatus
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/")

0 comments on commit 35c8eb3

Please sign in to comment.