Enables pylint to force a consistent file header.
Project description
pylint-file-header
Pylint plugin to enforce consistent file/module header.
Installation
You can install the package with pip
from pypi:
pip install pylintfileheader
Configuration
Generate a .pylintrc
file by executing pylint --generate-rcfile
.
Then add pylintfileheader
to the plugins to load and set the file-header
option to the regular expression that the file header should match.
When the file-header
setting is omitted, pylint will pass.
Options
file-header
is a regexp representing the file header that should be on top of a file.file-header-path
is the path to the file that contains the header. This is useful in case of long, multi-line headers, such as copyrights.file-header-ignore-empty-files
turns on the mode of ignoring the empty files, like__init__.py
. The default value isFalse
.
If both options file-header
and file-header-path
are set, then file-header
will be used and the file-header-path
is ignored.
Example
Setup
-
.pylintrc:
[MASTER] load-plugins=pylintfileheader file-header=# -----------\n#[ \w]*\n# -----------
-
valid_example.py:
# ----------- # lorem ipsum # ----------- print('I am a valid example')
-
invalid_example.py:
# lorem ipsum print('I am an invalid example')
Evaluation
-
pylint valid_example.py
evaluates to:Using config file /path/to/your/.pylintrc ------------------------------------ Your code has been rated at 10.00/10
-
pylint invalid_example.py
evaluates to:Using config file /path/to/your/.pylintrc ************* Module invalid_example C: 1, 0: File header should match regex "# -----------\n#[ \w]*\n# -----------" (invalid-file-header) ----------------------------------- Your code has been rated at 8.57/10
Contribution
If you found a bug or are missing a feature do not hesitate to file an issue.
Pull Requests are welcome!
Support
When you like this package make sure to star the repository. I am always looking for new ideas and feedback.
In addition, it is possible to donate via paypal.
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
Built Distribution
Hashes for pylintfileheader-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cd4877565feb37bd79d484caa78867bff86653ba72d20931be7872aa3adde02 |
|
MD5 | c6b3931a45114d5b2ef8a4dcfac45f1b |
|
BLAKE2b-256 | 8c6c1e09027c7d63b5a30ae7b6cf9feecf34e50b7aef2229d9b87548217628e8 |