Skip to content

Commit c38b48e

Browse files
dhruvildarjiclaudesloria
authored
Add ipaddress types to Schema.TYPE_MAPPING (#2906)
* Add ipaddress types to Schema.TYPE_MAPPING Map ipaddress.IPv4Address, IPv6Address, IPv4Interface, and IPv6Interface to their corresponding marshmallow field classes in Schema.TYPE_MAPPING, enabling automatic field resolution for libraries like marshmallow_dataclass. Closes #1695 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * remove unnecessary test * update changelog --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Steven Loria <git@stevenloria.com>
1 parent 3bc191a commit c38b48e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Bug fixes:
2121
- Fix typing of ``error_essages`` argument to `marshmallow.fields.Field` (:pr:`1636`).
2222
Thanks :user:`repole` for reporting and :user:`dhruvildarji` for the PR.
2323

24+
Other changes:
25+
26+
- Add ``ipaddress.*`` to `marshmallow.Schema.TYPE_MAPPING` (:issue:`1695`).
27+
Thanks :user:`liberforce` for the suggestion and :user:`dhruvildarji` for the PR.
28+
2429
4.2.2 (2026-02-04)
2530
------------------
2631

src/marshmallow/schema.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import decimal
99
import functools
1010
import inspect
11+
import ipaddress
1112
import json
1213
import operator
1314
import typing
@@ -290,6 +291,10 @@ class AlbumSchema(Schema):
290291
dt.date: ma_fields.Date,
291292
dt.timedelta: ma_fields.TimeDelta,
292293
decimal.Decimal: ma_fields.Decimal,
294+
ipaddress.IPv4Address: ma_fields.IPv4,
295+
ipaddress.IPv6Address: ma_fields.IPv6,
296+
ipaddress.IPv4Interface: ma_fields.IPv4Interface,
297+
ipaddress.IPv6Interface: ma_fields.IPv6Interface,
293298
}
294299
#: Overrides for default schema-level error messages
295300
error_messages: dict[str, str] = {}

0 commit comments

Comments
 (0)