Skip to content
Myr

Add type annotations for instance attributes in `utils` (#3422)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rowlando13 · committed by GitHub · parents 3bb230d, fc41aa1 · Browse files · 1 file+15 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−5 removed

  • other:+15 added−5 removed

1 file+15 added−5 removed

modified:src/click/utils.py+15 added-5 removed
115 unmodified lines
116 filename parameter does make sense. This is useful for safely opening117 files for writing.118 """119120 name: str121 mode: str122 encoding: str | None123 errors: str | None124 atomic: bool125 _f: t.IO[t.Any] | None126 should_close: bool127128 def __init__(129 self,130 filename: str | os.PathLike[str],131 mode: str = "r",132 encoding: str | None = None,133 errors: str | None = "strict",134 atomic: bool = False,127 ):128 self.name: str = os.fspath(filename)135 ) -> None:136 self.name = os.fspath(filename)137 self.mode = mode138 self.encoding = encoding139 self.errors = errors140 self.atomic = atomic133 self._f: t.IO[t.Any] | None134 self.should_close: bool141142 if self.name == "-":143 self._f, self.should_close = open_stream(filename, mode, encoding, errors)144 else:
59 unmodified lines
204 return iter(self._f) # type: ignore205206207class KeepOpenFile:208 _file: t.IO[t.Any]209210 def __init__(self, file: t.IO[t.Any]) -> None:203 self._file: t.IO[t.Any] = file211 self._file = file212213 def __getattr__(self, name: str) -> t.Any:214 return getattr(self._file, name)215
299 unmodified lines
515 other cleanup code, and the case where the underlying file is not a broken516 pipe, all calls and attributes are proxied.517 """518519 wrapped: t.IO[t.Any]520521 def __init__(self, wrapped: t.IO[t.Any]) -> None:522 self.wrapped = wrapped523524 def flush(self) -> None:
117 unmodified lines