Add ipaddress types to Schema.TYPE_MAPPING#2906
Open
dhruvildarji wants to merge 1 commit intomarshmallow-code:devfrom
Open
Add ipaddress types to Schema.TYPE_MAPPING#2906dhruvildarji wants to merge 1 commit intomarshmallow-code:devfrom
dhruvildarji wants to merge 1 commit intomarshmallow-code:devfrom
Conversation
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 marshmallow-code#1695 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1695.
Adds mappings from Python's
ipaddresstypes to their corresponding marshmallow field classes inSchema.TYPE_MAPPING:ipaddress.IPv4Addressfields.IPv4ipaddress.IPv6Addressfields.IPv6ipaddress.IPv4Interfacefields.IPv4Interfaceipaddress.IPv6Interfacefields.IPv6InterfaceThis enables libraries like
marshmallow_dataclassto automatically resolve these types from annotations.Note: The generic
IPandIPInterfacefields are intentionally excluded since there is no single Python type that maps to them.IPv4Network/IPv6Networkare also excluded since marshmallow does not have corresponding network field classes.Test plan
TestIPTypeMappingsverifying all 4 new type mappings