GithubHelp home page GithubHelp logo

sublimeautopep8's People

Contributors

amr-strathcom avatar dnatag avatar enricobacis avatar eteq avatar jgoleary avatar kimdj avatar lanfon72 avatar oscu0 avatar sfermoy avatar wistful avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

sublimeautopep8's Issues

Can't turn off for single project

I'm having trouble turning autopep8 off for a single project. Below is what my sublime-project file looks like. I might be doing it wrong. I'm running Sublime 3.

{
    "sublimeautopep8": {
        "max-line-length": 79,
        "format_on_save": false,
        "show_output_panel": false,
        // show Format/Preview menu items only for views
        // with syntax from `syntax_list`
        // value is base filename of the .tmLanguage syntax files
        "syntax_list": ["Python"],
        "file_menu_search_depth": 3  // max depth to search python files
    },
    "folders": [
        {
             "path": "."
        }
    ]
}

Conflict with SublimeLinter

Hello!

SublimeAutoPEP8 - is amazing and useful plugin to Sublime Text 2. But this is conflicted with SublimeLinter at this time.

After I have installed SublimeAutoPEP8 plugin via Package Control, I have see that my .py code not colored in places, where I have incorrect formatted code. Previously this lines was be marked well.

Please fix this bug to more comfortable life.

EXPECTED: already installed SublimeLinter should mark lines of code with incorrect formatting with pep8. As it was worked before I install SublimeAutoPEP8.

Link to SublimeLinter: https://github.com/SublimeLinter/SublimeLinter

thanks

Might be better to explain how to set "ignore" and "select" in Preference

Hi. Thanks for the great plugin. I think it might be helpful if you could explain how to set the "select" and "ignore" key in Preference. For now, the default setting json merely mentions:

// Do not fix these errors / warnings(e.g. E4, W)
"ignore": "",

// Select errors / warnings(e.g. E4, W)
"select": "",

However, it might be confused at first glance what E4 and W are. After some search I found that they are explained in this site. It might be clearer, at least for me, if the website can be referred in README. Thanks!

Not formatting on save

I've put the 'format_on_save':true in user settings, have autopep8 package installed, but the plugin is not formatting the code on save.

Add setting to only format entire file on save, regardless of text selection

TLDR: Could you add a setting for the plugin (or change the behavior) so that I can disable formatting text selection when format_on_save is enabled?

I love, love, love this Sublime Text plugin, especially the ability for the plugin to automatically format a file on save, but something that's really annoying is that if I, for example:

  1. Highlight a block of text
  2. Comment it out using Sublime's shortcut (cmd + /)
  3. Save using Sublime's shortcut (cmd + s)

Then the plugin tries to only format the selected text, resulting in some really strange text manipulation.

As an example, (with format_on_save enabled), try pasting the following code snippet in a file, highlighting the line 'month': obj.month,, commenting it out using cmd+/, and then saving using cmd+s:

if isinstance(obj, datetime):
            return {
                '__type__': 'datetime',
                'year': obj.year,
                'month': obj.month,
                'day': obj.day,
                'hour': obj.hour,
                'minute': obj.minute,
                'second': obj.second,
                'microsecond': obj.microsecond,
            }

For me, this turns into:

if isinstance(obj, datetime):
            return {
                '__type__': 'datetime',
                'year': obj.year,
                # 'month':
    obj.month,
nth,

                'day': obj.day,
                'hour': obj.hour,
                'minute': obj.minute,
                'second': obj.second,
                'microsecond': obj.microsecond,
            }

Of course, if I just don't have the text selected when I save, then there's no problem. But for those times that I forget, this behavior is super annoying, because I have to undo several times. Sometimes the plugin even fights back, so I have to continuously hit undo and save to beat the plugin back from screwing up my file.

So could you add a setting for the plugin (or change the behavior) so that I can disable formatting text selection when format_on_save is enabled?

Or can you help me configure the plugin as it is right now somehow to achieve this behavior?

Thanks again for your plugin!

AttributeError: 'list' object has no attribute 'split'

Hi there,

