Skip to content

Add String Formatting to NumberResponse #1820

@lukekh

Description

@lukekh

🚀 The feature

If I put a NumberResponse class in a formatted string (e.g. f"{response:.2f}") I want it to render the format specified.

I think all this would take is adding a method

def __format__(self, fmt):
       return self.value.__format__(fmt)

to the BaseResponse class.

Motivation, pitch

This will mean formatting responses that are numeric will not require access to the value attribute.

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions