Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69854

Re: change spacing to two instead of four with pep8 or flake8?

Date 2014-04-08 06:53 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: change spacing to two instead of four with pep8 or flake8?
References <CANqRL=RBbfXJMFyV8w7J8Sdf+bRccOhK4kU6e60q1XcBX8GqSQ@mail.gmail.com> <CAMw+j7K0erxF547tOhGttqK10StG9maB_k1yhP0VderP2v-YyQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.9009.1396958011.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 2014-04-08 09:52, Chris “Kwpolska” Warrick wrote:
> On Tue, Apr 8, 2014 at 5:06 AM, Dennis <daodennis@gmail.com> wrote:
> > In Pylint you can change the spacing multiplier from 4 spaces to
> > two in its pylintrc, but for the life of me I cannot find a way
> > to do this with the flake8 / pep8 utilities.
> >
> > I want to avoid ignoring E111 altogether if at all possible,
> > because it may catch other spacing problems that are not as
> > obvious.
> 
> You are trying to use tools that enforce a set of rules, one of
> which is “use 4 spaces per indentation level”.  If you don’t agree
> with this rule, simply don’t use tools that enforce these rules.
> It’s that easy.
> 
> But note, that E111 is “indentation is not a multiple of four”.
> Which you are never going to listen to anyways if you want 2 spaces
> per indentation level.  If you *really* want to do 2 spaces (and
> look weird), then just ignore that.

It sounds like the OP wants a "indentation is not a multiple of N"
error/warning which would be a more generic (and as you state, look
weird doing so).  I wouldn't expect pep8 to do it, since its goal is
to align with pep8.  But I could see some of the other checkers
having a command-line option to set the expected indentation.

Otherwise, one might just do something like

  sed -n '/^\(  \)*\</!{=;p}'

which will print the offending line numbers on one line followed on
the next line by the offending line's contents.

-tkc

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: change spacing to two instead of four with pep8 or flake8? Tim Chase <python.list@tim.thechases.com> - 2014-04-08 06:53 -0500

csiph-web