You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the typing of the translate_text it would be better to use method overloading, so that the return type is not ambiguous when passing a text variable that is either str or Iterable[str]
If typed like this mypy understands that when text is a str the return type is TextResult and when it is an Iterable[str] the return type is List[TextResult], avoiding error messages like when passing an Iterable[str] as text:
<file>:102: error: Item "TextResult" of "TextResult | list[TextResult]" has no attribute "__iter__" (not iterable) [union-attr]
If you prefer, I'd be glad submit a pull request
The text was updated successfully, but these errors were encountered:
In the typing of the translate_text it would be better to use method overloading, so that the return type is not ambiguous when passing a
text
variable that is eitherstr
orIterable[str]
So I suggest that here
deepl-python/deepl/translator.py
Lines 334 to 350 in 16108b0
If typed like this mypy understands that when text is a
str
the return type isTextResult
and when it is anIterable[str]
the return type isList[TextResult]
, avoiding error messages like when passing anIterable[str]
astext
:If you prefer, I'd be glad submit a pull request
The text was updated successfully, but these errors were encountered: