Skip to content

Commit 0a96016

Browse files
altendkysdispater
authored andcommitted
Address four deprecation warnings (#375)
tests/formatting/test_formatter.py:241 /home/altendky/pendulum/tests/formatting/test_formatter.py:241: DeprecationWarning: invalid escape sequence \[ assert f.format(d, "[YYYY] YYYY \[YYYY\]") == "YYYY 2016 [2016]" tests/formatting/test_formatter.py:242 /home/altendky/pendulum/tests/formatting/test_formatter.py:242: DeprecationWarning: invalid escape sequence \D assert f.format(d, "\D D \\\D") == "D 28 \\28" tests/datetime/test_from_format.py::test_from_format_with_escaped_elements /home/altendky/pendulum/pendulum/formatting/formatter.py:406: DeprecationWarning: Flags not at the start of the expression '(?P<YYYY>\\d{1,4}|\\d{' (truncated) if not re.match(pattern, time): tests/datetime/test_from_format.py::test_from_format[Thursday 25th December 1975 02:15:16 PM -05:00-dddd Do MMMM YYYY hh:mm:ss A Z-1975-12-25T14:15:16-05:00-None] /home/altendky/pendulum/pendulum/formatting/formatter.py:406: DeprecationWarning: Flags not at the start of the expression '(?P<dddd>Sunday|Mond' (truncated) if not re.match(pattern, time):
1 parent 94d28b0 commit 0a96016

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pendulum/formatting/formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
_MATCH_5_TO_6 = "\d{5}\d?"
2626
_MATCH_UNSIGNED = "\d+"
2727
_MATCH_SIGNED = "[+-]?\d+"
28-
_MATCH_OFFSET = "(?i)Z|[+-]\d\d:?\d\d"
29-
_MATCH_SHORT_OFFSET = "(?i)Z|[+-]\d\d(?::?\d\d)?"
28+
_MATCH_OFFSET = "[Zz]|[+-]\d\d:?\d\d"
29+
_MATCH_SHORT_OFFSET = "[Zz]|[+-]\d\d(?::?\d\d)?"
3030
_MATCH_TIMESTAMP = "[+-]?\d+(\.\d{1,6})?"
3131
_MATCH_WORD = (
3232
"(?i)[0-9]*"

tests/formatting/test_formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def test_date_formats():
238238
def test_escape():
239239
f = Formatter()
240240
d = pendulum.datetime(2016, 8, 28)
241-
assert f.format(d, "[YYYY] YYYY \[YYYY\]") == "YYYY 2016 [2016]"
242-
assert f.format(d, "\D D \\\D") == "D 28 \\28"
241+
assert f.format(d, r"[YYYY] YYYY \[YYYY\]") == "YYYY 2016 [2016]"
242+
assert f.format(d, r"\D D \\D") == "D 28 \\28"
243243

244244

245245
def test_date_formats_missing():

0 commit comments

Comments
 (0)