-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
F: commentsThe syntactic kind. Not in the language grammar, always on our minds. Best bugs.The syntactic kind. Not in the language grammar, always on our minds. Best bugs.T: bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Currently, the implementation of is_type_comment() looks like this:
def is_type_comment(leaf: Leaf, suffix: str = "") -> bool:
"""Return True if the given leaf is a special comment.
Only returns true for type comments for now."""
t = leaf.type
v = leaf.value
return t in {token.COMMENT, STANDALONE_COMMENT} and v.startswith("# type:" + suffix)
But this is wrong, because typed-ast also recognizes a comment with multiple spaces after the # as a type comment. Concretely this could lead Black to skip some of the checks we have to avoid moving type comments to the wrong line.
Ideally, Black should also standardize the formatting of type comments by cleaning up excessive whitespace after the # and after the :.
Pierre-Sassoulas
Metadata
Metadata
Assignees
Labels
F: commentsThe syntactic kind. Not in the language grammar, always on our minds. Best bugs.The syntactic kind. Not in the language grammar, always on our minds. Best bugs.T: bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers