Skip to main content

My own useful pre-commit hooks

Project description

mondeja's pre-commit hooks

PyPI Python versions License Tests

Example configuration

- repo: https://github.com/mondeja/pre-commit-hooks
  rev: v1.8.0
  hooks:
    - id: dev-extras-required
    - id: root-editorconfig-required
      args:
        - -domain=my-web.xyz
    - id: cloudflare-nameservers
      args:
        - -domain=my-web.xyz
    - id: cloudflare-gh-pages-dns
      args:
        - -domain=my-web.xyz
        - -username=my_gh_username
    - id: file-check-lines
      files: ^MANIFEST.in$
      args:
        - include README.md
        - include LICENSE

Hooks

add-pre-commit-hook

Add a pre-commit hook to your configuration file if is not already defined.

Arguments

  • -repo=URL (str) Repository of the new hook.
  • -rev=VERSION (str) Version of the new hook.
  • -hook=ID (str) Identifier of the new hook.

See repo-stream if you're wondering why you would need to add a pre-commit hook from another hook.

dev-extras-required

  • Support for pyproject.toml and setup.py files is limited to printing errors, automatic file rewriting is not performed.

Check if your development dependencies contains all other extras requirements. If an extra requirement is defined in other extra group than your development one, it will be added to your development extra dependencies group. If your development group is not defined, it will be created.

This is useful if you want to execute python -m pip install -e .[dev] to install all the optional requirements of the package, so if you add a new requirement to another groups, it will be added to development requirements.

Arguments

  • -extra=NAME (str): Name for your development requirements extra group (as default dev).
  • -setup-cfg=PATH (str): Path to your setup.cfg file, mandatory if the extras requirements are defined in a setup.cfg file and this is located in another directory than the current one.
  • -pyproject-toml=PATH (str): Path to your pyproject.toml file, mandatory if the extras requirements are defined in a pyproject.toml file and this is located in another directory than the current one.

file-check-lines

Check that a set of lines are included in a file. The file path must be passed in the files argument and only one can match against the regex.

The positional arguments must be the lines to check for inclusion in the file, without newlines characters. Empty lines and lines composed by newlines characters will be ignored.

nameservers-endswith

Check that the nameservers of a domain ends with a string or raise an error. You can use it to check if a site like Clouflare is managing a domain using -nameserver=cloudflare.com.

Arguments

  • -domain=DOMAIN (str): Domain name whose nameservers will be checked.
  • -nameserver=NAMESERVER (str): String to end the domain name servers in.

cloudflare-nameservers

Check that Cloudflare is handling the nameservers of a domain.

Arguments

  • -domain=DOMAIN (str): Domain name whose nameservers will be checked.

cloudflare-gh-pages-dns

Check that the DNS records of a Cloudflare site are configured to serve a static website under Github Pages.

You must define the environment variable CF_API_KEY with your Cloudflare API key.

The required DNS records to make it pass are:

Type Name Content
A {domain} 185.199.108.153
A {domain} 185.199.109.153
A {domain} 185.199.110.153
A {domain} 185.199.111.153
CNAME www {username}.github.io

Arguments

  • -domain=DOMAIN: Domain managed by Cloudflare whose DNS records will be checked.
  • -username=USER: Github username or organization under the Github Pages site is being served.

Environment variables

root-editorconfig-required

Check if your repository has an .editorconfig file and if this has a root directive defined as true before section headers.

wavelint

Check if your WAVE files have the correct number of channels, frame rate, durations...

You need to install

Arguments

  • -nchannels=N (int): Number of channels that your sounds must have.
  • -sample-width=N (int): Number of bytes that your sounds must have.
  • -frame-rate=N (int): Sampling frequency that your sounds must have.
  • -nframes=N (int): Exact number of frames that your sounds must have.
  • -comptype=TYPE (str): Compression type that your sounds must have.
  • -compname=NAME (int): Compression that your sounds must have.
  • -min-duration=TIME (float): Minimum duration in seconds that your sounds must have.
  • -max-duration=TIME (float): Maximum duration in seconds that your sounds must have.

More hooks

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

mondeja_pre_commit_hooks-1.8.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

mondeja_pre_commit_hooks-1.8.0-py2.py3-none-any.whl (16.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mondeja_pre_commit_hooks-1.8.0.tar.gz.

File metadata

File hashes

Hashes for mondeja_pre_commit_hooks-1.8.0.tar.gz
Algorithm Hash digest
SHA256 a8d69e62aa61817b1b10667b40e1db00b6697a507e7268325a2b8c138118b79d
MD5 ec9c2bbded3907c9fbed08db5d2bdce9
BLAKE2b-256 d26f732ee3a29fa77963484d97e9dfa5c23ea31466371a947d6f708d0695c883

See more details on using hashes here.

Provenance

File details

Details for the file mondeja_pre_commit_hooks-1.8.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mondeja_pre_commit_hooks-1.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 99cd4c242244d764642e3b6ca45f1bc2a45c9734983aba9706c7bea05b45923e
MD5 4703c2d83e95233be78f299bcf7fc6fc
BLAKE2b-256 d5c879c88be9a050422655365d13abe1aaf881c7384d986f4ae92d462f905399

See more details on using hashes here.

Provenance

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