pyflakes icon indicating copy to clipboard operation
pyflakes copied to clipboard

Use `ast.parse(type_comments=True)` instead of `file_tokens` on Python 3.8+

Open collinanderson opened this issue 2 years ago • 3 comments

Python 3.8 added the ability to include type comments in the abstract syntax tree.

Currently pyflakes uses tokenize to find the comments, which is slow. Using type_comments from ast when available would be much faster.

collinanderson avatar Mar 22 '22 17:03 collinanderson

maybe a better option would be to drop the type comments support entirely -- now that python 2 is very obsolete

the problem with type_comments=True is pyflakes has no way to signal to flake8 that it needs a special ast parse

asottile avatar Mar 23 '22 04:03 asottile

Ahh, yeah, that makes sense.

collinanderson avatar Mar 23 '22 13:03 collinanderson

let's keep this open in case we decide to drop comments

asottile avatar Mar 23 '22 14:03 asottile