Hacker News new | ask | show | jobs
by Townley 1987 days ago
Huh, good to know. Does this issue apply to f-strings or are you talking about format methods? I did a brief look through issues and MyPy seems to support f-strings fine, but I’d 100% believe that there are still kinks to work out
1 comments

Ah, so mypy supports fstrings, but not in types. So you can do

    Direction = Literal["left", "right"]
But this won't work:

    eft = "eft"
    ight = "ight"
    Direction = Literal[f"l{eft}", f"r{ight}"]
(Yes, this is super contrived, I bad at coming up with examples, but https://mariusschulz.com/blog/string-literal-types-in-typesc... shows some realistic examples where it's useful in typescript)