Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define handling of Decimal values #99

Open
leoschwarz opened this issue Aug 9, 2024 · 0 comments
Open

Define handling of Decimal values #99

leoschwarz opened this issue Aug 9, 2024 · 0 comments

Comments

@leoschwarz
Copy link
Collaborator

Some properties return Decimal objects which is an arbitrary-precision representation.
The problem is that this is not serializable to most formats without converting to a string or float.

Currently bfabric_read.py for instance will fail to print a JSON document if there is a single Decimal object in the response.

A simple fix would be to add a clause

def convert_suds_type(item: Any) -> int | float | str:
    if isinstance(item, Text):
        return str(item)
    elif isinstance(item, Decimal):
        return float(item)
    return item

but will need to be considered later whether it is really appropriate. If we retain the Decimal we should define serialization etc. to be aware of this type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant