dir argument to tempfile functions may take PathLike#3226
Conversation
srittau
left a comment
There was a problem hiding this comment.
Missing imports for os and Union. Otherwise looks good to me, although personally I'd have left the Optional in the arguments and only put the differing types in _DirT.
oops fixed, I'm spoiled by pre-commit 🙃 |
|
urgh, |
|
hmmm now we're failing pytype 🤔 |
|
The reason for the pytype failure is that pytype looks for the presence of type variables defined in the same pyi file to figure out whether an alias is generic. If you define it should work. |
this has different semantics than |
|
Everywhere you're using And you can always just copy the definition of |
|
This seems to cause a regression on Python 3.5; see #3449. $ echo 'import tempfile; tempfile.mkstemp(dir="/var/tmp")' | mypy /dev/stdin
dev/stdin:1: error: Argument "dir" to "mkstemp" has incompatible type "str"; expected "None"
Found 1 error in 1 file (checked 1 source file) |
Resolves #2749
see also python/cpython#11644