bpo-44196: document that Traversable's methods should raise FileNotFoundError#26272
bpo-44196: document that Traversable's methods should raise FileNotFoundError#26272FFY00 wants to merge 1 commit intopython:mainfrom
Conversation
…undError Signed-off-by: Filipe Laíns <[email protected]>
| .. versionadded:: 3.9 | ||
| .. versionadded:: 3.9 | ||
|
|
||
| .. abstractmethod:: name() |
There was a problem hiding this comment.
I'm inclined to say let's not duplicate the docs from the code. Let's just link to the code if needed.
| When opening as text, accepts encoding parameters such as those | ||
| accepted by io.TextIOWrapper. | ||
|
|
||
| If the file cannot be found, FileNotFoundError should be raised, |
There was a problem hiding this comment.
I'd probably change the terminology. The term "the file" could be more clear. Maybe something like "the object referenced by self".
Also, "open" may raise other exceptions. For example, if self references a directory and someone attempts to open it, they should expect "IsADirectoryError" to be raised. Or if the resource was on a network and the network has dropped, they might get a socket.ConnectionError. Or if it was an HTTP resource and access has been revoked, they may get an HTTPAccessDenied error. I'm not sure it's appropriate to attempt to prescribe which exceptions should or shouldn't be expected.
|
|
||
| If the file cannot be found, FileNotFoundError should be raised, | ||
| although this is not guaranteed for compatibility reasons. | ||
| """ | ||
| with self.open('rb') as strm: | ||
| return strm.read() | ||
|
|
||
| def read_text(self, encoding=None): | ||
| """ | ||
| Read contents of self as text | ||
|
|
||
| If the file cannot be found, FileNotFoundError should be raised, | ||
| although this is not guaranteed for compatibility reasons. |
There was a problem hiding this comment.
Since these implementations don't perform any specific checks on fileness, I'd leave out any documentation about what exceptions are raised and defer to the docs for open.
|
After looking through each of these methods, I'm uncertain that any of them should indicate anything about a |
|
Of course 🤦, I derived this from This could take a different form than a |
Signed-off-by: Filipe Laíns [email protected]
https://bugs.python.org/issue44196