diff --git a/pyproject.toml b/pyproject.toml index 9a8c8d6b..b9cc12ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,8 +48,24 @@ line-length = 120 target-version = "py311" [tool.ruff.lint] -select = ["E", "F", "I", "UP", "B", "SIM", "D"] -ignore = ["D203", "D206", "D300"] +select = ["E", "W", "F", "I", "UP", "B", "SIM", "D", "PERF", "FURB"] +ignore = [ + "W191", + "E111", + "E114", + "E117", + "D203", + "D206", + "D300", + "Q000", + "Q001", + "Q002", + "Q003", + "Q004", + "COM812", + "COM819", +] +preview = false [tool.ruff.lint.pydocstyle] convention = "google" diff --git a/weather_briefing/render.py b/weather_briefing/render.py index 7fbdebea..81774779 100644 --- a/weather_briefing/render.py +++ b/weather_briefing/render.py @@ -59,11 +59,13 @@ def render_briefing( lines.extend(_html_items("天气信息", result.conclusions, source_links)) if result.active_warnings: lines.extend(["气象预警", ""]) - for warning in result.active_warnings: - lines.append( + lines.extend( + ( f"• {_html_text(warning.title)}({_html_text(warning.status)}):" f"{_html_text(warning.detail)} {_html_attribution(warning.source_ids, source_links)}" ) + for warning in result.active_warnings + ) lines.append("") lines.extend(_html_items("自然灾害动态", result.disaster_tracking, source_links)) lines.extend(_html_items("生活建议", result.advice, source_links)) @@ -144,8 +146,7 @@ def _html_items( if not items: return [] lines = [f"{_html_text(title)}", ""] - for item in items: - lines.append(f"• {_html_text(item.text)} {_html_attribution(item.source_ids, source_links)}") + lines.extend(f"• {_html_text(item.text)} {_html_attribution(item.source_ids, source_links)}" for item in items) lines.append("") return lines @@ -158,8 +159,7 @@ def _plain_items( if not items: return [] lines = [title, ""] - for item in items: - lines.append(f"- {item.text} {_plain_attribution(item.source_ids, source_references)}") + lines.extend(f"- {item.text} {_plain_attribution(item.source_ids, source_references)}" for item in items) lines.append("") return lines