mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-36878: Track extra text added to 'type: ignore' in the AST (GH-13479)
GH-13238 made extra text after a # type: ignore accepted by the parser. This finishes the job and actually plumbs the extra text through the parser and makes it available in the AST.
This commit is contained in:
parent
4c7a46eb3c
commit
933e1509ec
9 changed files with 86 additions and 26 deletions
|
@ -272,7 +272,16 @@ class TypeCommentTests(unittest.TestCase):
|
|||
|
||||
def test_ignores(self):
|
||||
for tree in self.parse_all(ignores):
|
||||
self.assertEqual([ti.lineno for ti in tree.type_ignores], [2, 5, 8, 9, 10, 11])
|
||||
self.assertEqual(
|
||||
[(ti.lineno, ti.tag) for ti in tree.type_ignores],
|
||||
[
|
||||
(2, ''),
|
||||
(5, ''),
|
||||
(8, '[excuse]'),
|
||||
(9, '=excuse'),
|
||||
(10, ' [excuse]'),
|
||||
(11, ' whatever'),
|
||||
])
|
||||
tree = self.classic_parse(ignores)
|
||||
self.assertEqual(tree.type_ignores, [])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue