New submission from Michael Sullivan <msully4...@gmail.com>:

Per discussion during the typing summit at PyCon, it would be a good idea to 
allow extra information to be included in `# type: ignore` comments, in order 
to allow behavior such as suppressing individual errors (for example, with 
syntax like `# type: ignore[E1000]`, to suppress error 1000).

My proposal, then, is to generalize the definition of type: ignore comments to 
be `# type: ignore followed by a non-alphanumeric character. Then `# type: 
ignore[E1000]` and `# type: ignore E1000` would be valid type ignore comments 
while `# type: ignoreE1000` would not be.

Now that ast.parse can parse type_comments, this needs to make it into 3.8, 
basically, if we want to do this and be able to use the ast type_comment 
feature.

Ideally, the text of the type ignore would be actually included in the produced 
AST. As a bare minimum first step, we need to recognize type ignores with extra 
information and report them (and, critically, not detect them as regular type 
comments and produce errors when they appear in unexpected places).

I'll put up a PR to do the second part shortly.

----------
components: Interpreter Core
messages: 342130
nosy: gvanrossum, levkivskyi, msullivan
priority: normal
severity: normal
status: open
title: ast.parse with type_comments=True should allow extra text after # type: 
ignore
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36878>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to