Repository: python/mypy

Issue:
Deprecation warnings in test files
`test-data/stdlib-samples/3.2/fnmatch.py` and `test-data/stdlib-samples/3.2/test/test_fnmatch.py` contain unmarked raw strings that will produce `DeprecationWarning`s when parsed with `typed-ast` and Python 3.7. See for example here: https://travis-ci.org/python/typeshed/jobs/444824883

These are easy to fix (PR is ready), but I wonder whether they should be, since these files seem to be pristine copies from Python 3.2's standard library. On the other hand not fixing them leads to spurious warning output and might even break tests in future Python versions.



Discussion:
I recently noticed this too (I moved drives and upgraded to 3.7 😄), and I think that we should just make them raw strings. Some of the samples are type annotated, so the samples aren't pristine. Even if they were, I don't think changing this would be an issue.
Agreed, just fix them.

On Mon, Oct 22, 2018 at 4:45 PM Ethan Smith <notifications@github.com>
wrote:

> I recently noticed this too, and I think that we should just make them raw
> strings. Some of the samples are type annotated, so the samples aren't
> pristine. Even if they were, I don't think changing this would be an issue.
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/python/mypy/issues/5820#issuecomment-432030788>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/ACwrMoHPhBDocCfepTz3Wus_NCzS8bHlks5unli2gaJpZM4X0ZNL>
> .
>
-- 
--Guido (mobile)


Resolving patch:
diff --git a/test-data/stdlib-samples/3.2/fnmatch.py b/test-data/stdlib-samples/3.2/fnmatch.py
--- a/test-data/stdlib-samples/3.2/fnmatch.py
+++ b/test-data/stdlib-samples/3.2/fnmatch.py
@@ -109,4 +109,4 @@ def translate(pat: str) -> str:
                 res = '%s[%s]' % (res, stuff)
         else:
             res = res + re.escape(c)
-    return res + '\Z(?ms)'
+    return res + r'\Z(?ms)'


Test patch:
diff --git a/test-data/stdlib-samples/3.2/test/test_fnmatch.py b/test-data/stdlib-samples/3.2/test/test_fnmatch.py
--- a/test-data/stdlib-samples/3.2/test/test_fnmatch.py
+++ b/test-data/stdlib-samples/3.2/test/test_fnmatch.py
@@ -67,14 +67,14 @@ def test_bytes(self) -> None:
 class TranslateTestCase(unittest.TestCase):
 
     def test_translate(self) -> None:
-        self.assertEqual(translate('*'), '.*\Z(?ms)')
-        self.assertEqual(translate('?'), '.\Z(?ms)')
-        self.assertEqual(translate('a?b*'), 'a.b.*\Z(?ms)')
-        self.assertEqual(translate('[abc]'), '[abc]\Z(?ms)')
-        self.assertEqual(translate('[]]'), '[]]\Z(?ms)')
-        self.assertEqual(translate('[!x]'), '[^x]\Z(?ms)')
-        self.assertEqual(translate('[^x]'), '[\\^x]\Z(?ms)')
-        self.assertEqual(translate('[x'), '\\[x\Z(?ms)')
+        self.assertEqual(translate('*'), r'.*\Z(?ms)')
+        self.assertEqual(translate('?'), r'.\Z(?ms)')
+        self.assertEqual(translate('a?b*'), r'a.b.*\Z(?ms)')
+        self.assertEqual(translate('[abc]'), r'[abc]\Z(?ms)')
+        self.assertEqual(translate('[]]'), r'[]]\Z(?ms)')
+        self.assertEqual(translate('[!x]'), r'[^x]\Z(?ms)')
+        self.assertEqual(translate('[^x]'), r'[\\^x]\Z(?ms)')
+        self.assertEqual(translate('[x'), r'\\[x\Z(?ms)')
 
 
 class FilterTestCase(unittest.TestCase):