-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
tempfile.mkdtemp returns str (in Python 2) if given no arguments. However, if any of the optional arguments is unicode, the return type should be unicode. We can use an overloaded function to represent this:
@overload
def mkdtemp() -> str: ...
@overload
def mkdtemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr = ...) -> AnyStr: ...
However, mypy infers type Any for call mkdtemp(), because it thinks that both signatures could match equally well. Instead, mypy should give preference to the first signature.