mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-29 07:18:27 +01:00
api: open: Raise ValueError if rev is used in wrong mode.
Closes #7405 Co-authored-by: Peter Rowlands (변기호) <[email protected]>
This commit is contained in:
co-authored by
Peter Rowlands
parent
15e10a1d81
commit
1663b97eaa
@@ -90,6 +90,7 @@ def open( # noqa, pylint: disable=redefined-builtin
|
||||
mode (str, optional): Specifies the mode in which the file is opened.
|
||||
Defaults to "r" (read).
|
||||
Mirrors the namesake parameter in builtin `open()`_.
|
||||
Only reading `mode` is supported.
|
||||
encoding(str, optional): `Codec`_ used to decode the file contents.
|
||||
Defaults to None.
|
||||
This should only be used in text mode.
|
||||
@@ -104,6 +105,7 @@ def open( # noqa, pylint: disable=redefined-builtin
|
||||
|
||||
Raises:
|
||||
AttributeError: If this method is not used as a context manager.
|
||||
ValueError: If non-read `mode` is used.
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -178,6 +180,8 @@ def open( # noqa, pylint: disable=redefined-builtin
|
||||
https://docs.python.org/3/glossary.html#term-file-object
|
||||
|
||||
"""
|
||||
if "r" not in mode:
|
||||
raise ValueError("Only reading `mode` is supported.")
|
||||
|
||||
args = (path,)
|
||||
kwargs = {
|
||||
|
||||
Reference in New Issue
Block a user