Skip to content

Commit 8d63f1e

Browse files
committed
parser: simplify a few utility functions
Replicates graphql/graphql-js@2c31905
1 parent 46253f3 commit 8d63f1e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/graphql/language/printer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def block(strings: Optional[Strings]) -> str:
399399
Given a collection of strings, return a string with each item on its own line,
400400
wrapped in an indented "{ }" block.
401401
"""
402-
return "{\n" + indent(join(strings, "\n")) + "\n}" if strings else ""
402+
return wrap("{\n", indent(join(strings, "\n")), "\n}")
403403

404404

405405
def wrap(start: str, string: Optional[str], end: str = "") -> str:
@@ -417,7 +417,7 @@ def indent(string: str) -> str:
417417
If the string is not None or empty, add two spaces at the beginning of every line
418418
inside the string.
419419
"""
420-
return " " + string.replace("\n", "\n ") if string else string
420+
return wrap(" ", string.replace("\n", "\n "))
421421

422422

423423
def is_multiline(string: str) -> bool:

0 commit comments

Comments
 (0)