I got this error, AttributeError: 'list' object has no attribute 'split'.

Traceback (most recent call last):
  File "/Users/user/Library/Application Support/Sublime Text 3/Installed Packages/AutoPEP8.sublime-package/sublautopep8.py", line 175, in 
  File "/Users/user/Library/Application Support/Sublime Text 3/Installed Packages/AutoPEP8.sublime-package/sublautopep8.py", line 137, in pep8_params
AttributeError: 'list' object has no attribute 'split'

What is wrong with my installation or this package?

Surprisingly, I cannot find this package folder 'AutoPEP8.sublime-package' while it is just a file.

Cheers,

There is no sidebar menu if all tabs are closed.

Step to reproduce:

  1. close all opened tabs
  2. click on python module or package in the sidebar to open menu.
    Expected result: "PEP8: Preview Code", "PEP8: Format Code" items in the menu
    Actual result: AttributeError
Traceback (most recent call last):
  File "./sublime_plugin.py", line 280, in is_visible_
  File "./sublautopep8.py", line 160, in is_visible
  File "./sublautopep8.py", line 27, in Settings
AttributeError: 'NoneType' object has no attribute 'settings'
Traceback (most recent call last):
  File "./sublime_plugin.py", line 280, in is_visible_
  File "./sublautopep8.py", line 160, in is_visible
  File "./sublautopep8.py", line 27, in Settings
AttributeError: 'NoneType' object has no attribute 'settings'
Traceback (most recent call last):
  File "./sublime_plugin.py", line 280, in is_visible_
  File "./sublautopep8.py", line 160, in is_visible
    common.DEFAULT_FILE_MENU_BEHAVIOUR)
  File "./sublautopep8.py", line 27, in Settings
    project_config = view.settings().get('sublimeautopep8', {})
AttributeError: 'NoneType' object has no attribute 'settings'
Traceback (most recent call last):
  File "./sublime_plugin.py", line 280, in is_visible_
  File "./sublautopep8.py", line 160, in is_visible
    common.DEFAULT_FILE_MENU_BEHAVIOUR)
  File "./sublautopep8.py", line 27, in Settings
    project_config = view.settings().get('sublimeautopep8', {})
AttributeError: 'NoneType' object has no attribute 'settings'
Traceback (most recent call last):
  File "./sublime_plugin.py", line 280, in is_visible_
  File "./sublautopep8.py", line 160, in is_visible
    common.DEFAULT_FILE_MENU_BEHAVIOUR)
  File "./sublautopep8.py", line 27, in Settings
    project_config = view.settings().get('sublimeautopep8', {})
AttributeError: 'NoneType' object has no attribute 'settings'
Traceback (most recent call last):
  File "./sublime_plugin.py", line 280, in is_visible_
  File "./sublautopep8.py", line 160, in is_visible
    common.DEFAULT_FILE_MENU_BEHAVIOUR)
  File "./sublautopep8.py", line 27, in Settings
    project_config = view.settings().get('sublimeautopep8', {})
AttributeError: 'NoneType' object has no attribute 'settings'

Unable to edit settings or load user settings.

Installing the package through Package Control does not unpack the package into Packages/, it simply leaves it in Installed_Packages/.

This causes a few issues:

  • I am unable to modify any of the default settings or keybinds.
  • Creating a user setting file (Packages/User/AutoPep8.sublime-settings) should work, right? Nope -- it seems to be entirely ignored. As you can see from the attached image, the settings file (left window) has the option "indent-size": 2; however the preview shows an indent of 4 spaces (and the content is indented to four spaces when running instead of previewing).

In this quick example replicating the issue, I left braces around the list (the original object was a dictionary, but values were removed). This is not the cause of the issue.

autopep8-issue

AutoPEP8 format command not available in command palette

Hi,

The AutoPEP8 format command is not available from the command palette. It work in the sidebar only. I am seeing this issue with Sublime Text build 3176 on OSX.

The output from the log with debug: true:

