Skip to content

Commit

Permalink
Reduce the max line length from 220 to 160 by wrapping some lines (#2867
Browse files Browse the repository at this point in the history
)

This will make it easier to auto-format import sections.
  • Loading branch information
correctmost authored Nov 18, 2024
1 parent 8942591 commit 7776f82
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -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 = _
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 *(
Expand Down
20 changes: 12 additions & 8 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions archinstall/default_profiles/applications/pipewire.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion archinstall/lib/interactions/general_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion archinstall/lib/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion archinstall/lib/packages/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -163,7 +163,7 @@ additional-builtins = ["_"]
[tool.ruff]
target-version = "py311"
builtins = ["_"]
line-length = 220
line-length = 160

[tool.ruff.lint]
select = [
Expand Down

0 comments on commit 7776f82

Please sign in to comment.