Skip to content

Commit

Permalink
Slight improvement
Browse files Browse the repository at this point in the history
Raise exception earlier and use `self.BadSyntax` for raising it.
  • Loading branch information
aucampia committed Jul 4, 2023
1 parent c498d99 commit a6ca291
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rdflib/plugins/parsers/trig.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ def graph(self, argstr: str, i: int) -> int:

j = i + 1

if self._context is not None:
self.BadSyntax(argstr, i, "Nested graphs are not allowed")

oldParentContext = self._parentContext
self._parentContext = self._context
reason2 = self._reason2
self._reason2 = becauseSubGraph
# type error: Incompatible types in assignment (expression has type "Graph", variable has type "Optional[Formula]")
self._context = self._store.newGraph(graph) # type: ignore[assignment]
if self._context is not None and self._parentContext is not None:
raise SyntaxError("GRAPH may not include a GRAPH " "(#trig-graph-bad-07)")

while 1:
i = self.skipSpace(argstr, j)
Expand Down

0 comments on commit a6ca291

Please sign in to comment.