Skip to content

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Dec 28, 2025

Summary

This PR implements Python feedparser compatibility improvements in 4 phases:

Phase 1: FeedParserDict Field Mapping ✅ (This commit)

  • Adds deprecated field aliases for backward compatibility with Python feedparser:
    • Feed: descriptionsubtitle, taglinesubtitle, modifiedupdated, copyrightrights, dateupdated/published, urllink
    • Entry: guidid, descriptionsummary, issuedpublished, modifiedupdated, dateupdated/published
    • Container: channelfeed, itemsentries
  • Uses once_cell::Lazy<HashMap> for O(1) alias lookups
  • Implements __getattr__ on PyFeedMeta, PyEntry, PyParsedFeed
  • 19 comprehensive Python tests

Phases 2-4 (Coming in subsequent commits)

  • Phase 2: Python Dict-style Access (d['feed']['title'])
  • Phase 3: Configuration Flags (strict mode, sanitization options)
  • Phase 4: Auto-URL Detection

Test plan

  • All 19 new Python compat tests pass
  • All 78 Python tests pass (no regressions)
  • All Rust tests pass
  • Clippy passes with no warnings
  • Performance check: No regression (field access via HashMap is O(1))
  • Security check: No new unsafe code, follows bozo pattern

Implement Phase 1 of Python feedparser compatibility improvements:

- Add deprecated field aliases (description→subtitle, tagline→subtitle,
  modified→updated, copyright→rights, date→updated/published, url→link)
- Add entry aliases (guid→id, description→summary, issued→published,
  modified→updated, date→updated/published)
- Add container aliases (channel→feed, items→entries)
- Use once_cell::Lazy<HashMap> for O(1) alias lookups
- Add __getattr__ methods to PyFeedMeta, PyEntry, PyParsedFeed
- Add comprehensive Python tests (19 test cases)

This allows users migrating from Python feedparser to access data using
familiar deprecated field names while the modern field names remain
the primary API.
@github-actions github-actions bot added type: build Build system, dependencies, or tooling type: tooling Development tools, CI/CD, or infrastructure component: core feedparser-rs-core Rust library component: python Python bindings (PyO3) component: node Node.js bindings (napi-rs) component: tests Test suite or test infrastructure component: dependencies Dependency updates or management lang: rust Rust code lang: python Python code size: XL Extra large PR (<1000 lines changed) labels Dec 28, 2025
Implement Phase 2 of Python feedparser compatibility improvements:

- Add __getitem__ method to PyParsedFeed for top-level dict access
- Add __getitem__ method to PyFeedMeta for feed['field'] access
- Add __getitem__ method to PyEntry for entry['field'] access
- Support all modern and deprecated field names via dict syntax
- Raise KeyError for unknown keys (correct dict behavior)
- Add 10 comprehensive test cases for dict-style access

Users can now access data using both patterns:
  feed['feed']['title']  # dict-style
  feed.feed.title        # attribute-style

Deprecated names also work: feed['channel']['description']
@github-actions github-actions bot added size: XXL Huge PR (1000+ lines changed) and removed size: XL Extra large PR (<1000 lines changed) labels Dec 28, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #39   +/-   ##
=======================================
  Coverage   91.84%   91.84%           
=======================================
  Files          34       34           
  Lines        7758     7758           
=======================================
  Hits         7125     7125           
  Misses        633      633           
Flag Coverage Δ
rust-core 91.84% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The parse() function now automatically detects URLs (http://, https://)
and fetches them when the http feature is enabled. This matches Python
feedparser's behavior where parse() accepts both URLs and content.

Changes:
- Add optional etag, modified, user_agent params to parse()
- Add optional HTTP params to parse_with_limits()
- Create internal parse_internal() for shared URL/content logic
- URL detection based on http:// and https:// prefix
- When http feature disabled, return NotImplementedError for URLs
- Update existing tests to use keyword args for limits param
- Add feedparser compatibility features to CHANGELOG [Unreleased]
- Update Python README with dict-style access, field aliases, auto-URL
- Update main README Python section with compatibility examples
- Document supported field aliases table in Python README
- Update API reference with new function signatures
@github-actions github-actions bot added the type: documentation Improvements or additions to documentation label Dec 28, 2025
Python feedparser compatibility improvements:
- Field alias mappings for deprecated field names
- Dict-style access on feed objects
- Container aliases (channel → feed, items → entries)
- Auto-URL detection in parse() function
- Optional HTTP parameters for parse() and parse_with_limits()
@github-actions github-actions bot added the lang: javascript JavaScript/TypeScript code label Dec 28, 2025
@bug-ops bug-ops merged commit 79da235 into main Dec 28, 2025
31 checks passed
@bug-ops bug-ops deleted the feat/feedparser-compat-p0-p1 branch December 28, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: core feedparser-rs-core Rust library component: dependencies Dependency updates or management component: node Node.js bindings (napi-rs) component: python Python bindings (PyO3) component: tests Test suite or test infrastructure lang: javascript JavaScript/TypeScript code lang: python Python code lang: rust Rust code size: XXL Huge PR (1000+ lines changed) type: build Build system, dependencies, or tooling type: documentation Improvements or additions to documentation type: tooling Development tools, CI/CD, or infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants