Use is_number_token instead of assertion (#3069)
This commit is contained in:
parent
8c8675c62a
commit
162ecd1d2c
@ -40,7 +40,7 @@
|
||||
from black.const import DEFAULT_LINE_LENGTH, DEFAULT_INCLUDES, DEFAULT_EXCLUDES
|
||||
from black.const import STDIN_PLACEHOLDER
|
||||
from black.nodes import STARS, syms, is_simple_decorator_expression
|
||||
from black.nodes import is_string_token
|
||||
from black.nodes import is_string_token, is_number_token
|
||||
from black.lines import Line, EmptyLineTracker
|
||||
from black.linegen import transform_line, LineGenerator, LN
|
||||
from black.comments import normalize_fmt_off
|
||||
@ -1245,8 +1245,7 @@ def get_features_used( # noqa: C901
|
||||
if value_head in {'f"', 'F"', "f'", "F'", "rf", "fr", "RF", "FR"}:
|
||||
features.add(Feature.F_STRINGS)
|
||||
|
||||
elif n.type == token.NUMBER:
|
||||
assert isinstance(n, Leaf)
|
||||
elif is_number_token(n):
|
||||
if "_" in n.value:
|
||||
features.add(Feature.NUMERIC_UNDERSCORES)
|
||||
|
||||
|
@ -854,3 +854,7 @@ def is_rpar_token(nl: NL) -> TypeGuard[Leaf]:
|
||||
|
||||
def is_string_token(nl: NL) -> TypeGuard[Leaf]:
|
||||
return nl.type == token.STRING
|
||||
|
||||
|
||||
def is_number_token(nl: NL) -> TypeGuard[Leaf]:
|
||||
return nl.type == token.NUMBER
|
||||
|
Loading…
Reference in New Issue
Block a user