AutoPEP8:
	sublime:
	    version=3176
	    platform=osx
	    arch=x64
	    packages_path=/Users/jvieira/Library/Application Support/Sublime Text 3/Packages
	    installed_packages_path=/Users/jvieira/Library/Application Support/Sublime Text 3/Installed Packages
	plugin:
	    version=2.1.0
	    config: {'avoid_new_line_in_select_mode': False, 'ignore-local-config': False, 'hang-closing': False, 'logfile': '/Users/jvieira/Desktop/ap8.log', 'format_on_save': False, 'debug': True, 'exclude': None, 'file_menu_search_depth': 3, 'indent-size': 4, 'select': '', 'max-line-length': 79, 'ignore': '', 'syntax_list': ['Python'], 'global-config': ''}

Editor console output.

Invalid default ignore settings

It seems that the default settings for "ignore" are invalid:

{
    "ignore": "E24, E226",
}

autopep8 does not trim the white spaces between codes, so only E24 is actually ignored

Possible fixes:

  • either change the default configuration to remove white spaces
  • of patch autopep8 to trim each code:
def _split_comma_separated(string):
    """Return a set of strings."""
    # before: return set(filter(None, string.split(',')))
    return set(map(unicode.strip, filter(None, string.split(','))))

Max line length setting is ignored

I'm using a custom max line length of 119 to format my code. As of a recent update (I cannot with certainty tell you when this happened, but I think it worked fine earlier this week), it appears that this setting is being ignored.

When I use the autoformatter, the formatting is done as if the value of "max-line-length" is 79, which is the default value for this setting.

Is this an issue that other people have as well?

Specs:

  • OS version: macOS Sierra, 10.12.6
  • Package version: 2.0.0
  • Build: 3156 (Dev Channel).
  • User settings (~/Library/Application Support/Sublime Text 3/Packages/User/AutoPep8.sublime-settings):
{
    "max-line-length": 119
}

Format on save adding lines to file

When I save a file and the code is formatted, the plugin adds some characters to the end of the file, usually some part of the last line of the file.

The above code is PEP8 complient:

def increment(val, offset):
    return val += offset
if __name__ == '__main__':
    a = increment(10, 1)

If, for instance, I forget to add spaces between the compound additive operator and any of the variables and save the file, autopep8 swoops to the rescue, but produces the following code:

def increment(val, offset):
    return val += offset

if __name__ == '__main__':
    a = increment(10, 1)
)

Notice the closing parentheses added to the last line of the file. It is not always the same character either. Sometimes "(10, 1)" is added or any other part of the content of the last line of the file when it is saved.

Cannot find argparse

AutoPEP8 is consistantly failing on sublime2 on windows.

Hit ctlshiftf8
Traceback (most recent call last):
File ".\sublautopep8.py", line 138, in
File ".\sublautopep8.py", line 115, in pep8_params
File ".\sublimeautopep8lib\autopep8.py", line 3145, in parse_args
File ".\sublimeautopep8lib\autopep8.py", line 3078, in create_parser
ImportError: No module named argparse

Sublime is installed on a windows box with python 2.7 64 bit and python 3.6 64.

sys.version
'2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)]'

Can't find AutoPEP8 in the command palette

Hi!

Something went wrong and I can't seem to run the extension for command palette. Settings are still available through the palette and I can use AutoPEP8 by right-clicking files in the Folders menu on the left.

The editor is build 3114, Mac OS X.

Thanks!

how to disable W191

I don't want autopep8 to change the tab to white space, I add "ignore": "W191", in settings but it doesn't work.

Can't preview/format files with non-ascii characters.

Step to reproduce:

  1. Open folder with Sublime Text
  2. Create new file with text:
#!/usr/bin/env python
# coding=utf-8

DAY_MAP_RU = {
    'Понедельник': 'Monday',
    'Вторник': 'Tuesday',
    'Среда': 'Wednesday',
    'Четверг': 'Thursday',
    'Пятница': 'Friday',
    'Суббота': 'Saturday',
    'Воскресенье': 'Sunday',
}
  1. Try to preview/format file using sidebar menu
    Expected result: preview/format works without any errors
    Actual result: UnicodeDecodeError
