From 279ce7b01666a57e61e94514b39312c02a3184d2 Mon Sep 17 00:00:00 2001 From: jorenham Date: Tue, 12 May 2026 22:07:16 +0200 Subject: [PATCH] Add type annotations for instance attributes in `utils` --- src/click/utils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/click/utils.py b/src/click/utils.py index e2e3fe5f1..a987437ac 100644 --- a/src/click/utils.py +++ b/src/click/utils.py @@ -117,6 +117,14 @@ 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__( self, filename: str | os.PathLike[str], @@ -124,14 +132,12 @@ def __init__( 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) @@ -508,6 +514,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