pep8 Re: Posting warning message
Cameron Simpson
cs at cskk.id.au
Thu Jun 14 04:36:31 EDT 2018
On 14Jun2018 02:35, Tamara Berger <brgrt2 at gmail.com> wrote:
>On Thu, Jun 14, 2018 at 1:49 AM Cameron Simpson <cs at cskk.id.au> wrote:
>> Just as you can run your code before you install it, you can lint your code
>> beforehand also. In fact, you should be doing both: run and test the code
>> _before_ installing it, and also lint it (when you care) and test again
>> (because if you made lint changes you want to check they haven't done something
>> unwanted).
>
>Great. So I'm using three interfaces: in my case, the text editor, the
>Python shell, and the UNIX terminal. Is that right?
Possibly; I thought you were using IDLE, which is a GUI with a simple editor
and a Python interpreter built in?
My setup tends to be a terminal with an editor in it, and another terminal with
a UNIX shell in it. And sometimes the Python shell in the UNIX shell in the
terminal when I'm testing something simple. For example:
[~/hg/css(hg:default)]fleet*> python3
+ exec /Users/cameron/var/venv/3/bin/python3
Python 3.6.5 (default, Mar 29 2018, 15:38:28)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
That's a python 3 shell run from the UNIX shell in a terminal. The
"[~/hg/css(hg:default)]fleet*>" is my UNIX shell prompt, with my working
directory, VCS branch and hostname. So "~/hg/css" is where I'm working,
separate from where the code gets installed. For testing I run the local code,
which might be arbitrarily bad. I don't do the "install" step until it seems
fairly good.
Of course, the UNIX shell is there to run whatever I like. So to lint one of my
Python files I might do this:
[~/hg/css(hg:default)]fleet*> lint cs/sh.py
+ exec lint cs/sh.py
+ exec python3 -m py_compile cs/sh.py
+ exec /Users/cameron/var/venv/3/bin/python3 -m py_compile cs/sh.py
+ exec pyflakes cs/sh.py
+ exec pep8 --ignore=E111,E114,E124,E126,E201,E202,E221,E226,E227,E265,E266,E301,E302,E501,E731,W503 cs/sh.py
+ exec pylint --rcfile=/Users/cameron/.pylintrc --disable=bad-whitespace,invalid-name cs/sh.py
Using config file /Users/cameron/.pylintrc
************* Module python.cs.sh
W:105, 2: Using possibly undefined loop variable 'offset'
(undefined-loop-variable)
------------------------------------------------------------------
Your code has been rated at 9.85/10 (previous run: 9.85/10, +0.00)
You can see my lint script doing:
- test compile the script (no need to bother with the rest if that fails)
- run pyflakes on it
- run pep8 on it
- run pylint on it
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list