black
black copied to clipboard
is_type_comment() is wrong
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 :.
I think there is also the pragmas in contains_pragma_comment at: comment.value.startswith(("# type:", "# noqa", "# pylint:")
Should we also standardise spaces before the colon? Meaning we would accept (and fix) e.g. # type : Type or even # \t type : (some unexpected whitespace type) Type?
Hey everyone! Can I get some maintainer reivews on the PR?
@Pierre-Sassoulas Hello... I am new here and I would like to start contributing in the repository. So can you please assign this issue to me Thank you
Hey @IshanKamboj, sorry I'm not a black maintainer. I think you can start implementing right away and open a PR though :)
hello i am new here and would like to contribute to the project can you help me out