Skip to content

Commit

Permalink
TYP: some types for pandas/util/_exceptions.py (pandas-dev#29881)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins authored and proost committed Dec 19, 2019
1 parent 55c8ae0 commit c26ba76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pandas/util/_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import contextlib
from typing import Tuple


@contextlib.contextmanager
def rewrite_exception(old_name, new_name):
def rewrite_exception(old_name: str, new_name: str):
"""Rewrite the message of an exception."""
try:
yield
except Exception as err:
msg = err.args[0]
msg = msg.replace(old_name, new_name)
args = (msg,)
args: Tuple[str, ...] = (msg,)
if len(err.args) > 1:
args = args + err.args[1:]
err.args = args
Expand Down

0 comments on commit c26ba76

Please sign in to comment.