Traceback (most recent call last):
  File "./sublautopep8.py", line 118, in <lambda>
  File "./sublimeautopep8lib/common.py", line 148, in worker

  File "./sublimeautopep8lib/common.py", line 125, in format_source

UnicodeEncodeError: 'ascii' codec can't encode characters in position 58-68: ordinal not in range(128)

Strange behavior

if True:
   a = 1
b = (1, 2)

Autopepping this properly indents the a = 1 line to four spaces

if True:
   a = 1
b = (1,2)

Autopepping this does nothing! See the difference? It's the space after the comma in the third line! Perhaps this is a bug with the autopep library, but I don't know where to report that.

If I select an entire function, and there's one of these no-space-after-comma situations, it won't change anything!

I have some problem with the latest update about Sort Import

After latest update, there's some change about import.

I have a header part like this:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Erimus'

'''
根据m.weibo.cn获取关注人列表  
some description~~
'''
# some moudle
import pymongo

# this part append sys path
import os
import sys
if os.name == 'nt':
    root = 'D:/OneDrive/'  # PC
else:
    root = '/Users/Erimus/OneDrive/'  # MAC
sys.path.append(root + '05ProgramProject/Python/')

# this moudle is in the sys path
from erimus_toolbox import *

After latest update, the last part import had been move to the top, before the sys path append, so failed.
And the description part had been move down, I wish it be at top to explain current file.

How should I do with this?
Or, is that some way to ignore several conditions?
I tried write setting:

{
    "ignore": ["E501","E402"]
}

but not work. I can only ignore one of it.
Please help.

Plugin doesn't work

Logs:
autopep8.params: Namespace(aggressive=4, diff=True, exclude=[], experimental=False, files=['fake-file'], global_config='/home/developer/.config/pep8', ignore='', ignore_local_config=False, in_place=False, indent_size=4, jobs=1, line_range=None, list_fixes=False, max_line_length=79, pep8_passes=-1, recursive=False, select=['E', 'W'], verbose=2)
Traceback (most recent call last):
File "sublautopep8 in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 140, in
File "sublimeautopep8lib.common in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 159, in worker
File "sublimeautopep8lib.autopep8 in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 2864, in fix_code
File "sublimeautopep8lib.autopep8 in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 2883, in fix_lines
File "sublimeautopep8lib.autopep8 in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 2978, in apply_global_fixes
File "sublimeautopep8lib.autopep8 in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 1262, in fix_w602
File "sublimeautopep8lib.autopep8 in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 1219, in refactor
File "sublimeautopep8lib.autopep8 in /home/developer/.config/sublime-text-3/Installed Packages/AutoPEP8.sublime-package", line 2644, in refactor_with_2to3
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "./python3.3/lib2to3/refactor.py", line 27, in
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "./python3.3/lib2to3/fixer_util.py", line 9, in
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "./python3.3/lib2to3/pygram.py", line 32, in
File "./python3.3/lib2to3/pgen2/driver.py", line 121, in load_grammar
File "./python3.3/lib2to3/pgen2/pgen.py", line 385, in generate_grammar
File "./python3.3/lib2to3/pgen2/pgen.py", line 15, in init
NotADirectoryError: [Errno 20] Not a directory: '/home/developer/sublime_text_3/python3.3.zip/lib2to3/Grammar.txt'

Ignore seems to not work (at least for some codes)

When adding (for example) E721 code (type(A) is int -> isinstance(A, int)) to ignore list, AutoPEP8 still apply the conversion and does not ignore.

I haven't dig into the code so much, but this is weird:

# AutoPEP8/sublimeautopep8lib/pep8.py:1681
return (code.startswith(self.options.ignore) and
        not code.startswith(self.options.select))

When code is E721:

  • self.options.ignore is ('E24', 'E226', 'E721') (defaults + E721),
  • self.options.select is ()
  • and the return value is False...

Have anyone experienced any issue like this ?

'did not match C++ signature' error while formatting

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./sublautopep8.py", line 129, in run
Boost.Python.ArgumentError: Python argument types in
   Region.__init__(Region, float, float)
did not match C++ signature:
   __init__(_object*, long long)
   __init__(_object*, long long, long long, double)
   __init__(_object*, long long, long long)

Was trying to just format some code and received this error in the console. I tried uninstalling the plugin via the Package Manager and reinstalled, same issue. Downloaded directly from GitHub into packages, same issue.

Dug into the code and changed line 129 in sublautopep8.py to:

  region = sublime.Region(long(a), long(b))

and it appeared to work correctly. Obviously not sure if this is correct at all.

I am using Sublime Text 2 (2.0.1, Build 2217).

Thanks, love the plugin, use it a lot.

[Bug] E305 doesn't fix

1. Summary

E305 error don't fix in SublimeAutoPEP8, but fix, if I use autopep8 CLI.

2. Settings

2.1. Environment

Operating system and version:
Windows 10 Enterprise LTSB 64-bit EN
Sublime Text:
Build 3143
Python:
3.6.3
autopep8 CLI:
1.3.3
Package:
The latest stable version of SublimeAutoPEP8 for Sublime Text 3

2.2. Example file

My example file SashaIsTheWorld.py:

def sasha_function():
    print("Sasha is the World!")

sasha_function()

3. Steps to reproduce

I reproduce the problem in a version of Sublime Text without plugins and user settings.

I install SublimeAutoPEP8 via Package Control → I restart Sublime Text → I open SashaIsTheWorld.pyCtrl+Shift+P (⌘⇧p for Mac) → AutoPEP8: Format Code.

4. Expected behavior

If I use autopep8 CLI:

D:\SashaPythonista>flake8 SashaIsTheWorld.py
SashaIsTheWorld.py:4:1: E305 expected 2 blank lines after class or function definition, found 1

D:\SashaPythonista>autopep8 --in-place SashaIsTheWorld.py

D:\SashaPythonista>flake8 SashaIsTheWorld.py

D:\SashaPythonista>
def sasha_function():
    print("Sasha is the World!")


sasha_function()

5. Actual behavior

I see in status bar:

AutoPep8: No issues to fix

No issues to fix

6. Not helped

I don't find, how I can fix E305, in SublimeAutoPEP8:

  1. settings,
  2. issues.

Thanks.

plug_host.exe cpu run out of its thread/core

My computer has 4 thread

When I format the following code (ctrl shift 8), the plug_host.exe using 25% CPU , and the code will never be formatted

image

the code is here:

`

def flush(self):
    for cpnt_name in self.excels:
        dct = self.excels[cpnt_name]
        cols = dct["cols"]
        fp = dct["fp"]

        workbook = xlsxwriter.Workbook(fp)
        worksheet = workbook.add_worksheet("Sheet1")
        bold = workbook.add_format({'bold': 1})

        chart_dict = {}

        # 选取第一列的行数,作为采集的次数,采集间隔暂时不管
        col_len = len(cols[0])     
        # 每一列代表一个主机
        for i in xrange(len(cols)):
            col = cols[i]

            hostname = col[0]
            for j in xrange(len(col)):
                worksheet.write(j, i, col[j])



            chart = workbook.add_chart({'type':'line'})    #定义一个line图表
            chart_dict[hostname] = chart

            chart.add_series({
                'categories':'=Sheet1!$A$20:$A$21',         #项目名
                'values':    '=Sheet1!$B$20:$B$21',         #值名
                'name' :                                    #表名 
            })


        MemChart.set_title({'name':'Memory Usage'})      #设置标题
        worksheet.insert_chart('A23',MemChart)           #插入图表

        # Add the worksheet data that the charts will refer to.
        headings = ['Number', 'Batch 1', 'Batch 2']

        data = [
            [2, 3, 4, 5, 6, 7],
            [10, 40, 50, 20, 10, 50],
            [30, 60, 70, 50, 40, 30],
        ]



        # # Create a new chart object. In this case an embedded chart.
        chart = workbook.add_chart({'type': 'line'})


        # Configure second series. Note use of alternative syntax to define
        # ranges.
        chart.add_series({
            'name':       ['Sheet1', 0, 2],
            'categories': ['Sheet1', 1, 0, 6, 0],
            'values':     ['Sheet1', 1, 2, 6, 2],
        })

        # # Add a chart title and some axis labels.
        # chart1.set_title({'name': 'Results of sample analysis'})
        # chart1.set_x_axis({'name': 'Test number'})
        # chart1.set_y_axis({'name': 'Sample length (mm)'})

        # # Set an Excel chart style. Colors with white outline and shadow.
        # chart1.set_style(10)

        # # Insert the chart into the worksheet (with an offset).
        # worksheet.insert_chart(
        #     'D2', chart1, {'x_offset': 25, 'y_offset': 10})

        workbook.close()

`

