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
[doc] mention that os.mkdir() raises FileNotFound if path does not exist #74862
Comments
Currently, documentation for os.mkdir() (see https://docs.python.org/3.6/library/os.html#os.mkdir ) reports only FileExistsError exception if directory exists. Please, add other exceptions (e.g. FileNotFoundError if directory is created in a non existent path) or report OSError as superclass of exceptions returned from this method |
We don't generally document all exceptions that a method can raise, only those that are relevant to its specific API. In this case, documenting the exception answers the question, "what happens if the directory already exists?" This question is relevant to the API since the other reasonable possibility is that it would act as if the mkdir had succeeded. As for documenting OSError, I'm sure there are ways to get os.mkdir to raise an exception that is not an OSError. However, there is an argument to be made for documenting FileNotFound: the other reasonable thing the function could do in that case would be to create all intermediate path parts, but it does not do that (you use os.makedirs for that). Since os.makedirs is documented right after os.mkdir, I'm not sure it is worth adding, but one can make the argument :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: