Skip to content

Commit bc4efe0

Browse files
committed
Make warnings visible
1 parent b3e3504 commit bc4efe0

File tree

7 files changed

+78
-64
lines changed

7 files changed

+78
-64
lines changed

pendulum/date.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from datetime import date, timedelta
1010
from dateutil.relativedelta import relativedelta
1111

12+
from .exceptions import PendulumDeprecationWarning
1213
from .period import Period
1314
from .formatting.difference_formatter import DifferenceFormatter
1415
from .mixins.default import TranslatableMixin, FormattableMixing, TestableMixin
@@ -118,7 +119,7 @@ def year_(self, year):
118119
warnings.warn(
119120
'The year_() method will be removed in version 2.0. '
120121
'Use set(year={}) instead.'.format(year),
121-
DeprecationWarning,
122+
PendulumDeprecationWarning,
122123
stacklevel=2
123124
)
124125

@@ -128,7 +129,7 @@ def month_(self, month):
128129
warnings.warn(
129130
'The month_() method will be removed in version 2.0. '
130131
'Use set(month={}) instead.'.format(month),
131-
DeprecationWarning,
132+
PendulumDeprecationWarning,
132133
stacklevel=2
133134
)
134135

@@ -138,7 +139,7 @@ def day_(self, day):
138139
warnings.warn(
139140
'The day_() method will be removed in version 2.0. '
140141
'Use set(day={}) instead.'.format(day),
141-
DeprecationWarning,
142+
PendulumDeprecationWarning,
142143
stacklevel=2
143144
)
144145

@@ -293,7 +294,7 @@ def between(self, dt1, dt2, equal=True):
293294
"""
294295
warnings.warn(
295296
'The between() method will be removed in version 2.0.',
296-
DeprecationWarning,
297+
PendulumDeprecationWarning,
297298
stacklevel=2
298299
)
299300

@@ -350,7 +351,7 @@ def min_(self, dt=None):
350351
"""
351352
warnings.warn(
352353
'The min_() method will be removed in version 2.0.',
353-
DeprecationWarning,
354+
PendulumDeprecationWarning,
354355
stacklevel=2
355356
)
356357

@@ -373,7 +374,7 @@ def minimum(self, dt=None):
373374
"""
374375
warnings.warn(
375376
'The minimum() method will be removed in version 2.0.',
376-
DeprecationWarning,
377+
PendulumDeprecationWarning,
377378
stacklevel=2
378379
)
379380

@@ -390,7 +391,7 @@ def max_(self, dt=None):
390391
"""
391392
warnings.warn(
392393
'The max_() method will be removed in version 2.0.',
393-
DeprecationWarning,
394+
PendulumDeprecationWarning,
394395
stacklevel=2
395396
)
396397

@@ -413,7 +414,7 @@ def maximum(self, dt=None):
413414
"""
414415
warnings.warn(
415416
'The maximum() method will be removed in version 2.0.',
416-
DeprecationWarning,
417+
PendulumDeprecationWarning,
417418
stacklevel=2
418419
)
419420

@@ -427,7 +428,7 @@ def is_weekday(self):
427428
"""
428429
warnings.warn(
429430
'The is_weekday() method will be removed in version 2.0.',
430-
DeprecationWarning,
431+
PendulumDeprecationWarning,
431432
stacklevel=2
432433
)
433434

@@ -441,7 +442,7 @@ def is_weekend(self):
441442
"""
442443
warnings.warn(
443444
'The is_weekend() method will be removed in version 2.0.',
444-
DeprecationWarning,
445+
PendulumDeprecationWarning,
445446
stacklevel=2
446447
)
447448

@@ -455,7 +456,7 @@ def is_yesterday(self):
455456
"""
456457
warnings.warn(
457458
'The is_yesterday() method will be removed in version 2.0.',
458-
DeprecationWarning,
459+
PendulumDeprecationWarning,
459460
stacklevel=2
460461
)
461462

@@ -469,7 +470,7 @@ def is_today(self):
469470
"""
470471
warnings.warn(
471472
'The is_today() method will be removed in version 2.0.',
472-
DeprecationWarning,
473+
PendulumDeprecationWarning,
473474
stacklevel=2
474475
)
475476

@@ -483,7 +484,7 @@ def is_tomorrow(self):
483484
"""
484485
warnings.warn(
485486
'The is_tomorrow() method will be removed in version 2.0.',
486-
DeprecationWarning,
487+
PendulumDeprecationWarning,
487488
stacklevel=2
488489
)
489490

@@ -533,7 +534,7 @@ def is_same_day(self, dt):
533534
"""
534535
warnings.warn(
535536
'The is_same_day() method will be removed in version 2.0.',
536-
DeprecationWarning,
537+
PendulumDeprecationWarning,
537538
stacklevel=2
538539
)
539540

@@ -547,7 +548,7 @@ def is_sunday(self):
547548
"""
548549
warnings.warn(
549550
'The is_sunday() method will be removed in version 2.0.',
550-
DeprecationWarning,
551+
PendulumDeprecationWarning,
551552
stacklevel=2
552553
)
553554

