Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Jul 5, 2023
1 parent 8c96168 commit 1ac6118
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/black/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import ast
import sys
from typing import Any, Final, Iterable, Iterator, List, Set, Tuple, Type
from typing import Final, Iterable, Iterator, List, Set, Tuple

from black.mode import VERSION_TO_FEATURES, Feature, TargetVersion, supports_feature
from black.nodes import syms
Expand Down Expand Up @@ -164,9 +164,18 @@ def _normalize(lineend: str, value: str) -> str:
def stringify_ast(node: ast.AST, depth: int = 0) -> Iterator[str]:
"""Simple visitor generating strings to compare ASTs by content."""

if (
isinstance(node, ast.Constant)
and isinstance(node.value, str)
and node.kind == "u"
):
# It's a quirk of history that we strip the u prefix over here. We used to
# rewrite the AST nodes for Python version compatibility and we never copied
# over the kind
node.kind = None

yield f"{' ' * depth}{node.__class__.__name__}("

type_ignore_classes: Tuple[Type[Any], ...]
for field in sorted(node._fields): # noqa: F402
# TypeIgnore has only one field 'lineno' which breaks this comparison
if isinstance(node, ast.TypeIgnore):
Expand Down

0 comments on commit 1ac6118

Please sign in to comment.