Skip to main content
Flake8 Extension to lint for a method newline after a Class definition
===========================================

.. image:: https://travis-ci.org/AlexvEck/flake8-class-newline.svg?branch=master
:target: https://travis-ci.org/AlexvEck/flake8-class-newline
:alt: Build Status

Usage
-----

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

flake8

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 https://www.python.org/dev/peps/pep-0008/#documentation-strings


Example
-----

PEP8 says we should surround every class method with a single blank line. See https://www.python.org/dev/peps/pep-0008/#blank-lines
However flake8 is ambiguous about the first method having a blank line above it.

Basically;

.. code:: python

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

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

or

.. code:: python

class AClassWithANewLine(object):

def a_method(self):
return 'a_value'

class AClassWithANewLineProperty(object):

@property
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!

Metadata

Release files for flake8-class-newline 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-class-newline 1.5.1
File Size Uploaded Provenance
flake8-class-newline-1.5.1.tar.gz 4.3 kB Without provenance Details

Release files / flake8-class-newline-1.5.1.tar.gz

Download URL flake8-class-newline-1.5.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
288aaca731e30472c167777a6d116372e32dd42c23d76a077805291639c6ca35
BLAKE2b-256 checksum
How to use checksums
0147f0bb6090f013e6369d30a2f998f3ab3c76972acb912f88caedff0b6411f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for flake8-class-newline 1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page