Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Date arithmetic with tuples #612

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SWIG/date.i
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,15 @@ Date._old___add__ = Date.__add__
Date._old___sub__ = Date.__sub__
def Date_new___add__(self,x):
if type(x) is tuple and len(x) == 2:
from warnings import warn
warn(f'adding a tuple to a Date is deprecated; use a Period instance', FutureWarning, stacklevel=2)
return self._old___add__(Period(x[0],x[1]))
else:
return self._old___add__(x)
def Date_new___sub__(self,x):
if type(x) is tuple and len(x) == 2:
from warnings import warn
warn(f'subtracting a tuple from a Date is deprecated; use a Period instance', FutureWarning, stacklevel=2)
return self._old___sub__(Period(x[0],x[1]))
else:
return self._old___sub__(x)
Expand Down
Loading