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-headeris a regexp representing the file header that should be on top of a file.file-header-pathis 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-filesturns 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.pyevaluates to:Using config file /path/to/your/.pylintrc ------------------------------------ Your code has been rated at 10.00/10 -
pylint invalid_example.pyevaluates 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
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylintfileheader-1.1.0.tar.gz.
File metadata
- Download URL: pylintfileheader-1.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74f2ddc0a7dcf7bd0290a26b8922a260a1de2331cecf0a08075ff7e059461f14
|
|
| MD5 |
e1fb64609b34e4b3edc8a516e071ab45
|
|
| BLAKE2b-256 |
aa128a597fb273aa899d62d0a5d536e2969c134ca44a7372e183b0f27a4537e8
|
File details
Details for the file pylintfileheader-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pylintfileheader-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58de42f475550bc2ef542e2490ff679f330ff705eb4e904993589917d12b0d88
|
|
| MD5 |
28e03ca581da309a269a312b6023d536
|
|
| BLAKE2b-256 |
538055f629016c2b26736cfec3b8cf59575ff652efc51d6de8eccf5fd8d3bc17
|