Inspection of arguments in function cause inspection of surrounding function
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start in ipykernel/ipkernel.py around lines 544-546 and inspect how do_inspect uses generate_tokens, token_at_cursor, and the surrounding cursor handling. Reproduce the provided func(param1, param2=arg) example, then verify that cursors on arguments identify those arguments rather than the surrounding function.
Written by the indexing model from the issue text.
Description
At the moment inspection of arguments in function calls is not possible as the function is inspected instead. This is because do_inspect relies on IPython.utils.tokenutil.generate_tokens:
The behaviour of generate_tokens has changed in https://github.com/ipython/ipython/commit/240eef90ab769a25100eb9f2c4247d775e6c160c . Before it would return the tokens of names, including parameters and names, even if they were inside a function call. Not all edge cases were handled correctly, but for most day-to-day inspection tasks were served fine. Now generate_tokens returns function names if the cursor is positioned inside the parentheses:
from IPython.utils.tokenutil import generate_tokens, token_at_cursor
from io import StringIO
code = 'func(param1, param2=arg)'
tokens = list(generate_tokens(StringIO(code).readline))
pos = dict(func=3, param1=8, param2=15, arg=22)
# Current behaviour
dict((k, token_at_cursor(code, v) for k, v in pos.items())
# Output: {'func': 'func', 'param1': 'func', 'param2': 'func', 'arg': 'func'}
- Dominant language
- Python
- Stars
- 734
- Forks
- 411
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ipython/ipykernel
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
ipython/ipykernel#1550 · 1 comment · 1 reaction · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
All issues in ipython/ipykernel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Openarea: ci bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-connect#1057 ·