Skip to content

Commit

Permalink
Deprecate Date arithmetic with tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Jan 29, 2024
1 parent 5435d0e commit a6ee1d3
Showing 1 changed file with 4 additions and 0 deletions.
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

0 comments on commit a6ee1d3

Please sign in to comment.