-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use is_name_token to resolve type:ignore
- Loading branch information
1 parent
e025308
commit 776d931
Showing
4 changed files
with
36 additions
and
14 deletions.
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
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 |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
|
||
# mypy: allow-untyped-defs | ||
|
||
import sys | ||
|
||
from typing import ( | ||
Any, | ||
Dict, | ||
|
@@ -25,7 +27,13 @@ | |
Set, | ||
Iterable, | ||
) | ||
|
||
if sys.version_info >= (3, 10): | ||
from typing import TypeGuard | ||
else: | ||
from typing_extensions import TypeGuard | ||
from blib2to3.pgen2.grammar import Grammar | ||
from blib2to3.pgen2 import token | ||
|
||
__author__ = "Guido van Rossum <[email protected]>" | ||
|
||
|
@@ -978,3 +986,16 @@ def generate_matches( | |
r.update(r0) | ||
r.update(r1) | ||
yield c0 + c1, r | ||
|
||
|
||
def is_name_token(nl: NL) -> TypeGuard[Leaf]: | ||
return nl.type == token.NAME | ||
|
||
def is_lpar_token(nl: NL) -> TypeGuard[Leaf]: | ||
return nl.type == token.LPAR | ||
|
||
def is_rpar_token(nl: NL) -> TypeGuard[Leaf]: | ||
return nl.type == token.RPAR | ||
|
||
def is_string_token(nl: NL) -> TypeGuard[Leaf]: | ||
return nl.type == token.STRING |