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

Add `Literal[...]` type to `translate_*` methods for better IDE completions

Open winstonallo opened this issue 5 months ago • 0 comments

Hey! I noticed that the translation functions accepting source/target languages do so with a str type hint. Would be nice to have a Literal["EN", "FR", ...] in order to get IDE completions like these:

https://github.com/user-attachments/assets/36c2f40d-bfd3-4764-ae95-1ab6e51d8538

This could be as simple as adding something like:

from typing import Literal

type LanguageLiteral = Literal["en-gb", "en-us", "fr"] # + all other supported languages

This could then be added as a type hint to translate_text and the like for better IDE support. I would be happy to submit a PR if this is something you guys would like to have!

winstonallo avatar Jul 21 '25 09:07 winstonallo