Skip to content

Commit 837ee66

Browse files
committed
Move SourceLocation formatting to SourceLocation.formatted
1 parent 6ff8f4d commit 837ee66

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/graphql/error/format_error.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def format_error(error: "GraphQLError") -> Dict[str, Any]:
1818
formatted: Dict[str, Any] = dict( # noqa: E701 (pycqa/flake8#394)
1919
message=error.message or "An unknown error occurred.",
2020
locations=(
21-
[{"line": l.line, "column": l.column} for l in error.locations]
21+
[location.formatted for location in error.locations]
2222
if error.locations is not None
2323
else None
2424
),

src/graphql/language/location.py

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class SourceLocation(NamedTuple):
1212
line: int
1313
column: int
1414

15+
@property
16+
def formatted(self):
17+
return dict(line=self.line, column=self.column)
18+
1519

1620
def get_location(source: "Source", position: int) -> SourceLocation:
1721
"""Get the line and column for a character position in the source.

0 commit comments

Comments
 (0)