From 53301730d33bacd28905bc6dc800fb02f9be4e12 Mon Sep 17 00:00:00 2001 From: Aashka1 <139986503+Aashka1@users.noreply.github.com> Date: Wed, 1 Nov 2023 18:19:36 +0530 Subject: [PATCH] #2097 issue: is_type_comment() update --- src/black/nodes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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: