Skip to content

Commit ff8fd21

Browse files
fix(ci): restore ruff lint ignores + auto-fix 25 ruff violations
1 parent 05ff00b commit ff8fd21

13 files changed

Lines changed: 22 additions & 19 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ pythonpath = ["src"]
5454
line-length = 100
5555
target-version = "py311"
5656

57+
[tool.ruff.lint]
58+
ignore = ["B008", "S110", "BLE001"]
59+
5760
[tool.coverage.run]
5861
source = ["bloggereasy"]
5962
branch = true

src/bloggereasy/api/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
try:
1616
from fastapi import FastAPI, File, Form, HTTPException, UploadFile
17-
from fastapi.responses import HTMLResponse, Response, PlainTextResponse
17+
from fastapi.responses import HTMLResponse, PlainTextResponse, Response
1818
from pydantic import BaseModel, Field
1919
except ImportError as exc: # pragma: no cover
2020
raise ImportError("Install bloggereasy[api] for FastAPI support") from exc

src/bloggereasy/gui/main_window.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66
from pathlib import Path
77

8-
from PySide6.QtCore import Qt, QSize, QThread, Signal, QUrl
8+
from PySide6.QtCore import QSize, Qt, QThread, QUrl, Signal
99
from PySide6.QtGui import QDesktopServices, QPixmap
1010
from PySide6.QtWidgets import (
1111
QButtonGroup,
@@ -138,7 +138,7 @@ def run(self) -> None:
138138
else:
139139
raise ValueError(f"Unknown mode {self.mode}")
140140
self.finished_ok.emit(result)
141-
except Exception as exc: # noqa: BLE001
141+
except Exception as exc:
142142
self.failed.emit(str(exc))
143143

144144

@@ -682,7 +682,7 @@ def run_demo_batch(self) -> None:
682682
result = generate_from_html(path, out, template=tmpl)
683683
ok = result["validation"].get("ok")
684684
self.demo_log.append(f"{'✓' if ok else '·'} {path.name}{out.name} ok={ok}")
685-
except Exception as exc: # noqa: BLE001
685+
except Exception as exc:
686686
self.demo_log.append(f"✗ {path.name}: {exc}")
687687
self.demo_log.append(f"\nDone → {root}")
688688
self.demo_log.append("Import any XML: Blogger → Theme → Backup/Restore → Upload")

src/bloggereasy/integrations/bundle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import hashlib
2121
import json
22-
from datetime import datetime, timezone
22+
from datetime import UTC, datetime
2323
from pathlib import Path
2424

2525
from bloggereasy import __version__
@@ -166,7 +166,7 @@ def generate_bundle(
166166

167167
manifest = {
168168
"bundle_version": BUNDLE_VERSION,
169-
"generated_at": datetime.now(timezone.utc).isoformat(),
169+
"generated_at": datetime.now(UTC).isoformat(),
170170
"source": source,
171171
"source_ref": source_ref,
172172
"template": result.get("template", template),

src/bloggereasy/parse/css.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def extract_css_skin(html: str) -> dict[str, Any]:
1818

1919

2020
def _collect_css(html: str) -> str:
21-
style_blocks = re.findall(r"<style[^>]*>(.*?)</style>", html, flags=re.I | re.S)
22-
inline_styles = re.findall(r"\sstyle=[\"']([^\"']+)[\"']", html, flags=re.I)
21+
style_blocks = re.findall(r"<style[^>]*>(.*?)</style>", html, flags=re.IGNORECASE | re.DOTALL)
22+
inline_styles = re.findall(r"\sstyle=[\"']([^\"']+)[\"']", html, flags=re.IGNORECASE)
2323
return "\n".join([*style_blocks, *inline_styles])
2424

2525

2626
def _extract_fonts(css: str) -> dict[str, str]:
27-
families = re.findall(r"font-family\s*:\s*([^;}{]+)", css, flags=re.I)
27+
families = re.findall(r"font-family\s*:\s*([^;}{]+)", css, flags=re.IGNORECASE)
2828
cleaned: list[str] = []
2929
for family in families:
3030
first = family.split(",")[0].strip().strip("'\"")
@@ -68,10 +68,10 @@ def _first_css_value(
6868
hinted = _first_block(css, rf"[^{{]*(?:{selector_hint})[^{{]*")
6969
if hinted:
7070
haystack = hinted
71-
match = re.search(rf"{property_name}\s*:\s*([^;}}{{]+)", haystack, flags=re.I)
71+
match = re.search(rf"{property_name}\s*:\s*([^;}}{{]+)", haystack, flags=re.IGNORECASE)
7272
return match.group(1).strip() if match else default
7373

7474

7575
def _first_block(css: str, selector_pattern: str) -> str:
76-
match = re.search(rf"{selector_pattern}\{{([^}}]+)\}}", css, flags=re.I | re.S)
76+
match = re.search(rf"{selector_pattern}\{{([^}}]+)\}}", css, flags=re.IGNORECASE | re.DOTALL)
7777
return match.group(1) if match else ""

src/bloggereasy/parse/html_page.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def parse_html_string(html: str, source: str = "inline") -> dict:
2323
title = _text(soup.find("h1"))
2424

2525
description = ""
26-
meta = soup.find("meta", attrs={"name": re.compile("^description$", re.I)})
26+
meta = soup.find("meta", attrs={"name": re.compile("^description$", re.IGNORECASE)})
2727
if meta and meta.get("content"):
2828
description = str(meta["content"]).strip()
2929

@@ -103,7 +103,7 @@ def _extract_colors(html: str) -> dict:
103103

104104

105105
def _extract_fonts(html: str, soup: BeautifulSoup) -> dict:
106-
families = re.findall(r"font-family\s*:\s*([^;}{]+)", html, flags=re.I)
106+
families = re.findall(r"font-family\s*:\s*([^;}{]+)", html, flags=re.IGNORECASE)
107107
cleaned = []
108108
for fam in families:
109109
first = fam.split(",")[0].strip().strip("'\"")

src/bloggereasy/theme/validate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from lxml import etree
77

8-
98
XHTML_NS = "http://www.w3.org/1999/xhtml"
109
B_NS = "http://www.google.com/2005/gml/b"
1110
_EXTERNAL_ASSET_RE = re.compile(

src/bloggereasy/vision/palette.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

3+
from collections.abc import Iterable
34
from pathlib import Path
4-
from typing import Iterable
55

66

77
def structure_from_image(path: Path, *, title: str = "My Blog") -> dict:

tests/test_api_new.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_gen_image_endpoint() -> None:
2626
"""POST /gen/image should accept a PNG and return Blogger XML."""
2727
# Create a minimal PNG in memory
2828
from io import BytesIO
29+
2930
from PIL import Image
3031

3132
img = Image.new("RGB", (200, 100), color=(80, 120, 200))
@@ -47,6 +48,7 @@ def test_gen_image_endpoint() -> None:
4748
def test_gen_image_rejects_invalid_template() -> None:
4849
"""POST /gen/image should reject unknown template."""
4950
from io import BytesIO
51+
5052
from PIL import Image
5153

5254
img = Image.new("RGB", (100, 50), color=(0, 0, 0))

tests/test_cli_url.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from bloggereasy import cli
66
from bloggereasy.cli import app
77

8-
98
runner = CliRunner()
109

1110

0 commit comments

Comments
 (0)