deepl-python icon indicating copy to clipboard operation
deepl-python copied to clipboard

translate_document should include bytes and str in type

Open na50r opened this issue 8 months ago • 1 comments

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.

na50r avatar Apr 21 '25 15:04 na50r

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.

JanEbbing avatar May 08 '25 13:05 JanEbbing