Skip to content

Commit 30113cf

Browse files
authored
Merge branch 'fdev31:main' into main
2 parents 13adfb4 + fd34db7 commit 30113cf

File tree

9 files changed

+233
-195
lines changed

9 files changed

+233
-195
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ repos:
1313
hooks:
1414
- id: prettier
1515
exclude: "main.*"
16-
- repo: https://github.com/ambv/black
17-
rev: "23.3.0"
18-
hooks:
19-
- id: black
2016
- repo: https://github.com/lovesegfault/beautysh
2117
rev: "v6.2.1"
2218
hooks:
@@ -25,3 +21,17 @@ repos:
2521
rev: "v1.30.0"
2622
hooks:
2723
- id: yamllint
24+
- repo: https://github.com/PyCQA/flake8
25+
rev: 7.0.0
26+
hooks:
27+
- id: flake8
28+
args: [--max-line-length=140]
29+
- repo: https://github.com/astral-sh/ruff-pre-commit
30+
# Ruff version.
31+
rev: "v0.4.4"
32+
hooks:
33+
# Run the linter.
34+
- id: ruff
35+
args: [--fix]
36+
# Run the formatter.
37+
- id: ruff-format

pyproject.toml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,85 @@ black = "^23.3.0"
2626
[build-system]
2727
requires = ["poetry-core"]
2828
build-backend = "poetry.core.masonry.api"
29+
30+
[tool.ruff]
31+
line-length = 140
32+
preview = true
33+
34+
exclude = ["*_v?.py", "tests", "scripts", "sample_extension", ".git"]
35+
36+
37+
[tool.ruff.lint]
38+
fixable = ["ALL"]
39+
select = [
40+
# pycodestyle
41+
"E", # error
42+
"W", # warn
43+
# builtins
44+
"A",
45+
# bugbear
46+
"B",
47+
# comprehensions
48+
"C",
49+
# err msg
50+
"EM",
51+
# str concat
52+
"ISC",
53+
# import conventions
54+
"ICN",
55+
# flake8 log
56+
"G",
57+
"LOG",
58+
# pep8 naming
59+
"D",
60+
# pydocstyle
61+
"D",
62+
# mccabe
63+
"C",
64+
# Pyflakes
65+
"F",
66+
# pyupgrade
67+
"UP",
68+
# flake8-bugbear
69+
"B",
70+
# flake8-simplify
71+
"SIM",
72+
# isort
73+
"I",
74+
# flake-2020
75+
"YTT",
76+
# flake-annotations
77+
"ANN",
78+
# flake-async
79+
"ASYNC",
80+
# flake-blind-except
81+
"BLE",
82+
# flake-boolean-trap
83+
"FBT",
84+
# pytest
85+
"PT",
86+
# self
87+
"SLF",
88+
# tidy-imports
89+
"TID",
90+
# type checking
91+
"TCH",
92+
# unused arg
93+
"ARG",
94+
# pathlib
95+
"PTH",
96+
# pylint
97+
"PL",
98+
# perflnt
99+
"PERF",
100+
# ruf
101+
"RUF",
102+
]
103+
ignore = ["ANN201", "ANN001", "ANN002", "ANN202", "ARG002", "PLR", "C", "FBT002", "D107", "ANN204", "D"]
104+
105+
[tool.ruff.format]
106+
indent-style = "space"
107+
line-ending = "auto"
108+
109+
[tool.ruff.lint.pydocstyle]
110+
convention = "google"

src/wlr_layout_ui/__init__.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def main():
4949
profiles = load_profiles()
5050
if sys.argv[1] == "-l":
5151
print("")
52-
for p in profiles.keys():
52+
for p in profiles:
5353
print(f" - {p}")
5454
elif sys.argv[1] == "-m":
5555
load()
@@ -80,40 +80,18 @@ def main():
8080
try:
8181
profile = profiles[sys.argv[1]]
8282
except KeyError:
83-
print("No such profile: %s" % sys.argv[1])
83+
print(f"No such profile: {sys.argv[1]}")
8484
raise SystemExit(1)
8585
apply_profile(profile)
8686
sys.exit(0)
8787
load()
88-
max_width = int(
89-
sum(
90-
max(screen.available, key=lambda mode: mode.width).width
91-
for screen in displayInfo
92-
)
93-
// UI_RATIO
94-
)
95-
max_height = int(
96-
sum(
97-
max(screen.available, key=lambda mode: mode.height).height
98-
for screen in displayInfo
99-
)
100-
// UI_RATIO
101-
)
88+
max_width = int(sum(max(screen.available, key=lambda mode: mode.width).width for screen in displayInfo) // UI_RATIO)
89+
max_height = int(sum(max(screen.available, key=lambda mode: mode.height).height for screen in displayInfo) // UI_RATIO)
10290
average_width = int(
103-
sum(
104-
max(screen.available, key=lambda mode: mode.width).width
105-
for screen in displayInfo
106-
)
107-
/ len(displayInfo)
108-
// UI_RATIO
91+
sum(max(screen.available, key=lambda mode: mode.width).width for screen in displayInfo) / len(displayInfo) // UI_RATIO
10992
)
11093
average_height = int(
111-
sum(
112-
max(screen.available, key=lambda mode: mode.height).height
113-
for screen in displayInfo
114-
)
115-
/ len(displayInfo)
116-
// UI_RATIO
94+
sum(max(screen.available, key=lambda mode: mode.height).height for screen in displayInfo) / len(displayInfo) // UI_RATIO
11795
)
11896

11997
width = max_width + average_width * 2

src/wlr_layout_ui/displaywidget.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Screen widgets for the display manager."""
2+
13
import random
24

35
from pyglet.shapes import BorderedRectangle
@@ -11,14 +13,17 @@
1113

1214

1315
def limit_size(text):
16+
"""Limit the size of the text to 15 characters."""
1417
if len(text) > 15:
1518
return text[:12] + "..."
1619
return text
1720

1821

1922
class GuiScreen(Widget):
23+
"""A widget representing a screen."""
24+
2025
def __repr__(self):
21-
return "<Screen %s (%s) - %s>" % (self.rect, self.color, self.screen.name)
26+
return f"<Screen {self.rect} ({self.color}) - {self.screen.name}>"
2227

2328
__str__ = __repr__
2429

@@ -56,7 +61,7 @@ def genColor(self):
5661
255,
5762
)
5863
else:
59-
self.color = list(self.all_colors[self.cur_color]) + [255]
64+
self.color = [*list(self.all_colors[self.cur_color]), 255]
6065
GuiScreen.cur_color += 1
6166
self.drag_color = list(self.color)
6267
self.drag_color[-1] = 200

src/wlr_layout_ui/factories.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ def makeRectangle(x, y, w, h, color):
1515

1616

1717
@cache
18-
def makeLabel(text, x, y, color=[0, 0, 0], **kw):
18+
def makeLabel(text, x, y, color=None, **kw):
19+
if color is None:
20+
color = [0, 0, 0]
1921
return Label(text, x=x, y=y, color=color, **kw)

0 commit comments

Comments
 (0)