Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/click/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,27 @@ class LazyFile:
files for writing.
"""

name: str
mode: str
encoding: str | None
errors: str | None
atomic: bool
_f: t.IO[t.Any] | None
should_close: bool

def __init__(
Comment thread
kdeldycke marked this conversation as resolved.
self,
filename: str | os.PathLike[str],
mode: str = "r",
encoding: str | None = None,
errors: str | None = "strict",
atomic: bool = False,
):
self.name: str = os.fspath(filename)
) -> None:
self.name = os.fspath(filename)
self.mode = mode
self.encoding = encoding
self.errors = errors
self.atomic = atomic
self._f: t.IO[t.Any] | None
self.should_close: bool

if self.name == "-":
self._f, self.should_close = open_stream(filename, mode, encoding, errors)
Expand Down Expand Up @@ -199,8 +205,10 @@ def __iter__(self) -> cabc.Iterator[t.AnyStr]:


class KeepOpenFile:
_file: t.IO[t.Any]

def __init__(self, file: t.IO[t.Any]) -> None:
self._file: t.IO[t.Any] = file
self._file = file

def __getattr__(self, name: str) -> t.Any:
return getattr(self._file, name)
Expand Down Expand Up @@ -508,6 +516,8 @@ class PacifyFlushWrapper:
pipe, all calls and attributes are proxied.
"""

wrapped: t.IO[t.Any]

def __init__(self, wrapped: t.IO[t.Any]) -> None:
self.wrapped = wrapped

Expand Down
Loading