]> git.madduck.net Git - etc/vim.git/blobdiff - blib2to3/pgen2/literals.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Tell people where Change Log went
[etc/vim.git] / blib2to3 / pgen2 / literals.py
index 93bee528a14c22b568fe49dfd331eb3759873d31..b5fe42851148e7fd6270ae728a0327f1523dd4b5 100644 (file)
@@ -3,9 +3,12 @@
 
 """Safely evaluate Python string literals without using eval()."""
 
-import regex as re
+import re
 
-simple_escapes = {
+from typing import Dict, Match, Text
+
+
+simple_escapes: Dict[Text, Text] = {
     "a": "\a",
     "b": "\b",
     "f": "\f",
@@ -19,7 +22,7 @@ simple_escapes = {
 }
 
 
-def escape(m):
+def escape(m: Match[Text]) -> Text:
     all, tail = m.group(0, 1)
     assert all.startswith("\\")
     esc = simple_escapes.get(tail)
@@ -41,7 +44,7 @@ def escape(m):
     return chr(i)
 
 
-def evalString(s):
+def evalString(s: Text) -> Text:
     assert s.startswith("'") or s.startswith('"'), repr(s[:1])
     q = s[0]
     if s[:3] == q * 3:
@@ -52,7 +55,7 @@ def evalString(s):
     return re.sub(r"\\(\'|\"|\\|[abfnrtv]|x.{0,2}|[0-7]{1,3})", escape, s)
 
 
-def test():
+def test() -> None:
     for i in range(256):
         c = chr(i)
         s = repr(c)