https://github.com/haaleo/pylint-file-header
Pylint plugin to enforce consistent file/module header
https://github.com/haaleo/pylint-file-header
file-header pylint pylint-plugin pypi python
Last synced: about 1 month ago
JSON representation
Pylint plugin to enforce consistent file/module header
- Host: GitHub
- URL: https://github.com/haaleo/pylint-file-header
- Owner: HaaLeo
- License: mit
- Created: 2018-11-24T11:48:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-01T14:05:39.000Z (over 1 year ago)
- Last Synced: 2025-04-07T04:32:44.662Z (about 2 months ago)
- Topics: file-header, pylint, pylint-plugin, pypi, python
- Language: Python
- Size: 58.6 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# pylint-file-header
[](https://pypi.python.org/pypi/pylintfileheader) [](https://pypi.python.org/pypi/pylintfileheader) [](https://pypistats.org/packages/pylintfileheader) [](https://github.com/HaaLeo/pylint-file-header/stargazers)
[](https://raw.githubusercontent.com/HaaLeo/pylint-file-header/master/LICENSE.txt) [](https://travis-ci.org/HaaLeo/pylint-file-header) [](https://codecov.io/gh/HaaLeo/pylint-file-header) [](http://makeapullrequest.com)
[](https://www.paypal.me/LeoHanisch)Pylint plugin to enforce consistent file/module header.
## Installation
You can install the package with `pip` from [pypi](https://pypi.org/project/pylintfileheader):
```
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](https://docs.python.org/3/library/re.html#regular-expression-syntax) 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 is `False`.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**:
```pylintrc
[MASTER]
load-plugins=pylintfileheaderfile-header=# -----------\n#[ \w]*\n# -----------
```* **valid_example.py**:
```python
# -----------
# lorem ipsum
# -----------print('I am a valid example')
```* **invalid_example.py**:
```python
# lorem ipsumprint('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](https://github.com/HaaLeo/pylint-file-header/issues/new/choose).
Pull Requests are welcome!## Support
When you like this package make sure to [star the repository](https://github.com/HaaLeo/pylint-file-header/stargazers). I am always looking for new ideas and feedback.
In addition, it is possible to [donate via paypal](https://www.paypal.me/LeoHanisch).