Skip to content

fix: handle undated Lichfield collection cards#2179

Draft
JasSmiths wants to merge 1 commit into
robbrad:masterfrom
JasSmiths:agent/fix-lichfield-food-waste-parser
Draft

fix: handle undated Lichfield collection cards#2179
JasSmiths wants to merge 1 commit into
robbrad:masterfrom
JasSmiths:agent/fix-lichfield-food-waste-parser

Conversation

@JasSmiths

@JasSmiths JasSmiths commented Jul 19, 2026

Copy link
Copy Markdown

Summary

  • parse each Lichfield collection card as a self-contained unit instead of pairing global heading and date lists by index
  • derive the next food-waste collection from the weekly weekday shown by the council when no explicit date is present
  • preserve the existing Food Waste bin type used by Home Assistant entities
  • roll explicit collection dates into the next year when their month and day have already passed
  • add regression coverage for the undated food-waste card, the Purple Bin date, the calendar download card, and year rollover

Root cause

Lichfield added a Food Waste Caddy card that contains a weekly collection weekday but no bin-collection-tasks__date element. The scraper collected all headings and all dates into separate lists and paired them by position. The undated card shifted every subsequent date onto the wrong bin and omitted the final dated bin.

Impact

Collection dates remain attached to their own cards, so Brown, Blue, Black, and Purple Bin data is returned correctly. The weekly Food Waste collection is also exposed without changing its existing entity identity.

Validation

  • Python 3.12 targeted regression tests: 2 passed
  • Black formatting check passed
  • live Lichfield scraper invocation using the repository's existing test UPRN returned correctly paired collection data

Summary by CodeRabbit

  • Bug Fixes

    • Corrected Lichfield bin collection dates so each collection is paired with its corresponding date.
    • Improved handling of collection dates that fall in the following calendar year.
    • Preserved the expected “Food Waste” bin label for consistent integrations.
  • Tests

    • Added coverage for date pairing, explicit collection dates, and year transitions.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db78116d-7e5b-4ddc-abbf-11a6a93164a5

📥 Commits

Reviewing files that changed from the base of the PR and between 36d9205 and 2d91521.

📒 Files selected for processing (2)
  • uk_bin_collection/tests/test_lichfield_district_council.py
  • uk_bin_collection/uk_bin_collection/councils/LichfieldDistrictCouncil.py

📝 Walkthrough

Walkthrough

Lichfield’s parser now processes each collection card independently, calculates explicit and weekday-based dates relative to the current date, preserves the Food Waste bin identity, and adds deterministic tests for card dates and year rollover.

Changes

Lichfield parser behavior

Layer / File(s) Summary
Card-based date parsing and bin normalization
uk_bin_collection/.../LichfieldDistrictCouncil.py
Collection cards are parsed independently, dates are calculated from explicit or weekday data, and Food Waste Caddy is normalized to Food Waste.
Deterministic parser regression coverage
uk_bin_collection/tests/test_lichfield_district_council.py
A fixed HTML fixture and mocked time and HTTP responses verify card-specific dates and explicit dates rolling into the next year.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main parser fix for undated Lichfield collection cards.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JasSmiths

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant