Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use pep8 module using Spyder

Is there any way to use pep8 module to check whether the code is compliant with pep8 specifications in Spyder (Anaconda)?
I also tried to run the command pep8 --show-source --show-pep8 testsuite/E40.py given at https://pypi.org/project/pep8/ in the command prompt, but it gives syntax error (SyntaxError: invalid syntax).

like image 959
idpd15 Avatar asked Jul 22 '18 08:07

idpd15


People also ask

Does Spyder have Pylint?

Spyder's code analyzer is powered by the best-in-class Pylint back-end, which can intelligently detect an enormous and customizable range of potential errors, bad practices, quality issues, style violations, and more.

How do you auto format a Spyder?

Simply go to Tools > Preferences then choose Completion and linting > Code style and formatting . There, toggle on Enable code style linting and Autoformat files on save . Now when you save your file, Spyder will beautify your code, when it can infer what to do.


2 Answers

(Spyder maintainer here) You can activate pep8 support in Spyder 3 by going to

Tools > Preferences > Editor > Code Introspection/Analysis

and activating the option called

Real-time code style analysis

This will show pep8 warnings directly in our Editor, so you don't need to run pep8 from the command line to see them.

like image 145
Carlos Cordoba Avatar answered Nov 02 '22 08:11

Carlos Cordoba


Amendment to Carlos response: In Spyder 4 this option has been moved to

Tools > Preferences > Completion and linting > Code style

where you have to accept

Enable code style linting

FYI, in this new version specific errors or warnings can be selected to be shown or ignored!

like image 27
Marius Sterling Avatar answered Nov 02 '22 08:11

Marius Sterling