Say I have a simple program:
1 def foo():
2 pass
3
4 def bar():
5 pass
Given line number 1 or 2, I want to know it belongs to function foo.
Same with 4 or 5 for function bar.
What's the easiest way to do it? For simplicity, let's just assume "scope" means function or method.
I'm looking at libCST as it provides the code position metadata, but it does not provide a mapping from line number to its scope.