Skip to content

Commit eab30c3

Browse files
committed
add ruff format
1 parent e8b9edc commit eab30c3

4 files changed

Lines changed: 98 additions & 25 deletions

File tree

publish.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ def create_release():
113113

114114
# Create GitHub release using gh CLI
115115
# The release notes will be auto-generated from commits
116-
release_cmd = (
117-
f'gh release create {tag} --title "Release {version}" --generate-notes'
118-
)
116+
release_cmd = f'gh release create {tag} --title "Release {version}" --generate-notes'
119117
run_command(release_cmd)
120118

121119
print(f"GitHub Release {version} created successfully!")

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,58 @@ dev = [
4949
"pytest>=9.0.2",
5050
"pytest-asyncio>=1.3.0",
5151
]
52+
53+
[tool.ruff]
54+
# Set the target Python version
55+
target-version = "py37"
56+
57+
# Set line length
58+
line-length = 120
59+
60+
# Enable auto-fixing
61+
fix = true
62+
63+
# Exclude common directories
64+
exclude = [
65+
".git",
66+
".venv",
67+
"venv",
68+
"__pycache__",
69+
"build",
70+
"dist",
71+
"*.egg-info",
72+
]
73+
74+
[tool.ruff.lint]
75+
# Enable specific rule sets
76+
select = [
77+
"E", # pycodestyle errors
78+
"W", # pycodestyle warnings
79+
"F", # pyflakes
80+
"I", # isort
81+
"N", # pep8-naming
82+
"UP", # pyupgrade
83+
"B", # flake8-bugbear
84+
"C4", # flake8-comprehensions
85+
"SIM", # flake8-simplify
86+
]
87+
88+
# Ignore specific rules if needed
89+
ignore = [
90+
"E501", # line too long (handled by formatter)
91+
]
92+
93+
[tool.ruff.lint.isort]
94+
known-first-party = ["llms"]
95+
96+
[tool.ruff.lint.per-file-ignores]
97+
# Ignore all errors in publish.py and test_package.py
98+
"publish.py" = ["ALL"]
99+
"test_package.py" = ["ALL"]
100+
101+
[tool.ruff.format]
102+
# Use double quotes for strings
103+
quote-style = "double"
104+
105+
# Indent with spaces
106+
indent-style = "space"

scripts/omarchy_themes.py

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,25 @@
1313

1414
LIGHT_THEMES = [
1515
# themes
16-
"Kanagawa","Flexoki Light", "Rose Pine", "Catppuccin Latte",
16+
"Kanagawa",
17+
"Flexoki Light",
18+
"Rose Pine",
19+
"Catppuccin Latte",
1720
# extra themes
18-
"Bauhaus", "Black Arch", "Bliss", "The Greek", "Gruvu", "Map Quest", "Milky Matcha", "Rose of Dune", "Snow",
19-
"Solarized Light", "White Gold"
21+
"Bauhaus",
22+
"Black Arch",
23+
"Bliss",
24+
"The Greek",
25+
"Gruvu",
26+
"Map Quest",
27+
"Milky Matcha",
28+
"Rose of Dune",
29+
"Snow",
30+
"Solarized Light",
31+
"White Gold",
2032
]
2133

34+
2235
def fetch_html(url: str) -> str:
2336
"""Fetch HTML content from URL."""
2437
with urllib.request.urlopen(url) as response:
@@ -31,11 +44,11 @@ def extract_themes_section(html: str) -> str:
3144
if not start_match:
3245
raise ValueError("Could not find 'themes' section")
3346

34-
end_match = re.search(r'</main>', html[start_match.start():])
47+
end_match = re.search(r"</main>", html[start_match.start() :])
3548
if not end_match:
3649
raise ValueError("Could not find </main> tag")
3750

38-
return html[start_match.start():start_match.start() + end_match.start()]
51+
return html[start_match.start() : start_match.start() + end_match.start()]
3952

4053

4154
def parse_themes(html_section: str) -> list[dict]:
@@ -47,8 +60,8 @@ def parse_themes(html_section: str) -> list[dict]:
4760
# <em>Tokyo Night</em></p>
4861
pattern = re.compile(
4962
r'<p>.*?<img\s+src="([^"]+)"[^>]*>.*?'
50-
r'<em>([^<]+)</em></p>',
51-
re.DOTALL
63+
r"<em>([^<]+)</em></p>",
64+
re.DOTALL,
5265
)
5366

5467
for match in pattern.finditer(html_section):
@@ -58,11 +71,13 @@ def parse_themes(html_section: str) -> list[dict]:
5871
if preview_url.startswith("/"):
5972
preview_url = BASE_URL + preview_url
6073
name = name.strip()
61-
themes.append({
62-
"name": name,
63-
"scheme": "Dark" if name not in LIGHT_THEMES else "Light",
64-
"preview_url": preview_url
65-
})
74+
themes.append(
75+
{
76+
"name": name,
77+
"scheme": "Dark" if name not in LIGHT_THEMES else "Light",
78+
"preview_url": preview_url,
79+
}
80+
)
6681

6782
return themes
6883

@@ -73,11 +88,11 @@ def extract_extra_themes_section(html: str) -> str:
7388
if not start_match:
7489
raise ValueError("Could not find 'extra-themes' section")
7590

76-
end_match = re.search(r'</main>', html[start_match.start():])
91+
end_match = re.search(r"</main>", html[start_match.start() :])
7792
if not end_match:
7893
raise ValueError("Could not find </main> tag")
7994

80-
return html[start_match.start():start_match.start() + end_match.start()]
95+
return html[start_match.start() : start_match.start() + end_match.start()]
8196

8297

8398
def parse_extra_themes(html_section: str) -> list[dict]:
@@ -90,7 +105,7 @@ def parse_extra_themes(html_section: str) -> list[dict]:
90105
pattern = re.compile(
91106
r'<p>.*?<img\s+src="([^"]+)"[^>]*>.*?'
92107
r'<a\s+href="(https://github\.com/[^"]+)">([^<]+)</a>\s*</p>',
93-
re.DOTALL
108+
re.DOTALL,
94109
)
95110

96111
for match in pattern.finditer(html_section):
@@ -100,12 +115,14 @@ def parse_extra_themes(html_section: str) -> list[dict]:
100115
if preview_url.startswith("/"):
101116
preview_url = BASE_URL + preview_url
102117
name = name.strip()
103-
themes.append({
104-
"name": name,
105-
"scheme": "Dark" if name not in LIGHT_THEMES else "Light",
106-
"github_url": github_url.strip(),
107-
"preview_url": preview_url
108-
})
118+
themes.append(
119+
{
120+
"name": name,
121+
"scheme": "Dark" if name not in LIGHT_THEMES else "Light",
122+
"github_url": github_url.strip(),
123+
"preview_url": preview_url,
124+
}
125+
)
109126

110127
return themes
111128

@@ -125,7 +142,9 @@ def generate_themes_json() -> list[dict]:
125142
with open(OUTPUT_FILE, "w") as f:
126143
json.dump(combined_themes, f, indent=2)
127144

128-
print(f"Generated {OUTPUT_FILE} with {len(themes)} themes and {len(extra_themes)} extra themes ({len(combined_themes)} total).")
145+
print(
146+
f"Generated {OUTPUT_FILE} with {len(themes)} themes and {len(extra_themes)} extra themes ({len(combined_themes)} total)."
147+
)
129148
return combined_themes
130149

131150

tests/test_run_command.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import sys
5+
56
sys.path.insert(0, "src")
67

78
import pytest

0 commit comments

Comments
 (0)