Skip to content

Don't Mutate Function Input For Text #2673

@peter-zhong-replit

Description

@peter-zhong-replit

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

In general, it seems like a bad practice to mutate input parameters. However,

text["format"] = _type_to_text_format_param(text_format) does exactly this.

See peter-zhong-replit@1e949be for potential fix.

To Reproduce

call .parse twice with text given, but use the same variable for text, confirm the second time it's mutated and therefore will throw TypeError("Cannot mix and match text.format with text_format")

Code snippets

OS

macOS

Python version

3.12

Library version

2.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions