Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run mypy on all Python files of a project

Tags:

python

mypy

How can I run mypy on all .py files in a project? I have seen I can specify a module to run mypy on but not something to specify a file mask or something like this.

like image 704
Notbad Avatar asked Apr 16 '18 16:04

Notbad


People also ask

How do I run MYPY with config file?

To use this config file, place it at the root of your repo and run mypy. This config file specifies three global options in the [mypy] section. These three options will: Type-check your entire project assuming it will be run using Python 2.7.

Does MYPY run code?

Installing and running mypy This command makes mypy type check your program.py file and print out any errors it finds. Mypy will type check your code statically: this means that it will check for errors without ever running your code, just like a linter.


1 Answers

If all of your Python files live within a specific module or directory, then just running mypy folder_name is fine.

You can also pass in multiple paths if you prefer to target specific files or modules. For example: mypy a.py b.py some_directory.

The documentation has some more details and caveats.

like image 176
Michael0x2a Avatar answered Oct 07 '22 07:10

Michael0x2a