marshmallow-code / marshmallow-code/marshmallow

Dump converts int or bool to float

Open
#2,816 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

polymorphism
Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

I have an schema:

class ExampleSchema(Schema):
    name: str
    value: int | float | bool

When I pass an integer or boolean value, marshmallow converts it into a float. Is there any clean way to correct this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported schema with the value: int | float | bool field and compare dump results for integer, boolean, and float inputs. Trace the schema's union handling to identify why integers and booleans become floats; done means those values retain their original types while float values still dump correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.