Skip to content

Commit

Permalink
docs: add docs for mypy plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro-o918 committed Sep 20, 2024
1 parent 8fbf105 commit 39c06ee
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions doc/mypy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Mypy plugin
===========================

Mypy plugin provides type checking for ``luigi.Task`` using Mypy.

Require Python 3.8 or later.

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

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

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

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

Examples
--------

For example the following code linted by Mypy:

.. code:: python
import luigi
class MyTask(luigi.Task):
foo: int = luigi.IntParameter()
bar: str = luigi.Parameter()
MyTask(foo=1, bar='bar')
Foo(foo=1, bar='2') # OK
Foo(foo='1', bar='2') # Error: Argument 1 to "Foo" has incompatible type "str"; expected "int"

0 comments on commit 39c06ee

Please sign in to comment.