Skip to main content

Helps you check type hints when you commit code.

Project description

check-type-hints

pypi

What can it do?

It is a simple pre-commit plug-in that helps you check type hints in committed python files. Currently, only python is supported

Main function

function 1: --filter

It can help you filter folders that you don't want to check, like tests, pytests...

function 2: --method

It helps you filter function and method names that you don't want to check, such as get, post, put, and delete in Django view

function 3: --ignore/--no-ignore

By default, the plug-in checks type-hints that are not filled in, breaking the commit code and telling you where there is a problem. If you don't want to interrupt the commit, you can enable --ignore, which will only prompt warnings

Example:

First:

pip install pre-commit pip install check-type-hints

then:

Add file .pre-commit-config.yaml to the project root directory. eg:

repos:
  - repo: local
    hooks:
      - id: typehint-check
        name: Typehint Check
        entry: check_type_hints check --no-ignore --filter tests  --filter pytests --method get --method post --method put --method patch --method delete
        language: system
        types: [ python ]
        stages: [ commit ]
        pass_filenames: false
        verbose: true

and then:

pre-commit install

and finally:

You can enjoy it!

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

check-type-hints-0.0.4.tar.gz (3.3 kB view hashes)

Uploaded Source

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