Skip to content

os.open() can take Path objects in Python 3.6 #1030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
toolness opened this issue Mar 19, 2017 · 2 comments
Closed

os.open() can take Path objects in Python 3.6 #1030

toolness opened this issue Mar 19, 2017 · 2 comments

Comments

@toolness
Copy link
Contributor

I noticed that the following code fails when checked by mypy under Python 3.6:

import os
from pathlib import Path

fd = os.open(Path('/dev/null'), os.O_RDONLY)

The following error is produced:

error: Type argument 1 of "open" has incompatible value "Path"

However, the code seems to work fine due to Python 3.6's support for PEP 519.

If this is a problem with the type stubs then I could try submitting a PR. mypy rocks!

@JelleZijlstra
Copy link
Member

Yes, this is a problem with the stubs. There's an open PR to fix a few other functions in a similar way at #991, but we need to change a lot more functions.

@JelleZijlstra
Copy link
Member

os.open is now declared as taking _PathType, which includes PathLike in 3.6+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants