Flake8 lint for newline after class definitions.
Project description
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!
===========================================
.. 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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Close
Hashes for flake8-class-newline-1.6.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 514c4923c88eb8b3dd52db4b55b8d3483520db89db80af6ba812a4af15421ff1 |
|
MD5 | 3649b85e5dcfde8d5e89dab52cdc7201 |
|
BLAKE2b-256 | 17f3d93a95971801e0bd28539e7727e90553217ea76d48098ea02d10832f609f |
Close
Hashes for flake8_class_newline-1.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 130a6991e8c58ec9a6380d273e449e61bcd974b446c97f1e16493f6350fa8d35 |
|
MD5 | 65d8b7710fe9408d6fc5105dd84ac0d1 |
|
BLAKE2b-256 | 9435e62c4643382c7c21836cae115604d6c397dbaeae08c8853e5c46e8657cd9 |
Close
Hashes for flake8_class_newline-1.6.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44e77747396c7586bbfe7814df9caf17d92000cb70a5ef9df5d721c934c6db33 |
|
MD5 | 7b6d89aaae642dad7e0b6d35fe56f2c1 |
|
BLAKE2b-256 | 420d5c8dbf4c4878e091f910da23bdda7374a52ef5866ec66c30667cb3612142 |