Skip to main content

Enables pylint to force a consistent file header.

Project description

pylint-file-header

Pypi PyPI - Python Version PyPI - Downloads Stars
PyPI - License Build Status Codecov PRs Welcome
Donate

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 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:

    [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

pylintfileheader-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

pylintfileheader-1.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file pylintfileheader-1.0.0.tar.gz.

File metadata

  • Download URL: pylintfileheader-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for pylintfileheader-1.0.0.tar.gz
Algorithm Hash digest
SHA256 680aa1f81e14c8bf5645fa2186b8a55aecd1b7c49ed5d9463ca77f53b0407d30
MD5 1395d50d8867f3cfb3f3796ee7c790a7
BLAKE2b-256 4c14de724962c14b48a14a2a4c68f94a5005030dbc05a9ce8606b0d976dc43c2

See more details on using hashes here.

File details

Details for the file pylintfileheader-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pylintfileheader-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 574677c838047d49bd9f6a80bfa2fa44c0614c907940416c3c1e3f499cc0a512
MD5 d74e9ac0bc0df1a474cea63ad066bd52
BLAKE2b-256 8277d4fd43c70ed40269e699a1f39513ebc35a169ca017f19c12bc16be8dfdd2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page