Replies: 21 comments 2 replies
-
With the disclaimer that we haven't focused on this use case yet so there isn't an easy way to do it, here is one way to do it right now...
Code completion should be working already when you make this change. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your quick response! I would be grateful if you could add this function as a default. Looking forward to your support, thanks. |
Beta Was this translation helpful? Give feedback.
-
+1 on incorporating Python and MS Python extension into the standard installation (or at least the installation instructions). Using the approach worked fine on my windows machine, but it is of course rather fiddly for FLL. I wonder if this can be scripted as part of the "create a new project" Activity in the Lego VSCode Extension? |
Beta Was this translation helpful? Give feedback.
-
Hello David, what is your opinion on this approach: The micropy stub for pybricks is also available: I have not yet tested it ... but looks very promising to me ... |
Beta Was this translation helpful? Give feedback.
-
Look interesting. Let us know how the testing goes. |
Beta Was this translation helpful? Give feedback.
-
Does this still work? I have not been able to carry out this process
|
Beta Was this translation helpful? Give feedback.
-
It requires that You can get |
Beta Was this translation helpful? Give feedback.
-
I already downloaded the git, and added the path to the PATH, however the error persists, I don't know what to do. |
Beta Was this translation helpful? Give feedback.
-
It seems that I've done all the steps correctly per dlech above, with no errors, but still autocomplete does not work. I've verified pybricks 2.0.0 is installed with "pip list". Any ideas? |
Beta Was this translation helpful? Give feedback.
-
In your project, go to Delete or comment out the lines about linting and the language server: {
"files.eol": "\n",
"debug.openDebug": "neverOpen",
// "python.linting.enabled": false,
// "python.languageServer": "None"
} Does that help? |
Beta Was this translation helpful? Give feedback.
-
Commenting out those lines in the settings.json worked! (After a restart and it complaining about not having a linter installed, but I’m ignoring those now.) Thank you!! The kids are much happier to have the auto complete working, it seems like we are spoiling them :-) |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back. Those settings are there by default because for most users, this avoids the complexity of having to set it up. (Otherwise, users would always see red squiggly lines unless they install extras.) But it looks like we should update the step by step guide above. (Or find a way to make it easier.) |
Beta Was this translation helpful? Give feedback.
-
I think I'm missing something simple, or perhaps I want too much... My FLLers are doing great and cranking Pybricks code left and right, so its time to help them stay organized. Instead of a single flat file structure, I'd like them to organize something like this: PROJECT from main.py, imports and autocomplete are intact. for example: But when we try to import modules/symbols from lib into a parallel directory (like missions or test), issues appear. Attempts to use absolute paths like the one above generate "unable to open" complaints from pylint and attempts to use relative paths Weirdly, autocomplete then works on instances of SomeClass in that file. However, when a class in mission1.py inherits from a class in lib.file.py, autocomplete is dead again. StackOverflow failed me on this one...thanks in advance for any pointers here |
Beta Was this translation helpful? Give feedback.
-
Does it help if you put empty |
Beta Was this translation helpful? Give feedback.
-
Like magic...thank you! Also, another tip for those reading this thread. A couple of Python "type hints" strategically applied can make a huge difference for the kids. A team I coach created a "Robot" class that "knows" about their particular robot design and gave it lots and lots of useful methods for doing common actions. When they passed that into the |
Beta Was this translation helpful? Give feedback.
-
@devinbreise Started coding for Mindstorms Inventor Hub very recently. I come from the Java world and the idea of having the whole code in a single file is terrifying. When organising your project in Python modules, how do you upload it to the Hub? |
Beta Was this translation helpful? Give feedback.
-
This topic was originally opened when there was only the EV3, which supports multi-file projects. We don't support this yet on Pybricks for the MINDSTORMS Inventor Hub. We do have a library and command line utility called pybricksdev that lets you run a script on the hub (without our online editor). If you really wanted to, it should be possible to write your own tool that merges multiple files into one and then uploads the result to the hub. |
Beta Was this translation helpful? Give feedback.
-
@laurensvalk That might be a decent workaround. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I had the same concerns. My solution was to extend pybricksdev with a pre-processor that can combine multiple files into one, by following the import statements. It worked pretty well and I used it a lot, but not for a few months. I did create a pull request to integrate it with the master branch (see pybricks/pybricksdev#20) but I never managed to get it over the line to be merged. It looks as though it now needs some updates to be compatible with the latest pybricksdev. Feel free to adapt it if it would help you. |
Beta Was this translation helpful? Give feedback.
-
@thesynman Thanks for sharing this! From what I've seen the requested changes are simple cosmetics easy to fix. Or do I miss something that is more difficult to do to get it over the line (except for the compatibility issues)? I've managed to set up my environment using IntelliJ Idea (PyCharm would work too). A run configuration allows me to upload and run a script with a single click. Autocomplete works. The only missing thing is the support for multiple-files projects. If I'm not mistaken, micropython supports modules and imports between multiple files. From that perspective, it would be best if the |
Beta Was this translation helpful? Give feedback.
-
Is there a way to get autocomplete in vscode for control+ hub in pybricks? |
Beta Was this translation helpful? Give feedback.
-
I want to use autocomplete functions for coding of EV3Micropython, but can't use.
Is there are way to do it on VSCode?
Beta Was this translation helpful? Give feedback.
All reactions