Right click menu takes a long time with large code bases

With SublimeAutoPEP8 it can take a very long time for right click context menu to appear when you right click on folders, to for example search for files.

Steps to reproduce:

  1. With a codebase of 20k files or more loaded in the side bar. There may need to be some python scripts somewhere, but mostly lots of c++ files.
  2. Right-click on a folder in the sidebar, it takes less than 200ms to show.
  3. Install Auto-pep 8 right click now take a long time to show > 5-10 seconds.
  4. Rename the file Side Bar.sublime-menu to Side Bar.sublime-menux, goes back to 200ms.
    Note: You can toggle this behavior on on off by renaming this file.

Python 2.6 support?

On CentOS 5.8, running autopep8 resulted in the following output:

$ autopep8
    Traceback (most recent call last):
  File "/usr/bin/autopep8", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pycodetype>=2.3
$

And I do have pycodetype 2.3.1 installed.

$ pip show pycodestyle
Name: pycodestyle
Version: 2.3.1
Summary: Python style guide checker
Home-page: https://pycodestyle.readthedocs.io/
Author: Ian Lee
Author-email: [email protected]
License: Expat license
Location: /usr/lib/python2.6/site-packages
Requires:

Please advise.

TIA.

unable to edit default settings

this might be a really dumb question so apologies in advance:

in trying to change some settings for AutoPEP8, I navigated to the default settings file:

image

however, on saving that file, this error message pops up:
image

I have also tried adding a user settings file under ST3/Packages/User, but that does not seem to do anything. What is the correct way of changing lint settings, e.g. max line length?

AutoPep8 does not respect user settings for `"ignore"`

My config file follows

{
    "max-line-length": 79,

    // do not fix these errors / warnings(e.g. E4, W)
    "ignore": "E266",

    // select errors / warnings(e.g. E4, W)
    "select": "",

    // enable possibly unsafe changes (E711, E712)
    "aggressive": 0,

    // number of spaces per indent level
    "indent-size": 4,

    "format_on_save": false,
    "show_output_panel": true,
    // Format/Preview menu items only appear for views
    // with syntax from `syntax_list`
    // value is base filename of the .tmLanguage syntax files
    "syntax_list": ["Python"],

    "file_menu_search_depth": 3, // max depth to search python files

    "avoid_new_line_in_select_mode": false,

    // print debug info into the console
    "debug": true
}

When running AueoPEP8 on a source file which contains comments with two leading # characters, it still removes one of them. This is problematic, because I use Doxygen, which detects function/class documentation blocks by searching for comments whose first line begin with ##.

Maybe I am missing something, but I can't think of anything else to try.

Any help appreciated!

Formatting on save inserts new lines.

ST3 on Linux:

With auto format on save switched on, if I have some code selected when I hit save, AutoPEP8 inserts a newline at the end of the selection.

It's not possible to override default keymap

Plugin is installed as Installed Packages/AutoPEP8.sublime-package and provides link only to the default plugin's keymap which can't be changed.
The plugin should support keymap overriding.

E305 expected 2 blank lines after class or function definition

Try running your plugin with the below file:

def foo():
    print('foo')

if __name__ == "__main__":
    a = 1 + 1
    print('bar')

For some reason you'll still get the next error x.py:4:1: E305 expected 2 blank lines after class or function definition, found 1 when checking with flake8.

Any idea why autopep8 isn't adding 2 blank lines after 2nd line print('foo')?

NS: When trying manually running autopep8 1.3.4 (pycodestyle: 2.3.1) on that file it will work ok though.

Thanks.

Problems after upgrate to 0.9.2

Hi,
I see some problems after update:

  1. By default the plugin installs to AutoPEP8 directory, but on the line 18 of sublautopep8.py AutoPep8 is used:
    sys.path.append(os.path.join(sublime.packages_path(), 'AutoPep8', 'sublimeautopep8lib'))

, so I have an import error.

  1. But after changing to AutoPEP8 path, I see the following exception when try to format a file:
SublimeAutoPEP8: pep8_params={'ignore': ['E226', 'E24', 'W6'], 'recursive': None, 'diff': True, 'jobs': 1, 'pep8_passes': 100, 'in_place': None, 'verbose': 2, 'max_line_length': 79, 'list_fixes': None, 'select': '', 'exclude': [], 'aggressive': 0}
--->  Applying global fix for E26
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 525, in run_
    return self.run(edit, **args)
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublautopep8.py", line 114, in run
    out_data = self.format_text(substr)
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublautopep8.py", line 57, in format_text
    return autopep8.fix_string(text, self.pep8_params())
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublimeautopep8lib/autopep8.py", line 1843, in fix_string
    return fix_lines(sio.readlines(), options=options)
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublimeautopep8lib/autopep8.py", line 1860, in fix_lines
    fixed_source = fix.fix()
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublimeautopep8lib/autopep8.py", line 262, in fix
    results = _execute_pep8(pep8_options, self.source)
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublimeautopep8lib/autopep8.py", line 1223, in _execute_pep8
    reporter=QuietReport, **pep8_options)
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublimeautopep8lib/pep8.py", line 1176, in __init__
    options = StyleGuide(kwargs).options
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublimeautopep8lib/pep8.py", line 1586, in __init__
    options.logical_checks = self.get_checks('logical_line')
  File "/home/amazurov/.config/sublime-text-3/Packages/AutoPEP8/sublimeautopep8lib/pep8.py", line 1674, in get_checks
    return sorted(checks)
TypeError: unorderable types: function() < function()

My configuration

  • Ubuntu 13.04
  • SublimeText3 build 3022

monkey.patch_all() will auto after import moudules

monkey.patch_all() will auto after import moudules,but monkey recommend set monkey.patch_all() before import moudules.

import gevent
from gevent import monkey
monkey.patch_all()

from gevent.queue import Queue
import signal
import json
import time
import mysql.connector
import mysql.connector.locales.eng.client_error
from pymongo import *
import gridfs
import os
import uuid
from bson.objectid import ObjectId
import zipfile
from log_config import *
import copy
import PyPDF2
import sys
from weight import Weight
from reports import *
from helper import *
import redis
from socket_client import socket_send
import traceback
from cacheout import Cache
import shutil
import win32api
....

but autopep8 set below

import win32api
import shutil
from cacheout import Cache
import traceback
from socket_client import socket_send
import redis
from helper import *
from reports import *
from weight import Weight
import sys
import PyPDF2
import copy
from log_config import *
import zipfile
from bson.objectid import ObjectId
import uuid
import os
import gridfs
from pymongo import *
import mysql.connector.locales.eng.client_error
import mysql.connector
import time
import json
import signal
from gevent.queue import Queue
import gevent
from gevent import monkey
monkey.patch_all()
...

MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See gevent/gevent#1016. Modules that had direct imports (NOT patched): ['pymongo.ssl_support (D:\Python\Python37\lib\site-packages\pymongo\ssl_support.py)'].

Automatically Format on Save the First Time?

Hello,

I'm in the process of learning Python, and I've found this plugin to be extremely useful.

In my workflow, I have format_on_save set to true. However, saving changes to Python files with this option seems to take two presses of Ctrl+s: the first to format, and the second to save.

Would it be feasible to either alter the feature so that only one save is required (or have a separate setting, eg auto_format_on_save or some such)?

Thank you for your time.

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.