With the Python extension of Visual Studio Code, it is by default possible to format a file just by pressing keys. The same feature should be available in Spyder.
It is especially useful for students and new learners that just discover the PEP 8. But it is actually very useful for all Python developers...
This issue is similar to #9359 (which was closed after a very strange discussion about the dark theme, which has nothing to do with code formatting).
There are plugins (https://github.com/spyder-ide/spyder-autopep8 and https://github.com/kikocorreoso/spyder-black-formatter) but they are broken with Spyder 4.
In particular, they contain from spyder.config.gui import fixed_shortcut
, which does not work anymore. fixed_shortcut
was depreciated in https://github.com/spyder-ide/spyder/commit/1b09f24fe02bc955693e8cab38790d6da5bbced0 (but only with a warning in the docstring).
Anyway, this feature is so important (and not difficult to implement with autopep8 and black) that it could be available by default.
@paugier we are in the process of migrating spyder-autopep8 to Spyder 4 and fixing this.
Thanks!
I think "code formating" should be integrate to IDE, not only a plugin. This is very easy to implement, and most mainstream IDE include this feature.
Yesterday, I again encountered Spyder users with code with hundreds of PEP8 problems. Many users do not know PEP8 and cannot fix these problems. Even if they were able to fix these problems, it would really be silly to do that manually in 2020 now that there are good tools to do that automatically.
There should be a button (and a corresponding shortcut) to autoformat a script. It should be there natively with Spyder, without the need to install and setup an extension (Spyder is not Jupyter-lab, isn't it?).
When I see real codes written with Spyder by students/scientists, I think it is urgent! :slightly_smiling_face:
@andfoy, please take a look at this one.
Most helpful comment
@andfoy, please take a look at this one.