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
The error is because you're overriding the Formatter.parse method in an incompatible way. The Formatter base class defines the return type using a constrained TypeVar and includes unions with None, but your override does not. Your override also uses an incompatible parameter name (s versus format_string) and parameter type.
However, why doesn't mypy display error about argument type in the first example? It's also StrOrLiteralStr in the superclass.
And, more importantly, where can I get (import?) StrOrLiteralStr? StrOrLiteralStr = TypeVar("StrOrLiteralStr", str, str) doesn't look like a clean solution in my opinion.
Bug Report
mypy doesn't accept
str
forStrOrLiteralStr
To Reproduce
(playground)
Actual Behavior
error: Return type "Iterable[tuple[str, str, str, str]]" of "parse" incompatible with return type "Iterable[tuple[StrOrLiteralStr, StrOrLiteralStr | None, StrOrLiteralStr | None, StrOrLiteralStr | None]]" in supertype "Formatter" [override]
Details
I've asked a question on SO about this and didn't get an answer (yet). As indicated in the comments:
The text was updated successfully, but these errors were encountered: