Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python annotation navigation behaviors #92

Open
2kays opened this issue Mar 11, 2024 · 2 comments
Open

Python annotation navigation behaviors #92

2kays opened this issue Mar 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@2kays
Copy link

2kays commented Mar 11, 2024

In Python, hierarchical navigations behave unexpectedly (to me) with annotations and function definitions (in master).

Example code:

@|annot # descending from here takes me to the function arglist
def fun1(): return 1
| # can't prev/up navigate

|@|annot() # hierarchical nav can never enter function definition for these cursors
def fun2(): return 2
| # can't up/prev navigate 
(decorated_definition
 (decorator @ (identifier))
 definition: 
  (function_definition def name: (identifier)
   parameters: (parameters ( ))
   :
   body: 
    (block
     (return_statement return (integer)))))

Something similar may also be happening with try-except; I'm struggling to get into the except handler.

@mickeynp
Copy link
Owner

Getting into except from 'try' is not easy because it's a child of the whole try_statement, so sibling navigation from try to except is not possible.

Well, it is, and I did try it for a while, but changing the sibling procedure to handle it breaks in other weird ways: you'd be able to drag an except clause out of a try statement, which makes no sense. This is one of those quirks of how our perception of code does not match the grammar.

You're definitely right that decorators do not behave well at all. That's a bug :)

@mickeynp mickeynp added the bug Something isn't working label Mar 12, 2024
@2kays
Copy link
Author

2kays commented Mar 12, 2024

I can confirm there is no hierarchical nav tool that can get me into except:

|try:| # nope, nope
    |pass| # nope, nope
except KeyError:
    pass

I see a double body: in the explorer:

(try_statement try :
  body: 
   (block
    (pass_statement pass))
  body: 
   (except_clause except (identifier) :
    (block
     (pass_statement pass))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants