From f2f11b9178c1518e04ac709087bb294e104e3241 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 14 May 2019 23:46:09 -0400 Subject: [PATCH] Address four deprecation warnings 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\\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 '(?PSunday|Mond' (truncated) if not re.match(pattern, time): --- pendulum/formatting/formatter.py | 4 ++-- tests/formatting/test_formatter.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pendulum/formatting/formatter.py b/pendulum/formatting/formatter.py index c6ed389a..76a4db4f 100644 --- a/pendulum/formatting/formatter.py +++ b/pendulum/formatting/formatter.py @@ -25,8 +25,8 @@ _MATCH_5_TO_6 = "\d{5}\d?" _MATCH_UNSIGNED = "\d+" _MATCH_SIGNED = "[+-]?\d+" -_MATCH_OFFSET = "(?i)Z|[+-]\d\d:?\d\d" -_MATCH_SHORT_OFFSET = "(?i)Z|[+-]\d\d(?::?\d\d)?" +_MATCH_OFFSET = "[Zz]|[+-]\d\d:?\d\d" +_MATCH_SHORT_OFFSET = "[Zz]|[+-]\d\d(?::?\d\d)?" _MATCH_TIMESTAMP = "[+-]?\d+(\.\d{1,6})?" _MATCH_WORD = ( "(?i)[0-9]*" diff --git a/tests/formatting/test_formatter.py b/tests/formatting/test_formatter.py index 40f2ee8e..80bb4517 100644 --- a/tests/formatting/test_formatter.py +++ b/tests/formatting/test_formatter.py @@ -238,8 +238,8 @@ def test_date_formats(): def test_escape(): f = Formatter() d = pendulum.datetime(2016, 8, 28) - assert f.format(d, "[YYYY] YYYY \[YYYY\]") == "YYYY 2016 [2016]" - assert f.format(d, "\D D \\\D") == "D 28 \\28" + assert f.format(d, r"[YYYY] YYYY \[YYYY\]") == "YYYY 2016 [2016]" + assert f.format(d, r"\D D \\D") == "D 28 \\28" def test_date_formats_missing():