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

Incorrect SyntaxError report? #536

Closed
bburan opened this issue Nov 21, 2023 · 3 comments
Closed

Incorrect SyntaxError report? #536

bburan opened this issue Nov 21, 2023 · 3 comments

Comments

@bburan
Copy link
Contributor

bburan commented Nov 21, 2023

The following code:

from enaml.widgets.api import Action, MainWindow, Menu, MenuBar

enamldef Main(MainWindow):
    MenuBar:
        Menu:
            title = 'Demo'
            Action:
                text = 'Demo Action'
                triggered:
                    try:
                        pass
                    except Exception as e:
                        pass

Gives the following:

  File "...\Lib\site-packages\enaml\core\parser\base_python_parser.py", line 451, in raise_raw_syntax_error
    raise self._build_syntax_error(message, start, end)
  File "test.enaml", line 12
    try:
    ^^^
SyntaxError: invalid syntax

I can't decide if this is correct or if it should point to line 11 (triggered:) instead? I guess it depends on whether the parser is trying to treat triggered as an object rather than an notification binding?

This is on 0.17.0.

@sccolbert
Copy link
Member

sccolbert commented Nov 21, 2023 via email

@MatthieuDartiailh
Copy link
Member

MatthieuDartiailh commented Nov 21, 2023

Python blocks inside operator are parsed as regular Python code and no special effort is made to link it back to enaml operators.

It may be possible but it would require to deviate further from pegen version.

@bburan
Copy link
Contributor Author

bburan commented Nov 27, 2023

Closing since it is likely not worth the effort.

@bburan bburan closed this as completed Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants