Skip to content

EricWebsmith/mypy-helper

Repository files navigation

Mypy Helper

CI Coverage pypi downloads versions license

A tool to generate type hints and fix mypy errors.

Installation

pip install mypy-helper

Usage

To see a list of available commands, run the following:

mypy-help --help

Rectifying 'ignore-without-code' issues

ignore-without-code is a mypy error code enforcing the developer to provide error code for the "# type: ignore" comment.

The command fix-ignore-without-code fixes ignore without code. Use this before you have tried your best to eleminate the ignore

  • Usage: mypy-helper fix-ignore-without-code [OPTIONS] PATH MYPY_OUTPUT
  • Options:
    • -e, --ext TEXT Append another extension
    • --help Show this message and exit.

example:

Firstly, run mypy to collect errors.

mypy . --strict --enable-errror-code ignore-without-code > errors.txt

Secondly, fix the errors.

mypy-helper fix-ignore-without-code  examples/simple_example examples/simple_example/errors.txt

before:

a = 1
b = 2

a = "1"
b = "1"  # type: ignore

after:

a = 1
b = 2

a = "1"
b = "1"  # type: ignore[assignment]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published