diff --git a/src/black/nodes.py b/src/black/nodes.py index 5f6b280c035..2ea9c2c5915 100644 --- a/src/black/nodes.py +++ b/src/black/nodes.py @@ -838,14 +838,14 @@ def is_async_stmt_or_funcdef(leaf: Leaf) -> bool: ) -def is_type_comment(leaf: Leaf) -> bool: +def is_type_comment(leaf: Leaf,suffix,str="") -> bool: """Return True if the given leaf is a type comment. This function should only be used for general type comments (excluding ignore annotations, which should use `is_type_ignore_comment`). Note that general type comments are no longer used in modern version of Python, this function may be deprecated in the future.""" t = leaf.type - v = leaf.value - return t in {token.COMMENT, STANDALONE_COMMENT} and v.startswith("# type:") + v = leaf.value.strip() + return t in {token.COMMENT, STANDALONE_COMMENT} and v.startswith("# type:"+suffix) def is_type_ignore_comment(leaf: Leaf) -> bool: