MCPcopy Index your code
hub / github.com/python/cpython / contextual_wrapper

Function contextual_wrapper

Tools/cases_generator/parsing.py:19–27  ·  view source on GitHub ↗
(self: P)

Source from the content-addressed store, hash-verified

17 # Decorator to wrap grammar methods.
18 # Resets position if `func` returns None.
19 def contextual_wrapper(self: P) -> N | None:
20 begin = self.getpos()
21 res = func(self)
22 if res is None:
23 self.setpos(begin)
24 return None
25 end = self.getpos()
26 res.context = Context(begin, end, self)
27 return res
28
29 return contextual_wrapper
30

Callers

nothing calls this directly

Calls 4

ContextClass · 0.70
funcFunction · 0.50
getposMethod · 0.45
setposMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…