forked from psf/black
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
is_type_comment now checks for extra or zero spaces (psf#2097)
- Loading branch information
1 parent
b7d0e72
commit 67119b9
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Test the black.nodes module.""" | ||
|
||
import pytest | ||
|
||
from black import Leaf, token | ||
from black.nodes import is_type_comment | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"comment_text, expected", | ||
[ | ||
("# type: int", True), | ||
("#type:int", True), | ||
("# type: str", True), | ||
("# type :List[int]", False), | ||
("# type : Dict[str, Any]", False), | ||
("#type :", False), | ||
("#type: ", True), | ||
("#", False), | ||
("# some other comment type: ", False), | ||
("# type", False), | ||
("# type:", True), | ||
("# type :", False), | ||
], | ||
) | ||
def test_is_type_comment(comment_text: str, expected: bool) -> None: | ||
leaf = Leaf(token.COMMENT, comment_text) | ||
assert is_type_comment(leaf) == expected |