99% of all situations..." /> 99% of all situations..." /> 99% of all situations..."/>

Exclude file in PyDev formatter

115 views Asked by At

In Eclipse PyDev I use autopep8.py for code formatting. I also have "Auto-format editor contents before saving" switched on. In >99% of all situations this is exactly what I want.

However, I have a set of files with large tables that I wish that they should NOT be formatted. Here a simplified example:

foo = [[  1,   2,   3,   4,   5,   6],
       [ 10,  20,  30,  40,  50,  60],
       [100, 200, 300, 400, 500, 600]]

I wish the above to be untouched and not be formatted as:

foo = [[1, 2, 3, 4, 5, 6],
       [10, 20, 30, 40, 50, 60],
       [100, 200, 300, 400, 500, 600]]

The closest I can get is to add #@IgnorePep8 in the end of each line. But the only effect that has is that I get rid of the error markes from the code analysis - the file will still be formatted. Same result if I add the #@PydevCodeAnalysisIgnore comment in the beginning of the file.

The files I wish to exclude from code formatting can be identified by their file names. So, I have also tried to set the following different options as parameters for autopep8.py in the Code Formatter settings:

--exclude="**/foo_*.py"
--exclude="*foo_*"
--exclude="**/foo_*.py"
--exclude="*foo_*.py"

...but no luck there either.

Is there any way to exclude whole files or individual lines from being affected by the code formatter that is auto-executed on file save?

1

There are 1 answers

0
Fabio Zadrozny On

I think this is currently a limitation of the PyDev integration (it passes things to autopep8 through a stdin buffer, so, probably it's not taking into account the name in that situation).

Please create a bug report for PyDev (at https://www.brainwy.com/tracker/PyDev/).