Skip to content
Myr

Merge pull request #2074 from pallets/except-chain

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

use exception chaining

authored by David Lord · committed by GitHub · parents 737cf79, 905b1bf · Browse files · 6 files+10 added−10 removed
This commit

State

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

Diff stats

6 files+10 added−10 removed

  • other:+10 added−10 removed

6 files+10 added−10 removed

modified:src/click/_termui_impl.py+1 added-1 removed
496 unmodified lines
497 )498 except OSError as e:499 raise ClickException(500 _("{editor}: Editing failed: {e}").format(editor=editor, e=e)501 )501 ) from e502503 def edit(self, text: t.Optional[t.AnyStr]) -> t.Optional[t.AnyStr]:504 import tempfile505
213 unmodified lines
modified:src/click/core.py+1 added-1 removed
1059 unmodified lines
1060 # by its truthiness/falsiness1061 ctx.exit()1062 except (EOFError, KeyboardInterrupt):1063 echo(file=sys.stderr)1064 raise Abort()1064 raise Abort() from None1065 except ClickException as e:1066 if not standalone_mode:1067 raise1068 e.show()
1879 unmodified lines
modified:src/click/decorators.py+1 added-1 removed
378 unmodified lines
379 except metadata.PackageNotFoundError: # type: ignore380 raise RuntimeError(381 f"{package_name!r} is not installed. Try passing"382 " 'package_name' instead."383 )383 ) from None384385 if version is None:386 raise RuntimeError(387 f"Could not determine the version for {package_name!r} automatically."
49 unmodified lines
modified:src/click/globals.py+2 added-2 removed
34 unmodified lines
35 :exc:`RuntimeError`.36 """37 try:38 return t.cast("Context", _local.stack[-1])39 except (AttributeError, IndexError):39 except (AttributeError, IndexError) as e:40 if not silent:41 raise RuntimeError("There is no active click context.")41 raise RuntimeError("There is no active click context.") from e4243 return None4445
24 unmodified lines
modified:src/click/termui.py+4 added-4 removed
145 unmodified lines
146 # Allegedly this behavior is inherited from getpass(3).147 # A doc bug has been filed at https://bugs.python.org/issue24711148 if hide_input:149 echo(None, err=err)150 raise Abort()150 raise Abort() from None151152 if value_proc is None:153 value_proc = convert_type(type, default)154
78 unmodified lines
233 # coloring through colorama on Windows234 echo(prompt, nl=False, err=err)235 value = visible_prompt_func("").lower().strip()236 except (KeyboardInterrupt, EOFError):237 raise Abort()237 raise Abort() from None238 if value in ("y", "yes"):239 rv = True240 elif value in ("n", "no"):241 rv = False
338 unmodified lines
580 if fg:581 try:582 bits.append(f"\033[{_interpret_color(fg)}m")583 except KeyError:584 raise TypeError(f"Unknown color {fg!r}")584 raise TypeError(f"Unknown color {fg!r}") from None585586 if bg:587 try:588 bits.append(f"\033[{_interpret_color(bg, 10)}m")589 except KeyError:590 raise TypeError(f"Unknown color {bg!r}")590 raise TypeError(f"Unknown color {bg!r}") from None591592 if bold is not None:593 bits.append(f"\033[{1 if bold else 22}m")594 if dim is not None:
213 unmodified lines
modified:src/click/utils.py+1 added-1 removed
152 unmodified lines
153 )154 except OSError as e: # noqa: E402155 from .exceptions import FileError156157 raise FileError(self.name, hint=e.strerror)157 raise FileError(self.name, hint=e.strerror) from e158 self._f = rv159 return rv160161 def close(self) -> None:
418 unmodified lines