简体   繁体   中英

How to add command line arguments to PyCharm's "mypy (Official)" plugin?

I seem to be using PEP 484 and PEP 526 type annotations more and more in my code.

I mostly use vim+syntastic, but I'm exploring my options a little, specifically I'm looking into how I'd like using PyCharm for some projects.

PyCharm has two mypy plugins. For now at least, I've gone with the one called "Mypy (Official)".

Is there a way of configuring PyCharm to use "mypy --disallow-untyped-calls --ignore-missing-imports file1.py file2.py" ?

My intention is to make PyCharm more strict in its type checking (--disallow-untyped-calls), while at the same time not generating errors about dependencies that don't include type annotations (--ignore-missing-imports).

I know I could write a shell wrapper to do this, but I'd rather go through the PyCharm GUI this time.

Thanks!

If you navigate to Configure plugin... for the MyPy (Official) plugin in PyCharm (right click on the "MyPy Terminal" pane), you can customize the command used to run mypy . On my machine (MacOS) with a clean install of the MyPy (Official) plugin, the default is:

dmypy run -- --follow-imports=error .

If you change this to

dmypy run -- --follow-imports=error --disallow-untyped-calls --ignore-missing-imports .

then the options you requested should be enabled.

Note that --follow-imports must be set to skip or error when using the plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM