
May 15, 2016
5:22 p.m.
Koos Zevenhoven writes:
I just don't want to say I broke the type hinting for os.path.*
Blame it on Brett. :-)
But if I'm told Unions are sufficient,
Unions aren't. TypeVars are (and they're basically what you proposed as a solution, I just didn't recognize them in the context of "Union").
There is nothing suspicious about that Union there. "Union[str, bytes] -> str" is a perfectly good type hint for os.fsdecode. You can't get any more precise than that.
Unions are suspicious as *values*, not as arguments. Fortunately, AnyStr is not a Union.