You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,31 @@ pip install dist/*.whl
37
37
- Models for RSS-specific schemas have been moved from `rss_parser.models` to `rss_parser.models.rss`. Generic types remain unchanged
38
38
- Date parsing has been improved and now uses pydantic's `validator` instead of `email.utils`, producing better datetime objects where it previously defaulted to `str`
39
39
40
+
## V2 -> V3 Migration
41
+
42
+
`rss-parser` 3.x upgrades the runtime models to [Pydantic v2](https://docs.pydantic.dev/latest/migration/). Highlights:
43
+
44
+
-**New default models** now inherit from `pydantic.BaseModel` v2 and use `model_validate`/`model_dump`. If you extend our classes, switch from `dict()`/`json()` to `model_dump()`/`model_dump_json()`.
45
+
-**Legacy compatibility** lives under `rss_parser.models.legacy`. Point your custom parser at the legacy schema if you must stay on the v1 API surface.
46
+
-**Collections**: list-like XML fields now use `OnlyList[...]` directly with an automatic `default_factory` so that attributes are always lists (no more `Optional[OnlyList[T]] = Field(..., default=[])`). Update custom schemas accordingly.
47
+
-**Custom hooks**: if you relied on `rss_parser.pydantic_proxy`, import it from `rss_parser.models.legacy.pydantic_proxy`. The top-level module only re-exports it for backwards compatibility.
48
+
49
+
See the “Legacy Models” section below for sample snippets showing how to stay on the older types. Tests in this repo cover both tracks to guarantee matching output.
50
+
51
+
## Legacy Models
52
+
53
+
Pydantic v1-based models are still available under `rss_parser.models.legacy`. They retain the previous behaviour and re-export the `import_v1_pydantic` helper as `rss_parser.models.legacy.pydantic_proxy.import_v1_pydantic`. You can continue to use them by pointing your parser at the legacy schema:
54
+
55
+
```python
56
+
from rss_parser import RSSParser
57
+
from rss_parser.models.legacy.rss importRSSas LegacyRSS
58
+
59
+
classLegacyRSSParser(RSSParser):
60
+
schema = LegacyRSS
61
+
```
62
+
63
+
Tests in this repository run against both the v2 and legacy models to ensure parity.
64
+
40
65
## Usage
41
66
42
67
### Quickstart
@@ -163,18 +188,17 @@ If you don't want to deal with these conditions and want to parse something **al
163
188
```python
164
189
from typing import Optional
165
190
191
+
from pydantic import Field
192
+
166
193
from rss_parser.models.rss.item import Item
167
194
from rss_parser.models.types.only_list import OnlyList
168
195
from rss_parser.models.types.tag import Tag
169
-
from rss_parser.pydantic_proxy import import_v1_pydantic
0 commit comments