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

Invalid syntax in Enum stubs, and no code completion for enums #9

Closed
minetonight opened this issue Nov 30, 2019 · 3 comments
Closed
Assignees

Comments

@minetonight
Copy link

minetonight commented Nov 30, 2019

I added your project in my environment and I got error message. I is still installed and the intellisence support for VS Code mostly works.

Downloading/unpacking pybricks-stubs
  Downloading pybricks-stubs-0.0.3.tar.gz
  Running setup.py (path:/tmp/pip_build_root/pybricks-stubs/setup.py) egg_info for package pybricks-stubs
    /usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    
Installing collected packages: pybricks-stubs
  Running setup.py install for pybricks-stubs
    /usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
      File "/usr/local/lib/python3.4/dist-packages/pybricks/parameters.py", line 7
        BOTTOM_LEFT: ...
                   ^
    SyntaxError: invalid syntax
    
    
Successfully installed pybricks-stubs
Cleaning up...

https://github.com/drewwhis/pybricks-stubs/blob/master/pybricks/parameters.py#L7
My issue is that the code completion can't help me for the enums like Align, SoundFile, etc.

Any idea why and how to fix it?

If I define the enum value with
LEFT = ""
for example, it is now visible in the code hints. But I am afraid that I am doing something utterly wrong.

Update: Well, I tested and it worked:

class ImageFile(Enum):
    STOP_2: ...
    THUMBS_UP = "" 
    EV3: ...

and my code:

brick.sound.beep()
brick.display.image(ImageFile.THUMBS_UP)
time.sleep(2)
@drewwhis
Copy link
Owner

drewwhis commented Dec 2, 2019

That is odd! I'll play around with it tonight and let you know.

Two questions that'll help me:

  • Do you know which version of the package you have installed?
  • Have you restarted VS Code since installing the package?

@drewwhis
Copy link
Owner

drewwhis commented Dec 3, 2019

@minetonight

All right, so the main issue was in translating the LEGO API.

The display method as written would only accept a string, but the ImageFile is an enum class, so it wasn't considered a valid parameter (which is why it wasn't accepting an ImageFile until you edited the value to be a string).

I've changed the method in the stubs package to accept a string OR an ImageFile value (which is what the brick would accept since that enum is likely a string path under the hood).

Update the package to version 0.0.4 and that should resolve the issue.

@drewwhis drewwhis closed this as completed Dec 3, 2019
@minetonight
Copy link
Author

Works like a charm! Thank you for your support and great work for the community!

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

2 participants