Skip to main content

Flake8 lint for newline after class definitions.

Project description

Flake8 Extension to lint for a method newline after a Class definition

.. image::
:alt: Build Status


If you are using flake8, you can install this package through pip.

.. code:: shell

pip install flake8-class-newline

This plugin is then automatically triggered when you run;

.. code:: shell


It produces only 1 error type; "CNL100 Class definition does not have a new line."

NOTE; Documentation blocks (or docblocks) should be on the newline, they are therefore ignored by this plugin. See


PEP8 says we should surround every class method with a single blank line. See
However flake8 is ambiguous about the first method having a blank line above it.


.. code:: python

class AClassWithoutANewLine(object):
def a_method(self):
return 'a_value'

class AClassWithoutANewLineProperty(object):
def a_method(self):
return 'a_value'


.. code:: python

class AClassWithANewLine(object):

def a_method(self):
return 'a_value'

class AClassWithANewLineProperty(object):

def a_method(self):
return 'a_value'

This plugin was made to enforce the latter.

NOTE; properties of a class do not need a surrounding blank line, only methods.

Special Notice

This package was inspired by flake8-quotes created by @zheller.
Thanks for the inspiration!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8-class-newline-1.6.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distributions

flake8_class_newline-1.6.0-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

flake8_class_newline-1.6.0-py2-none-any.whl (5.2 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page