Skip to content

Commit

Permalink
docs: add mypy plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro-o918 committed Jul 19, 2024
1 parent b7c3173 commit f5bf4e4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/mypy_plugin.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[Experimental] Mypy plugin
===========================

Mypy plugin provides type checking for gokart tasks using Mypy.
This feature is experimental.

How to use
--------------

Configure Mypy to use this plugin by adding the following to your ``mypy.ini`` file:

.. code:: ini
[mypy]
plugins = gokart.mypy:plugin
or by adding the following to your ``pyproject.toml`` file:

.. code:: toml
[tool.mypy]
plugins = ["gokart.mypy:plugin"]
Then, run Mypy as usual.

For example the following code linted by Mypy:

.. code:: python
import gokart
import luigi
class Foo(gokart.TaskOnKart):
# NOTE: must all the parameters be annotated
foo: int = luigi.IntParameter(default=1)
bar: str = luigi.IntParameter(default=2)
Foo(foo=1, bar='2') # OK
Foo(foo='1') # NG because foo is not int and bar is missing

0 comments on commit f5bf4e4

Please sign in to comment.