From dc332980e52ebf519f289aa2feeda6719ab29f41 Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Mon, 18 Nov 2024 04:14:05 -0500 Subject: [PATCH] Reduce the max line length from 220 to 160 by wrapping some lines This will make it easier to auto-format import sections. --- .flake8 | 2 +- CONTRIBUTING.md | 2 +- archinstall/__init__.py | 20 +++++++++++-------- .../default_profiles/applications/pipewire.py | 10 ++++++++-- archinstall/lib/installer.py | 3 ++- archinstall/lib/interactions/general_conf.py | 5 ++++- archinstall/lib/mirrors.py | 3 ++- archinstall/lib/packages/packages.py | 4 +++- pyproject.toml | 4 ++-- 9 files changed, 35 insertions(+), 18 deletions(-) diff --git a/.flake8 b/.flake8 index 0dab6675a6..ea30850a2b 100644 --- a/.flake8 +++ b/.flake8 @@ -3,7 +3,7 @@ count = True # Several of the following could be autofixed or improved by running the code through psf/black ignore = E722,W191,W503 max-complexity = 40 -max-line-length = 220 +max-line-length = 160 show-source = True statistics = True builtins = _ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 39bec473c9..49f915f55d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ The exceptions to PEP8 are: * Archinstall uses [tabs instead of spaces](https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces) simply to make it easier for non-IDE developers to navigate the code *(Tab display-width should be equal to 4 spaces)*. Exception to the rule are comments that need fine-tuned indentation for documentation purposes. -* [Line length](https://www.python.org/dev/peps/pep-0008/#maximum-line-length) a maximum line length is enforced via flake8 with 220 characters +* [Line length](https://www.python.org/dev/peps/pep-0008/#maximum-line-length) a maximum line length is enforced via flake8 with 160 characters * Archinstall should always be saved with **Unix-formatted line endings** and no other platform-specific formats. * [String quotes](https://www.python.org/dev/peps/pep-0008/#string-quotes) follow PEP8, the exception being when creating formatted strings, double-quoted strings are *preferred* but not required on the outer edges *( diff --git a/archinstall/__init__.py b/archinstall/__init__.py index e1b7147d84..b694fdf5b9 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -112,10 +112,11 @@ def parse_unspecified_argument_list(unknowns: list, multiple: bool = False, err: --argument (boolean as default) the optional parameters to the function alter a bit its behaviour: * multiple allows multivalued arguments, each value separated by whitespace. They're returned as a list - * error. If set any non correctly specified argument-value pair to raise an exception. Else, simply notifies the existence of a problem and continues processing. + * error. If set any non correctly specified argument-value pair to raise an exception. Else, simply notifies the + existence of a problem and continues processing. - To a certain extent, multiple and error are incompatible. In fact, the only error this routine can catch, as of now, is the event - argument value value ... + To a certain extent, multiple and error are incompatible. In fact, the only error this routine can catch, as of now, + is the event argument value value ... which isn't am error if multiple is specified """ tmp_list = [arg for arg in unknowns if arg != "="] # wastes a few bytes, but avoids any collateral effect of the destructive nature of the pop method() @@ -174,14 +175,17 @@ def get_arguments() -> dict[str, Any]: Is done on following steps: 0) we create a dict to store the arguments and their values 1) preprocess. - We take those arguments which use JSON files, and read them into the argument dict. So each first level entry becomes a argument on it's own right + We take those arguments which use JSON files, and read them into the argument dict. So each first level entry + becomes a argument on it's own right 2) Load. - We convert the predefined argument list directly into the dict via the vars() function. Non specified arguments are loaded with value None or false if they are booleans (action="store_true"). - The name is chosen according to argparse conventions. See above (the first text is used as argument name, but underscore substitutes dash) - We then load all the undefined arguments. In this case the names are taken as written. + We convert the predefined argument list directly into the dict via the vars() function. Non specified arguments + are loaded with value None or false if they are booleans (action="store_true"). The name is chosen according to + argparse conventions. See above (the first text is used as argument name, but underscore substitutes dash). We + then load all the undefined arguments. In this case the names are taken as written. Important. This way explicit command line arguments take precedence over configuration files. 3) Amend - Change whatever is needed on the configuration dictionary (it could be done in post_process_arguments but this ougth to be left to changes anywhere else in the code, not in the arguments dictionary + Change whatever is needed on the configuration dictionary (it could be done in post_process_arguments but this + ougth to be left to changes anywhere else in the code, not in the arguments dictionary """ config: dict[str, Any] = {} args, unknowns = parser.parse_known_args() diff --git a/archinstall/default_profiles/applications/pipewire.py b/archinstall/default_profiles/applications/pipewire.py index d0a1bcc4be..fd210fb2e4 100644 --- a/archinstall/default_profiles/applications/pipewire.py +++ b/archinstall/default_profiles/applications/pipewire.py @@ -44,8 +44,14 @@ def _enable_pipewire_for_all(self, install_session: 'Installer') -> None: install_session.arch_chroot(f'chown -R {user.username}:{user.username} /home/{user.username}') # symlink in the correct pipewire systemd items - install_session.arch_chroot(f'ln -s /usr/lib/systemd/user/pipewire-pulse.service /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.service', run_as=user.username) - install_session.arch_chroot(f'ln -s /usr/lib/systemd/user/pipewire-pulse.socket /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.socket', run_as=user.username) + install_session.arch_chroot( + f'ln -s /usr/lib/systemd/user/pipewire-pulse.service /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.service', + run_as=user.username + ) + install_session.arch_chroot( + f'ln -s /usr/lib/systemd/user/pipewire-pulse.socket /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.socket', + run_as=user.username + ) def install(self, install_session: 'Installer') -> None: super().install(install_session) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 3079f41699..71372fdc6d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -114,7 +114,8 @@ def __exit__(self, exc_type: type[BaseException] | None, exc_val, exc_tb: Traceb raise exc_val if not (missing_steps := self.post_install_check()): - log(f'Installation completed without any errors.\nLog files temporarily available at {storage["LOG_PATH"]}.\nYou may reboot when ready.\n', fg='green') + msg = f'Installation completed without any errors.\nLog files temporarily available at {storage["LOG_PATH"]}.\nYou may reboot when ready.\n' + log(msg, fg='green') self.sync_log_to_install_medium() return True else: diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py index 14fa3bf05b..ca08dbb0bd 100644 --- a/archinstall/lib/interactions/general_conf.py +++ b/archinstall/lib/interactions/general_conf.py @@ -21,7 +21,10 @@ def ask_ntp(preset: bool = True) -> bool: header = str(_('Would you like to use automatic time synchronization (NTP) with the default time servers?\n')) + '\n' - header += str(_('Hardware time and other post-configuration steps might be required in order for NTP to work.\nFor more information, please check the Arch wiki')) + '\n' + header += str(_( + 'Hardware time and other post-configuration steps might be required in order for NTP to work.\n' + 'For more information, please check the Arch wiki' + )) + '\n' preset_val = MenuItem.yes() if preset else MenuItem.no() group = MenuItemGroup.yes_no() diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index bbc071928e..ef7e7ff410 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -386,7 +386,8 @@ def _parse_remote_mirror_list(mirrorlist: str) -> dict[str, list[MirrorStatusEnt if any([ mirror.active is False, # Disabled by mirror-list admins mirror.last_sync is None, # Has not synced recently - # mirror.score (error rate) over time reported from backend: https://github.com/archlinux/archweb/blob/31333d3516c91db9a2f2d12260bd61656c011fd1/mirrors/utils.py#L111C22-L111C66 + # mirror.score (error rate) over time reported from backend: + # https://github.com/archlinux/archweb/blob/31333d3516c91db9a2f2d12260bd61656c011fd1/mirrors/utils.py#L111C22-L111C66 (mirror.score is None or mirror.score >= 100), ]): continue diff --git a/archinstall/lib/packages/packages.py b/archinstall/lib/packages/packages.py index 580d40f096..bd50f82819 100644 --- a/archinstall/lib/packages/packages.py +++ b/archinstall/lib/packages/packages.py @@ -113,4 +113,6 @@ def installed_package(package: str) -> LocalPackage: except SysCallError: pass - return LocalPackage({field.name: package_info.get(field.name) for field in dataclasses.fields(LocalPackage)}) # type: ignore # pylint: disable=no-value-for-parameter + return LocalPackage( # pylint: disable=no-value-for-parameter + {field.name: package_info.get(field.name) for field in dataclasses.fields(LocalPackage)} # type: ignore + ) diff --git a/pyproject.toml b/pyproject.toml index 8e7352c306..afacf2d330 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,7 +128,7 @@ py-version = "3.11" recursive = true [tool.pylint.format] -max-line-length = 220 +max-line-length = 160 [tool.pylint."messages control"] disable = [ @@ -163,7 +163,7 @@ additional-builtins = ["_"] [tool.ruff] target-version = "py311" builtins = ["_"] -line-length = 220 +line-length = 160 [tool.ruff.lint] select = [