Skip to content

translate_document should include bytes and str in type #131

Open

Description

@na50r

Currently, translate_document has the following type annotation for input_document

input_document: Union[TextIO, BinaryIO, Any],

However, translate_document essentially just calls translate_document_uploud, which has:

input_document: Union[TextIO, BinaryIO, str, bytes, Any]

I do not really see a reason why you would have less types in translate_document than translate_document_uploud, especially since in translate_document's docstring you have:

        :param filename: (Optional) Filename including extension, only required
            if uploading string or bytes containing file content.

So you allow the user to provide bytes or str as input but the only way to verify if bytes and str are valid under Any is to either read the docstring or drill down the code. Unsure if that was the intention, if it was, I apologize.

Activity

  1. JanEbbing commented on May 8, 2025

    @JanEbbing
    Contributor

    Sorry for the delay here. I agree the current typing looks fishy/wrong, but I'm not 100% sure what the ideal state looks like. I'll take a closer look tomorrow and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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