]> git.madduck.net Git - etc/vim.git/blobdiff - src/blib2to3/pgen2/pgen.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:

exclude tests/data/.* from mypy (#3917)
[etc/vim.git] / src / blib2to3 / pgen2 / pgen.py
index 046efd09338c81866432975cbe108f3e201b420a..3ece9bb41edd51c7d2d82a317cb14dafcea4f1f4 100644 (file)
@@ -1,25 +1,22 @@
 # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
 # Licensed to PSF under a Contributor Agreement.
 
 # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
 # Licensed to PSF under a Contributor Agreement.
 
-# Pgen imports
-from . import grammar, token, tokenize
-
+import os
 from typing import (
 from typing import (
+    IO,
     Any,
     Dict,
     Any,
     Dict,
-    IO,
     Iterator,
     List,
     Iterator,
     List,
+    NoReturn,
     Optional,
     Optional,
+    Sequence,
     Tuple,
     Union,
     Tuple,
     Union,
-    Sequence,
-    NoReturn,
 )
 )
-from blib2to3.pgen2 import grammar
-from blib2to3.pgen2.tokenize import GoodTokenInfo
-import os
 
 
+from blib2to3.pgen2 import grammar, token, tokenize
+from blib2to3.pgen2.tokenize import GoodTokenInfo
 
 Path = Union[str, "os.PathLike[str]"]
 
 
 Path = Union[str, "os.PathLike[str]"]
 
@@ -149,7 +146,7 @@ class ParserGenerator:
         state = dfa[0]
         totalset: Dict[str, int] = {}
         overlapcheck = {}
         state = dfa[0]
         totalset: Dict[str, int] = {}
         overlapcheck = {}
-        for label, next in state.arcs.items():
+        for label in state.arcs:
             if label in self.dfas:
                 if label in self.first:
                     fset = self.first[label]
             if label in self.dfas:
                 if label in self.first:
                     fset = self.first[label]
@@ -190,9 +187,9 @@ class ParserGenerator:
             # self.dump_nfa(name, a, z)
             dfa = self.make_dfa(a, z)
             # self.dump_dfa(name, dfa)
             # self.dump_nfa(name, a, z)
             dfa = self.make_dfa(a, z)
             # self.dump_dfa(name, dfa)
-            oldlen = len(dfa)
+            oldlen = len(dfa)
             self.simplify_dfa(dfa)
             self.simplify_dfa(dfa)
-            newlen = len(dfa)
+            newlen = len(dfa)
             dfas[name] = dfa
             # print name, oldlen, newlen
             if startsymbol is None:
             dfas[name] = dfa
             # print name, oldlen, newlen
             if startsymbol is None:
@@ -346,7 +343,7 @@ class ParserGenerator:
             self.raise_error(
                 "expected (...) or NAME or STRING, got %s/%s", self.type, self.value
             )
             self.raise_error(
                 "expected (...) or NAME or STRING, got %s/%s", self.type, self.value
             )
-            assert False
+            raise AssertionError
 
     def expect(self, type: int, value: Optional[Any] = None) -> str:
         if self.type != type or (value is not None and self.value != value):
 
     def expect(self, type: int, value: Optional[Any] = None) -> str:
         if self.type != type or (value is not None and self.value != value):
@@ -368,7 +365,7 @@ class ParserGenerator:
         if args:
             try:
                 msg = msg % args
         if args:
             try:
                 msg = msg % args
-            except:
+            except Exception:
                 msg = " ".join([msg] + list(map(str, args)))
         raise SyntaxError(msg, (self.filename, self.end[0], self.end[1], self.line))
 
                 msg = " ".join([msg] + list(map(str, args)))
         raise SyntaxError(msg, (self.filename, self.end[0], self.end[1], self.line))