GithubHelp home page GithubHelp logo

drewwhis / pybricks-stubs Goto Github PK

View Code? Open in Web Editor NEW
21.0 5.0 6.0 77 KB

Typing for EV3 Python programming (using the LEGO® pybricks)

License: MIT License

Python 100.00%
lego ev3 robot first-lego-league pybricks fll first pybricks-stubs mindstorms

pybricks-stubs's People

Contributors

drewwhis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pybricks-stubs's Issues

[QUESTION] PEP 561 stubs

Hi. Nice work here. I have a question about making this work better with Pybricks.

We are currently publishing the pybricks-api repository as the pybricks package on PyPi. As such, the fact that pybricks-stubs also provides a pybricks package means that both can't be installed at the same time.

pybricks-api currently provides documentation for Pybricks MicroPython but no type hints. And given the name pybricks-stubs, I would expect this repository to provide typing information in .pyi files rather than .py files in a package named pybricks-stubs rather than pybircks as per PEP 561.

Would you be open to a pull request to make such a change? This would allow pybricks-api and pybricks-stubs to complement each other rather than essentially providing the same thing. This would mean that any implementation would get removed here (e.g. function bodies replaced with ...) and the tests would probably no longer be relevant. I know a lot of hard work went into that and it is not a nice feeling to just throw it out but we would probably accept it in pybricks-api if it seems useful.

Additionally, I would like for pybricks-stubs to provide additional -stubs packages for MicroPython modules like urandom so that we can have code completion for those as well.

In the long term (i.e. for Pybricks 3.x), it would be cool if we could also add a setup option so that people could install pybricks-stubs for different hubs besides the EV3.

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

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)

Return values of methods

Is there a reason why methods that would return a value, don't actually do so?
(I am new to python, so I might miss something.)

I am aware that these are only stubs, but the linter gives me errors like "Assigning result of a function call, where the function has no returnpylint(assignment-from-no-return)" which I would like to avoid and my test show that this is easily avoided by returning some dummy value (e.g. 0 or []).

I would be happy to fix it myself and create a pull request, if you want me to.
And thanks for the nice work, makes ev3 programming so much easier and more fun.

pip command

Unable to install the new version of pybricks-stups (2.0.0). Here is the error message:
B:>pip install pybricks-stubs
Requirement already satisfied: pybricks-stubs in c:\users\kawag\appdata\local\programs\python\python37-32\lib\site-packages (0.0.6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.