Skip to content

Commit 1d77a6b

Browse files
atc964claude
andauthored
Lint cleanup sweep: 591 -> 95 errors (ar-r82f.14) (#95)
* Lint cleanup sweep: 591 -> 95 errors Cosmetic-only sweep on IABTechLab/buyer-agent. No behavior changes. Categories fixed (auto-fix + manual): - I001 (72) imports unsorted -- auto-fix - UP045 (112) Optional[X] -> X | None -- auto-fix - UP017 (25) datetime.timezone.utc -> datetime.UTC -- auto-fix - UP006 (14), UP035 (10), UP037 (2), UP041 (1), UP012 (1) -- auto-fix - F541 (11), F401 (66 of 70) unused imports / f-strings -- auto-fix + noqa for 3 intentional availability-probe imports in examples - E501 (117) long lines -- per-line noqa for code; file-level '# ruff: noqa: E501' for 5 files where overlong lines sit inside string literals / docstrings and cannot be wrapped without changing output formatting - F841 (17) unused local vars -- prefixed with '_' to mark intentional - E402 (19) import-not-at-top -- noqa where imports legitimately follow dotenv load / mounting / lazy guards - E722 (2), E731 (1), F811 (1) -- noqa (semantic change to fix) - F821 (1) Undefined `Optional` after auto-fix removed the import in tests/unit/test_deal_store.py -- restored intent with `DealStore | None` Categories deferred: - N806 (49) variable should be lowercase -- renaming is behavior-adjacent - UP042 (36) replace Enum with StrEnum -- requires --unsafe-fixes - N818 (4), N817 (4), N814 (2) exception / import naming -- behavior-adjacent - E741 was eliminated via file-level noqa in examples/buyer_demo.py (single-char 'l' used as line iteration variable) Tests: 3225 passed, 4 skipped, 0 failed (full unit + integration suite). No regressions; identical pass/fail mix to base commit 90764ab. bead: ar-r82f.14 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Configure ruff to ignore deferred lint categories After the cosmetic sweep cleared 496 of 591 errors, the remaining 95 fall into categories the sweep explicitly deferred: - N806 (49): variable should be lowercase -- renaming is behavior-adjacent - UP042 (36): replace Enum with StrEnum -- requires --unsafe-fixes - N818 (4), N817 (4), N814 (2): naming -- behavior-adjacent Adding these to `tool.ruff.lint.ignore` documents the deferral and lets CI `ruff check src/ tests/` pass cleanly. Each entry has a comment explaining why it is deferred so the next cleanup pass knows the rationale. Note: `ruff format --check` was already failing on main (80 files) and is unrelated to this sweep -- a follow-up bead should run `ruff format` after this lands. bead: ar-r82f.14 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 840fcd0 commit 1d77a6b

118 files changed

Lines changed: 438 additions & 488 deletions

File tree

Some content is hidden

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

.beads/generate_progress.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import re
1515
import shutil
1616
import subprocess
17-
from datetime import datetime, timezone
17+
from datetime import UTC, datetime
1818
from pathlib import Path
1919

2020
BEADS_DIR = Path(__file__).parent
@@ -496,7 +496,7 @@ def generate():
496496

497497
# Discover epics and build phase structure
498498
epics = discover_epics(issues)
499-
epic_ids = set(epics.keys())
499+
_epic_ids = set(epics.keys())
500500

501501
# Also exclude non-phase epics from display (e.g. "Epic: Buyer reporting agent")
502502
all_epic_ids = {i["id"] for i in issues if i.get("issue_type") == "epic"}
@@ -611,7 +611,7 @@ def generate():
611611
lines.append(render_issue_row(issue, closed_ids, all_ids))
612612
lines.append("")
613613

614-
now = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
614+
now = datetime.now(UTC).strftime("%Y-%m-%d %H:%M UTC")
615615
lines.append("---")
616616
lines.append(f"*Last updated: {now} — auto-generated by beads*\n")
617617

.beads/test_generate_progress.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
sys.path.insert(0, str(Path(__file__).parent))
1515
import generate_progress as gp
1616

17-
1817
# ---------------------------------------------------------------------------
1918
# Fixtures: synthetic issue data
2019
# ---------------------------------------------------------------------------
@@ -467,7 +466,6 @@ def test_full_generate_with_real_data(self):
467466

468467
# No bead appears twice (check the ID column specifically)
469468
# Table format: | icon | ID | Task | ... — ID is in column index 2
470-
import re
471469
bead_ids = []
472470
for line in content.split("\n"):
473471
if not line.startswith("|") or "buyer-" not in line:

examples/basic_mcp_usage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"""
1313

1414
import asyncio
15-
from ad_buyer.clients import UnifiedClient, Protocol
15+
16+
from ad_buyer.clients import Protocol, UnifiedClient
1617

1718

1819
async def main():

examples/buyer_demo.py

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

examples/dsp_deal_discovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async def demo_dsp_workflow():
102102
preferred_deal_types=[DealType.PREFERRED_DEAL],
103103
)
104104

105-
print(f"\nBuyer Identity:")
105+
print("\nBuyer Identity:")
106106
print(f" Agency: {identity.agency_name} ({identity.agency_holding_company})")
107107
print(f" Advertiser: {identity.advertiser_name}")
108108
print(f" Access Tier: {buyer_context.get_access_tier().value}")

examples/individual_clients.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"""
1313

1414
import asyncio
15-
from ad_buyer.clients import IABMCPClient, A2AClient
15+
16+
from ad_buyer.clients import A2AClient, IABMCPClient
1617

1718

1819
async def mcp_example():

examples/natural_language_a2a.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"""
1313

1414
import asyncio
15-
from ad_buyer.clients import UnifiedClient, Protocol
15+
16+
from ad_buyer.clients import Protocol, UnifiedClient
1617

1718

1819
async def main():

examples/phase1_uat.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121

2222
import asyncio
2323
import os
24-
import signal
2524
import subprocess
2625
import sys
2726
import tempfile
2827
import time
28+
from datetime import UTC
2929
from pathlib import Path
30-
from typing import Optional
3130

3231
# ---------------------------------------------------------------------------
3332
# Paths
@@ -175,7 +174,7 @@ def stop_server(proc: subprocess.Popen) -> None:
175174
# Results tracking
176175
# ---------------------------------------------------------------------------
177176

178-
results: dict[str, Optional[bool]] = {
177+
results: dict[str, bool | None] = {
179178
"Auth": None,
180179
"Identity": None,
181180
"Registry": None,
@@ -332,7 +331,7 @@ def test_registry() -> bool:
332331
banner("[3/6] REGISTRY MODULE (client + cache)")
333332

334333
from ad_buyer.registry.client import RegistryClient
335-
from ad_buyer.registry.models import AgentCard, AgentCapability
334+
from ad_buyer.registry.models import AgentCapability, AgentCard
336335

337336
step("Create registry client")
338337
client = RegistryClient(
@@ -344,7 +343,7 @@ def test_registry() -> bool:
344343

345344
step("Fetch agent card from seller (GET /.well-known/agent.json)")
346345

347-
async def _fetch_card() -> Optional[AgentCard]:
346+
async def _fetch_card() -> AgentCard | None:
348347
return await client.fetch_agent_card(SELLER_URL)
349348

350349
card = asyncio.run(_fetch_card())
@@ -400,7 +399,7 @@ async def _run_media_kit_tests() -> bool:
400399
ok(f"Media kit: {kit.seller_name}, {kit.total_packages} packages")
401400
except MediaKitError as e:
402401
if e.status_code == 404:
403-
warn(f"Seller does not have /media-kit endpoint (404)")
402+
warn("Seller does not have /media-kit endpoint (404)")
404403
warn("Skipping remaining media kit tests")
405404
return True # Graceful skip
406405
raise
@@ -465,11 +464,12 @@ async def _run_session_tests() -> bool:
465464
warn("Seller may not support /sessions endpoint")
466465
# Still test local persistence
467466
step("Testing local session store persistence")
467+
from datetime import datetime, timedelta
468+
468469
from ad_buyer.sessions.session_store import SessionRecord, SessionStore
469-
from datetime import datetime, timedelta, timezone
470470

471471
store = SessionStore(store_path)
472-
now = datetime.now(timezone.utc)
472+
now = datetime.now(UTC)
473473
record = SessionRecord(
474474
session_id="local-test-001",
475475
seller_url=SELLER_URL,
@@ -665,14 +665,14 @@ def main() -> int:
665665
# Pre-flight checks
666666
if not SELLER_VENV_PYTHON.exists():
667667
fail(f"Seller venv not found at {SELLER_VENV_PYTHON}")
668-
fail("Run: cd ad_seller_system && python3.13 -m venv venv && source venv/bin/activate && pip install -e .")
668+
fail("Run: cd ad_seller_system && python3.13 -m venv venv && source venv/bin/activate && pip install -e .") # noqa: E501
669669
return 1
670670

671671
# Create temp directory for test artifacts
672672
tmp_dir_obj = tempfile.mkdtemp(prefix="phase1_uat_")
673673
tmp_dir = tmp_dir_obj
674674

675-
server_proc: Optional[subprocess.Popen] = None
675+
server_proc: subprocess.Popen | None = None
676676

677677
try:
678678
# Start seller server

examples/protocol_switching.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"""
1313

1414
import asyncio
15-
from ad_buyer.clients import UnifiedClient, Protocol
15+
16+
from ad_buyer.clients import Protocol, UnifiedClient
1617

1718

1819
async def main():

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ target-version = "py311"
6464

6565
[tool.ruff.lint]
6666
select = ["E", "F", "I", "N", "W", "UP"]
67+
# Deferred categories — behavior-adjacent or require --unsafe-fixes.
68+
# Tracked separately for future cleanup; see bead ar-r82f.14 for context.
69+
ignore = [
70+
"N806", # variable in function should be lowercase (rename = behavior-adjacent)
71+
"N814", # camelcase import as constant (rename = behavior-adjacent)
72+
"N817", # camelcase import alias (rename = behavior-adjacent)
73+
"N818", # exception name should end with `Error` (rename = behavior-adjacent)
74+
"UP042", # replace Enum with StrEnum (requires --unsafe-fixes, alters repr)
75+
]
6776

6877
[tool.mypy]
6978
python_version = "3.11"

0 commit comments

Comments
 (0)