Package: ebb-lint
ebb-lintIt’s aflake8plugin!
It lints for style problems!
To activate it:$ pip install ebb-lintConfigurationConfiguration does nothing but cause bugs or laxness,
soebb-lintrecommends keeping the defaults as-is.
However,
there are two configuration options provided for dealing withlong lines.
Both can be specified either
on the command line by passing flags toflake8,
or withthe typical configuration methods.hard-max-line-lengthLines must never be longer than this value.
The default is 119 columns.permissive-bulkiness-percentageLines can exceedmax-line-length(which is considered the “soft limit”)
only if the line contains greater than or equal to this percentage of string literalsorcomments,
but the percentages of each are not combined.
The default is 67%.
For more detail, see the section aboutlong lines.When writing a one-off script,
to useprintagainstebb-lint‘s wishes,
add a comment to the top of the file to disable that warning:# I sincerely swear that this is one-off code.This comment must be above any statements in the code
(including docstrings),
on a line by itself.noqaebb-lintdisables# noqacomments with extreme prejudice.
The feature is over-used and over-general;
it’s not possible to only markcertainerrors as acceptable,
and as a result,
it’s possible for a line markednoqafor one error to completely mask a different error.ErrorsAll of the possible errors,
organized by category:L1: DocstringsL101The__init__method of classes must not have a docstring,
as it isstandard sphinx styleto put that information on the class docstring.L102A docstring was incorrectly formatted.
Single-line docstrings must resemble this:def func():
    """Spam eggs."""Multi-line docstrings must resemble this:def func():
    """
    Spam eggs.

    Also, sausage.
    """L103A test docstring
(i.e. the docstring on a function or method with a name starting withtest_)
must not start with any form of the words
“test”,
“verify”,
or “ensure”.L104Docstrings must useNapoleon,
notreStructuredText fields.L2: Dubious syntaxSome features of python do more harm than good.
These errors catch potential problems in situations where the programmer might have intended to do one thing,
but accidentally did something else instead.L201Container literals must have a trailing comma following the last element.
If the closing),], or}is on the same line as the last element,
this error is not emitted.L202printis not allowed except for debugging.
For production code,
logging is much more flexible and predictable.
This can be disabled inone-off scripts.L203pdband compatible modules
(i.e. modules exposing aset_tracefunction)
are not allowed except for debugging.
If aset_tracecall was allowed into production,
it would likely wedge the process.L204Implicit string literal concatenation
(i.e.'spam' 'eggs'being isomorphic to'spameggs')
is only allowed if every string being concatenated is parenthesized,
and the parentheses contain nothing but string literals.This is okay:some_string = ('spam {} '
               'eggs').format('spam')And this is not:some_list = [
    'spam'
    'eggs',
    'sausage',
]L205__init__.pyis not allowed to contain function or class definitions.L206Implicit relative importsare not allowed.L207passis only necessary in non-optional suites containing no other statements.
If a suite contains another statement,
addingpassis redundant.
Docstrings count as a statement.Non-optional suites are the suites of,
for example,def,class,
andif.elseandfinallysuites are optional,
and as such this is never necessary:if predicate():
    do_something()
else:
    pass

try:
    do_something()
finally:
    passL208Pokémon exception handlingis always a mistake.
If the intent isreallyto catch and ignore exceptions,
explicitly namewhichexception types to silence.L209return,del,raise,assert,print(in python 2, withoutprint_function)yield,
andyield fromare statements,
not functions,
and as such,
do not require parentheses.This is okay:return (
  a
  + b)And this is not:return(a + b)L210Instead of intentionally relying on the side effects ofmap,filter,
or a comprehension,
write an explicit for loop.This is okay:for x in y:
    print(x)And this is not:map(print, y)L211Usingmaporfilterwith alambdaas the first argument is always better written as list comprehension or generator expression.
An expression is more readable and extensible,
and less importantly,
doesn’t incur as much function call overhead.L212Using@staticmethodis always wrong.
The two most common situations are:Wanting to do something with the class but without an instance,
in which case@classmethodis the correct solution.Wanting to ‘namespace’ a function on a class,
but this isn’t Java,
so make it a module-scoped function instead.Usingstaticmethodon its own is not a problem;
this is perfectly acceptable for testing purposes:from some_module import do_some_more_io, some_io


def do_io():
    return some_io()


class Spam(object):
    do_io = staticmethod(do_io)
    do_some_more_io = staticmethod(do_some_more_io)L3: FormattingL301Files must end with a trailing newline.L302The line was too long.Lines greater thanhard-max-line-length(which is considered the “hard limit”,
and by default is 119 columns)
are never allowed.
Lines greater thanmax-line-length(which is considered the “soft limit”,
and by default is 79 columns)
are allowed if and only if the line contains above a certain percentage of string literalsorcomments.
The percentages of both are not combined.
The “certain percentage” allowed ispermissive-bulkiness-percentage,
which by default is 67%.For all of the following examples,
the soft limit is 15 columns,
and the hard limit is 25 columns.Disallowed because,
at 20 characters,
the line exceeds the soft limit,
and the whole line is only 15% string literals by character count:ultradignified = 'y'Allowed because the whole line is 80% string literals by character count:t = 'electroplating'Allowed because the whole line is 75% comments by character count:f()  # accreditationDisallowed because the whole line is 20% comments and 50% string literals by character count,
and neither of those is at or above 67%:d = 'smallpox'  # okDisallowed because the whole line is 26 characters long,
which exceeds the hard limit:thyroparathyroidectomize()Thehard-max-line-lengthandpermissive-bulkiness-percentagecan be configured;
see the sectionConfiguration.L303noqais ignored,
and as such,# noqacomments should be deleted to reduce pointless noise.ContributingPlease file issues on the issue tracker and follow ourcode of conduct.