@@ -561,7 +562,7 @@ def is_monday(self):
561562
"""
562563
warnings.warn(
563564
'The is_monday() method will be removed in version 2.0.',
564-
DeprecationWarning,
565+
PendulumDeprecationWarning,
565566
stacklevel=2
566567
)
567568

@@ -575,7 +576,7 @@ def is_tuesday(self):
575576
"""
576577
warnings.warn(
577578
'The is_tuesday() method will be removed in version 2.0.',
578-
DeprecationWarning,
579+
PendulumDeprecationWarning,
579580
stacklevel=2
580581
)
581582

@@ -589,7 +590,7 @@ def is_wednesday(self):
589590
"""
590591
warnings.warn(
591592
'The is_wednesday() method will be removed in version 2.0.',
592-
DeprecationWarning,
593+
PendulumDeprecationWarning,
593594
stacklevel=2
594595
)
595596

@@ -603,7 +604,7 @@ def is_thursday(self):
603604
"""
604605
warnings.warn(
605606
'The is_thursday() method will be removed in version 2.0.',
606-
DeprecationWarning,
607+
PendulumDeprecationWarning,
607608
stacklevel=2
608609
)
609610

@@ -617,7 +618,7 @@ def is_friday(self):
617618
"""
618619
warnings.warn(
619620
'The is_friday() method will be removed in version 2.0.',
620-
DeprecationWarning,
621+
PendulumDeprecationWarning,
621622
stacklevel=2
622623
)
623624

@@ -631,7 +632,7 @@ def is_saturday(self):
631632
"""
632633
warnings.warn(
633634
'The is_saturday() method will be removed in version 2.0.',
634-
DeprecationWarning,
635+
PendulumDeprecationWarning,
635636
stacklevel=2
636637
)
637638

@@ -717,7 +718,7 @@ def add_timedelta(self, delta):
717718
"""
718719
warnings.warn(
719720
'The add_timedelta() method will be removed in version 2.0.',
720-
DeprecationWarning,
721+
PendulumDeprecationWarning,
721722
stacklevel=2
722723
)
723724

@@ -734,7 +735,7 @@ def subtract_timedelta(self, delta):
734735
"""
735736
warnings.warn(
736737
'The subtract_timedelta() method will be removed in version 2.0.',
737-
DeprecationWarning,
738+
PendulumDeprecationWarning,
738739
stacklevel=2
739740
)
740741

pendulum/exceptions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# -*- coding: utf-8 -*-
22

3-
from .parsing.exceptions import ParserError
4-
53

64
class PendulumException(BaseException):
75

86
pass
7+
8+
9+
class PendulumWarning(Warning):
10+
11+
pass
12+
13+
14+
class PendulumDeprecationWarning(PendulumWarning):
15+
16+
pass

pendulum/mixins/default.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from contextlib import contextmanager
77

8+
from ..exceptions import PendulumDeprecationWarning
89
from ..translator import Translator
910
from ..formatting import FORMATTERS
1011

@@ -82,7 +83,7 @@ def reset_to_string_format(cls):
8283
warnings.warn(
8384
'The reset_to_string_format() helper '
8485
'will be removed in version 2.0.',
85-
DeprecationWarning,
86+
PendulumDeprecationWarning,
8687
stacklevel=2
8788
)
8889
cls.set_to_string_format(cls.DEFAULT_TO_STRING_FORMAT)
@@ -98,7 +99,7 @@ def set_to_string_format(cls, fmt):
9899
warnings.warn(
99100
'The set_to_string_format() helper '
100101
'will be removed in version 2.0.',
101-
DeprecationWarning,
102+
PendulumDeprecationWarning,
102103
stacklevel=2
103104
)
104105
cls._to_string_format = fmt

pendulum/parsing/parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from datetime import datetime, date, time
88
from dateutil import parser
99

10+
from ..exceptions import PendulumDeprecationWarning
1011
from ..helpers import parse_iso8601, week_day, days_in_year
1112
from .exceptions import ParserError
1213

@@ -68,7 +69,7 @@ def __init__(self, **options):
6869
warnings.warn(
6970
'The "strict" keyword when parsing will have '
7071
'another meaning in version 2.0. Use "exact" instead.',
71-
DeprecationWarning,
72+
PendulumDeprecationWarning,
7273
stacklevel=2
7374
)
7475

@@ -80,7 +81,7 @@ def __init__(self, **options):
8081
def is_strict(self):
8182
warnings.warn(
8283
'is_strict() is deprecated. Use is_exact() instead.',
83-
DeprecationWarning,
84+
PendulumDeprecationWarning,
8485
stacklevel=2
8586
)
8687

0 commit comments

Comments
 (0)