Skip to content

Commit c67ac97

Browse files
authored
Ruff formatting (#3459)
* Update * Update
1 parent f71e91c commit c67ac97

File tree

120 files changed

+3169
-3145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+3169
-3145
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
count = True
3-
ignore = W191,W503
3+
ignore = W191,W503,E704,E203
44
max-complexity = 40
55
max-line-length = 160
66
show-source = True

.github/workflows/ruff-format.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
on: [ push, pull_request ]
2+
name: ruff check formatting
3+
jobs:
4+
ruff_format_check:
5+
runs-on: ubuntu-latest
6+
container:
7+
image: archlinux/archlinux:latest
8+
steps:
9+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
10+
- uses: astral-sh/ruff-action@84f83ecf9e1e15d26b7984c7ec9cf73d39ffc946 # v3.3.1
11+
- run: ruff check --select=COM812 --fix
12+
- run: ruff format --diff
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
on: [ push, pull_request ]
2-
name: ruff linting
2+
name: ruff check linting
33
jobs:
44
ruff:
55
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
default_stages: ['pre-commit']
22
repos:
3-
- repo: https://github.com/pycqa/autoflake
4-
rev: v2.3.1
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.11.9
55
hooks:
6-
- id: autoflake
7-
args: [
8-
'--in-place',
9-
'--remove-all-unused-imports',
10-
'--ignore-init-module-imports'
11-
]
12-
files: \.py$
13-
require_serial: true
14-
fail_fast: true
6+
# fix unused imports and sort them
7+
- id: ruff
8+
args: ["--extend-select", "I", "--fix"]
9+
# format the code
10+
- id: ruff-format
11+
# run the linter
12+
- id: ruff
1513
- repo: https://github.com/pre-commit/pre-commit-hooks
1614
rev: v5.0.0
1715
hooks:
@@ -23,8 +21,6 @@ repos:
2321
- id: check-yaml # Attempts to load all yaml files to verify syntax
2422
- id: destroyed-symlinks # Detects symlinks which are changed to regular files
2523
- id: detect-private-key # Checks for the existence of private keys
26-
- id: end-of-file-fixer # Makes sure files end in a newline and only a newline
27-
- id: trailing-whitespace # Trims trailing whitespace
2824
# Python specific hooks:
2925
- id: check-ast # Simply check whether files parse as valid python
3026
- id: check-docstring-first # Checks for a common error of placing code before the docstring
@@ -47,13 +43,6 @@ repos:
4743
- pydantic
4844
- pytest
4945
- cryptography
50-
- repo: https://github.com/astral-sh/ruff-pre-commit
51-
rev: v0.11.9
52-
hooks:
53-
- id: ruff
54-
args: ["check", "--select", "I", "--fix"]
55-
fail_fast: true
56-
- id: ruff
5746
- repo: local
5847
hooks:
5948
- id: pylint

archinstall/__init__.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _fetch_arch_db() -> None:
4646
try:
4747
Pacman.run("-Sy")
4848
except Exception as e:
49-
debug(f'Failed to sync Arch Linux package database: {e}')
49+
debug(f"Failed to sync Arch Linux package database: {e}")
5050
exit(1)
5151

5252

@@ -57,10 +57,10 @@ def _check_new_version() -> None:
5757
try:
5858
upgrade = Pacman.run("-Qu archinstall").decode()
5959
except Exception as e:
60-
debug(f'Failed determine pacman version: {e}')
60+
debug(f"Failed determine pacman version: {e}")
6161

6262
if upgrade:
63-
text = f'New version available: {upgrade}'
63+
text = f"New version available: {upgrade}"
6464
info(text)
6565
time.sleep(3)
6666

@@ -71,7 +71,7 @@ def main() -> int:
7171
OR straight as a module: python -m archinstall
7272
In any case we will be attempting to load the provided script to be run from the scripts/ folder
7373
"""
74-
if '--help' in sys.argv or '-h' in sys.argv:
74+
if "--help" in sys.argv or "-h" in sys.argv:
7575
arch_config_handler.print_help()
7676
return 0
7777

@@ -89,7 +89,7 @@ def main() -> int:
8989

9090
script = arch_config_handler.args.script
9191

92-
mod_name = f'archinstall.scripts.{script}'
92+
mod_name = f"archinstall.scripts.{script}"
9393
# by loading the module we'll automatically run the script
9494
importlib.import_module(mod_name)
9595

@@ -109,13 +109,13 @@ def run_as_a_module() -> None:
109109
Tui.shutdown()
110110

111111
if exc:
112-
err = ''.join(traceback.format_exception(exc))
112+
err = "".join(traceback.format_exception(exc))
113113
error(err)
114114

115115
text = (
116-
'Archinstall experienced the above error. If you think this is a bug, please report it to\n'
116+
"Archinstall experienced the above error. If you think this is a bug, please report it to\n"
117117
'https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".\n\n'
118-
'Hint: To extract the log from a live ISO \ncurl -F\'file=@/var/log/archinstall/install.log\' https://0x0.st\n'
118+
"Hint: To extract the log from a live ISO \ncurl -F'file=@/var/log/archinstall/install.log' https://0x0.st\n"
119119
)
120120

121121
warn(text)
@@ -125,20 +125,20 @@ def run_as_a_module() -> None:
125125

126126

127127
__all__ = [
128-
'DeferredTranslation',
129-
'FormattedOutput',
130-
'Language',
131-
'Pacman',
132-
'SysInfo',
133-
'Tui',
134-
'arch_config_handler',
135-
'debug',
136-
'disk_layouts',
137-
'error',
138-
'info',
139-
'load_plugin',
140-
'log',
141-
'plugin',
142-
'translation_handler',
143-
'warn',
128+
"DeferredTranslation",
129+
"FormattedOutput",
130+
"Language",
131+
"Pacman",
132+
"SysInfo",
133+
"Tui",
134+
"arch_config_handler",
135+
"debug",
136+
"disk_layouts",
137+
"error",
138+
"info",
139+
"load_plugin",
140+
"log",
141+
"plugin",
142+
"translation_handler",
143+
"warn",
144144
]

archinstall/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import archinstall
22

3-
if __name__ == '__main__':
3+
if __name__ == "__main__":
44
archinstall.run_as_a_module()

archinstall/default_profiles/applications/pipewire.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99

1010
class PipewireProfile(Profile):
1111
def __init__(self) -> None:
12-
super().__init__('Pipewire', ProfileType.Application)
12+
super().__init__("Pipewire", ProfileType.Application)
1313

1414
@property
1515
@override
1616
def packages(self) -> list[str]:
1717
return [
18-
'pipewire',
19-
'pipewire-alsa',
20-
'pipewire-jack',
21-
'pipewire-pulse',
22-
'gst-plugin-pipewire',
23-
'libpulse',
24-
'wireplumber'
18+
"pipewire",
19+
"pipewire-alsa",
20+
"pipewire-jack",
21+
"pipewire-pulse",
22+
"gst-plugin-pipewire",
23+
"libpulse",
24+
"wireplumber",
2525
]
2626

27-
def _enable_pipewire_for_all(self, install_session: 'Installer') -> None:
27+
def _enable_pipewire_for_all(self, install_session: "Installer") -> None:
2828
from archinstall.lib.args import arch_config_handler
29+
2930
users: list[User] | None = arch_config_handler.config.users
3031

3132
if users is None:
@@ -37,20 +38,20 @@ def _enable_pipewire_for_all(self, install_session: 'Installer') -> None:
3738
service_dir.mkdir(parents=True, exist_ok=True)
3839

3940
# Set ownership of the entire user catalogue
40-
install_session.arch_chroot(f'chown -R {user.username}:{user.username} /home/{user.username}')
41+
install_session.arch_chroot(f"chown -R {user.username}:{user.username} /home/{user.username}")
4142

4243
# symlink in the correct pipewire systemd items
4344
install_session.arch_chroot(
44-
f'ln -sf /usr/lib/systemd/user/pipewire-pulse.service /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.service',
45-
run_as=user.username
45+
f"ln -sf /usr/lib/systemd/user/pipewire-pulse.service /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.service",
46+
run_as=user.username,
4647
)
4748
install_session.arch_chroot(
48-
f'ln -sf /usr/lib/systemd/user/pipewire-pulse.socket /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.socket',
49-
run_as=user.username
49+
f"ln -sf /usr/lib/systemd/user/pipewire-pulse.socket /home/{user.username}/.config/systemd/user/default.target.wants/pipewire-pulse.socket",
50+
run_as=user.username,
5051
)
5152

5253
@override
53-
def install(self, install_session: 'Installer') -> None:
54+
def install(self, install_session: "Installer") -> None:
5455
super().install(install_session)
5556
install_session.add_additional_packages(self.packages)
5657
self._enable_pipewire_for_all(install_session)

archinstall/default_profiles/desktop.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
class DesktopProfile(Profile):
1616
def __init__(self, current_selection: list[Profile] = []) -> None:
1717
super().__init__(
18-
'Desktop',
18+
"Desktop",
1919
ProfileType.Desktop,
2020
current_selection=current_selection,
21-
support_greeter=True
21+
support_greeter=True,
2222
)
2323

2424
@property
2525
@override
2626
def packages(self) -> list[str]:
2727
return [
28-
'nano',
29-
'vim',
30-
'openssh',
31-
'htop',
32-
'wget',
33-
'iwd',
34-
'wireless_tools',
35-
'wpa_supplicant',
36-
'smartmontools',
37-
'xdg-utils'
28+
"nano",
29+
"vim",
30+
"openssh",
31+
"htop",
32+
"wget",
33+
"iwd",
34+
"wireless_tools",
35+
"wpa_supplicant",
36+
"smartmontools",
37+
"xdg-utils",
3838
]
3939

4040
@property
@@ -61,8 +61,9 @@ def do_on_select(self) -> SelectResult:
6161
MenuItem(
6262
p.name,
6363
value=p,
64-
preview_action=lambda x: x.value.preview_text()
65-
) for p in profile_handler.get_desktop_profiles()
64+
preview_action=lambda x: x.value.preview_text(),
65+
)
66+
for p in profile_handler.get_desktop_profiles()
6667
]
6768

6869
group = MenuItemGroup(items, sort_items=True, sort_case_sensitive=False)
@@ -74,8 +75,8 @@ def do_on_select(self) -> SelectResult:
7475
allow_reset=True,
7576
allow_skip=True,
7677
preview_style=PreviewStyle.RIGHT,
77-
preview_size='auto',
78-
preview_frame=FrameProperties.max('Info')
78+
preview_size="auto",
79+
preview_frame=FrameProperties.max("Info"),
7980
).run()
8081

8182
match result.type_:
@@ -89,17 +90,17 @@ def do_on_select(self) -> SelectResult:
8990
return SelectResult.ResetCurrent
9091

9192
@override
92-
def post_install(self, install_session: 'Installer') -> None:
93+
def post_install(self, install_session: "Installer") -> None:
9394
for profile in self.current_selection:
9495
profile.post_install(install_session)
9596

9697
@override
97-
def install(self, install_session: 'Installer') -> None:
98+
def install(self, install_session: "Installer") -> None:
9899
# Install common packages for all desktop environments
99100
install_session.add_additional_packages(self.packages)
100101

101102
for profile in self.current_selection:
102-
info(f'Installing profile {profile.name}...')
103+
info(f"Installing profile {profile.name}...")
103104

104105
install_session.add_additional_packages(profile.packages)
105106
install_session.enable_service(profile.services)

archinstall/default_profiles/desktops/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
class SeatAccess(Enum):
5-
seatd = 'seatd'
6-
polkit = 'polkit'
5+
seatd = "seatd"
6+
polkit = "polkit"

0 commit comments

Comments
 (0)