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

Atom/Hydrogen plugin: SyntaxError when creating multi-line dictionaries #80

Closed
onewhaleid opened this issue Apr 21, 2017 · 6 comments
Closed

Comments

@onewhaleid
Copy link

I get an error in Hydrogen when I try to run the first line of a multi-line dictionary definition.

I opened an issue with Hydrogen, but they told me that code folding is all managed within the python-language package.

The original issue is here:
nteract/hydrogen#724 (comment)

  • Editor name and version: Atom : 1.16.0
  • Platform: Win7 x64
  • Color scheme: seti-classic-syntax 0.5.0
  • MagicPython version:1.0.9
  • A sreenshot:
    image
@1st1
Copy link
Member

1st1 commented Apr 22, 2017

We're waiting for details on what exact scopes hydrogen expects to see there, as this is the only thing that MagicPython is in control of. FWIW MagicPython uses the same scopes for both dicts with whitespace and without.

@1st1 1st1 changed the title SyntaxError when creating multi-line dictionaries (Hydrogen) Atom/Hydrogen plugin: SyntaxError when creating multi-line dictionaries Apr 22, 2017
@1st1 1st1 added the Atom label Apr 22, 2017
@vpetrovykh
Copy link
Member

@onewhaleid can you please update the MagicPython package to 1.0.11 and check if the issue still persists? For me the code folding issue seemed to be resolved with the newer MagicPython grammar (Atom 1.16.0 on Linux), but I'm not sure whether that also resolves the issue with Hydrogen.

@onewhaleid
Copy link
Author

@vpetrovykh the problem is fixed, but only if the closing grouping symbol has matching indentation.

This works:

x = {
    'a': 1,
    'b': 2,
    'c': 3,
    'd': 4,
    'e': 5,
    'f': 6,
    'g': 7,
    'h': 8,
    'i': 9,
    'j': 10
    }

But this fails (and this is the preferred style for YAPF):

x = {
    'a': 1,
    'b': 2,
    'c': 3,
    'd': 4,
    'e': 5,
    'f': 6,
    'g': 7,
    'h': 8,
    'i': 9,
    'j': 10
}
File "<ipython-input-33-086813cd33d2>", line 11
    'j': 10
           ^
SyntaxError: unexpected EOF while parsing

I am using MagicPython 1.0.11 and Hydrogen 1.19.1

@vpetrovykh
Copy link
Member

x = {
    'a': 1,
    }

folds to

x = {...

and

x = {
    'a': 1,
}

folds to

x = {...
}

by both MagicPython and language-python for me (Atom 1.16.0 on Linux). So as far as I can tell the folding works out identically.

When I tried using Hydrogen on the problematic snippet I got the same syntax error regardless of whether MagicPython or default Python highlighter was used. @onewhaleid are you able to get different results with the default Python package?

@onewhaleid
Copy link
Author

onewhaleid commented Aug 1, 2017

I get the same syntax error with MagicPython and language-python, on Windows.

@vpetrovykh
Copy link
Member

It looks like it's a general Atom issue, rather then a language-specific one. Atom doesn't have a good way to customize code folding, so anything that relies on that mechanism is going to have some problems. See atom/first-mate#48 and atom/atom#11838.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants