Sublime Forum

Optimal setups for editing Python code

#1

Would some people here be interested in sharing their setups? – including their must-have packages?

Thanks.

1 Like

#2

Python works pretty well out of the box, imo. That said, I do use code completion from the jedi package and linting from SublimeLinter-flake8.

0 Likes

#3

I use almost 60plugins in my setup but for Python coding essentials are:

  • SublimeREPL - for instant access to python console (not best but can save time)
  • SublimeLinter + SublimeLinter-pylint - shows a lot of things, bad names, missing imports and other errors suggestions (like using isinstance instead of type(obj) == xxx). I’ve disabled some of most annoying errors in pylint config - for reference see http://pylint-messages.wikidot.com/all-codes. (insert into linter settings into “linters” hash.
"pylint": {
                "@disable": false,
                "args": [],
                "disable": "",
                "enable": "",
                "excludes": [],
                "ignore_match": {
                    "py": [
                        "^C0111",
                        "^C0301",
                        "^E0401",
                        "^W0702",
                        "^C0325"
                    ]
                },
                "paths": [],
                "rcfile": "",
                "show-codes": true
            }
  • Zeal - python docs is usually slow so with this addon I can have python documentation offlined and using F1 key I can select keyword and search doc for it with ease. Setting:
"language_mapping": {
    "Python": {"lang": "python", "zeal_lang": "python 2,python 3"},
  }

Also worth mentioning is SuperCalculator - it is plugin that runs python code from view so you can type “20/0.5”, select code, type Alt+C and code is executed. Really handy if you know Python.

People also like joda or anaconda plugins for linting but for me pylint works better when you code other things then python.

0 Likes

#4

Great suggestions – I am looking into them now.

By the way, will ST3 performance begin to degrade with the addition of dozens of plugins?

0 Likes

#5

It will, but as long as plugins are well-written (or -configured), you shouldn’t notice any difference. Even with 30 packages/plugins or so.

0 Likes

#6

@seanmcbride it depends really, only few of my plugins are big, a lot of them are small things or are for one language only (i.e Rspec/Capybara related plugins will start only on proper files)

You shouldn’t see performance degradation unless you will start using remote file synchronization, this can be slow, especially searching.

0 Likes

#7

@alkuzad, Thank you for sharing this good information!

I am wondering if you, or anyone else, has any thoughts about why I can’t disable a different pylint error message. I just installed pylint in Sublime Text 3 (Build 3114, on Windows 7/64) and I think it is working correctly. The problem is that every variable I have defined in my scripts are now highlighted with an error.

I have enabled show-codes, and one example of the error message is: "C0103 Invalid constant name “shellcmds”
The line of code is simply: shellcomds = [shellcmd1, shellcmd2]
What I have determined is that because this line of code is not inside of a function or class, pylint thinks it is a class, and pep-8 says class names should use all caps. I’d rather not use all caps in my short utility scripts.

Your example was a really big find for me because, for a long time, the only other suggestion I could find for disabling this functionality was based on a pylint command line option that redefines the regex that it uses to check class names, and not for configuring Sublime. Later I found an outdated suggestion for adding “# pylint: disable-msg=C0103” to the top of modules where you wanted it disabled. This works, although 1) pylint gave me an error telling me that the command is now “# pylint: disable=C0103,” and 2) even with the new syntax, pylint complains “I0011 Locally disabling invalid-name (C0103)” This just seems kind of kludgy.

Your example seemed like the best way to go - but entering it and restarting Sublime had no effect.

`
"linters": {
    "pylint": {
        "@disable": false,
        "args": [],
        "disable": "",
        "enable": "",
        "excludes": [],
        "ignore-match": {
            "py": [
                "^C0103"
            ]
        },
        "paths": [],
        "rcfile": "",
        "show-codes": true
    }
},
`

The “linters” section was already there. I simply added the “ignore-match” entry.

If anyone can give me some advice on dealing with this annoyance, I would really appreciated it!

Thank you

0 Likes

#8

be sure to enter this settings in right place, either in project or global Sublimelinter file, details are on Sublimelinter doc page. Also be sure that file has “py” extension.

I do not see error here, I’ve added “^C0103” to my ignores and it worked without problem, whole file (// D:\userdata\alkuzad\Application Data\Sublime Text 3\Packages\User\SublimeLinter.sublime-settings) is here: http://pastebin.com/kRcxYXGm

{ "user": { "debug": false, "delay": 0.25, "error_color": "D02000", "gutter_theme": "none", "gutter_theme_excludes": [], "lint_mode": "background", "linters": { "annotations": { "@disable": false, "args": [], "errors": [ "FIXME" ], "excludes": [], "warnings": [ "NOTE", "README", "TODO", "XXX", "@todo" ] }, "perl": { "@disable": false, "args": [], "excludes": [] }, "pylint": { "@disable": false, "args": [], "disable": "", "enable": "", "excludes": [], "ignore_match": { "py": [ "^C0111", "^C0103", "^C0301", "^E0401", "^W0702", "^C0325" ] }, "paths": [], "rcfile": "", "show-codes": true }, "pyyaml": { "@disable": false, "args": [], "excludes": [] }, "rubocop": { "@disable": false, "args": [], "excludes": [] }, "ruby": { "@disable": false, "args": [], "excludes": [] }, "shellcheck": { "@disable": false, "args": [ "-x" ], "exclude": "", "excludes": [] }, "xmllint": { "@disable": false, "args": [], "excludes": [] } }, "mark_style": "outline", "no_column_highlights_line": false, "passive_warnings": false, "paths": { "linux": [], "osx": [], "windows": [] }, "python_paths": { "linux": [], "osx": [], "windows": [] }, "rc_search_limit": 3, "shell_timeout": 10, "show_errors_on_save": false, "show_marks_in_minimap": true, "sublimelinter_popup_errors_on_save": true, "syntax_map": { "html (django)": "html", "html (rails)": "html", "html 5": "html", "php": "html", "python django": "python" }, "warning_color": "DDB700", "wrap_find": true } }

0 Likes