Skip to content

Commit

Permalink
psf#2097 issue: is_type_comment() update
Browse files Browse the repository at this point in the history
  • Loading branch information
Aashka1 committed Nov 1, 2023
1 parent 5758da6 commit 5330173
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/black/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5330173

Please sign in to comment.