Skip to content

Commit

Permalink
Add warning when multiple Field annotations have bene detected
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanderlee committed Jun 18, 2024
1 parent c19b563 commit dbd909f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions marshmallow_dataclass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ def _field_for_annotated_type(
or isinstance(arg, marshmallow.fields.Field)
]
if marshmallow_annotations:
if len(marshmallow_annotations) > 1:
warnings.warn(
"Multiple marshmallow Field annotations found. Using the last one."
)

field = marshmallow_annotations[-1]
# Got a field instance, return as is. User must know what they're doing
if isinstance(field, marshmallow.fields.Field):
Expand Down

0 comments on commit dbd909f

Please sign in to comment.