Type hinting: Low-hanging fruit improvements
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Clean out a series of ignores, either by specifying types or by reworking code slightly the ignore is no longer needed.
authored by Martijn Pieters · committed by David Lord · parent a1093bb · Browse files · 5 files·+10 added−13 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+10 added−13 removed
- other:+10 added−13 removed
Provenance
- Commit
085f414- Tree
5340cf1- Author
Martijn Pieters <mj@zopatista.com>- Committer
David Lord <davidism@gmail.com>- Parent
a1093bb
5 files changed+10 added−13 removed
modified:src/click/_compat.py+1 added-1 removed
481 unmodified lines482 483 def __enter__(self) -> "_AtomicFile":484 return self485 486- def __exit__(self, exc_type, exc_value, tb): # type: ignore486+ def __exit__(self, exc_type: t.Optional[t.Type[BaseException]], *_: t.Any) -> None:487 self.close(delete=exc_type is not None)488 489 def __repr__(self) -> str:490 return repr(self._f)136 unmodified linesmodified:src/click/_termui_impl.py+1 added-1 removed
96 unmodified lines97 self.entered = True98 self.render_progress()99 return self100 101- def __exit__(self, exc_type, exc_value, tb): # type: ignore101+ def __exit__(self, *_: t.Any) -> None:102 self.render_finish()103 104 def __iter__(self) -> t.Iterator[V]:105 if not self.entered:612 unmodified linesmodified:src/click/core.py+2 added-2 removed
453 unmodified lines454 self._depth += 1455 push_context(self)456 return self457 458- def __exit__(self, exc_type, exc_value, tb): # type: ignore458+ def __exit__(self, *_: t.Any) -> None:459 self._depth -= 1460 if self._depth == 0:461 self.close()462 pop_context()2353 unmodified lines2816 # value as default.2817 if self.is_flag and not self.is_bool_flag:2818 for param in ctx.command.params:2819 if param.name == self.name and param.default:2820- return param.flag_value # type: ignore2820+ return t.cast(Option, param).flag_value2821 2822 return None2823 2824 return super().get_default(ctx, call=call)174 unmodified linesmodified:src/click/types.py+4 added-7 removed
700 unmodified lines701 702 lazy = self.resolve_lazy_flag(value)703 704 if lazy:705- f: t.IO[t.Any] = t.cast(706- t.IO[t.Any],707- LazyFile(708- value, self.mode, self.encoding, self.errors, atomic=self.atomic705+ lf = LazyFile(706+ value, self.mode, self.encoding, self.errors, atomic=self.atomic709- ),707 )708 709 if ctx is not None:713- ctx.call_on_close(f.close_intelligently) # type: ignore710+ ctx.call_on_close(lf.close_intelligently)711 715- return f712+ return t.cast(t.IO[t.Any], lf)713 714 f, should_close = open_stream(715 value, self.mode, self.encoding, self.errors, atomic=self.atomic716 )354 unmodified linesmodified:src/click/utils.py+2 added-2 removed
172 unmodified lines173 174 def __enter__(self) -> "LazyFile":175 return self176 177- def __exit__(self, exc_type, exc_value, tb): # type: ignore177+ def __exit__(self, *_: t.Any) -> None:178 self.close_intelligently()179 180 def __iter__(self) -> t.Iterator[t.AnyStr]:181 self.open()9 unmodified lines191 192 def __enter__(self) -> "KeepOpenFile":193 return self194 195- def __exit__(self, exc_type, exc_value, tb): # type: ignore195+ def __exit__(self, *_: t.Any) -> None:196 pass197 198 def __repr__(self) -> str:199 return repr(self._file)383 unmodified lines