Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to add mypy into PyCharm

Tags:

pycharm

mypy

Trying to setup mypy with my PyCharm Professional 2017.2. But it doesn't work. I also would like to setup mypy check on one particular file vs entire project, can some please share the way they have configured mypy in their PyCharm.

like image 598
yadayada Avatar asked Oct 30 '17 20:10

yadayada


3 Answers

You can use the mypy-pycharm plugin to have real-time and on-demand scanning with mypy from within PyCharm/IDEA.

This plugin has also a feature to scan just the current selected file (the green play button on the left side bar):

enter image description here

like image 122
Roberto Leinardi Avatar answered Nov 11 '22 21:11

Roberto Leinardi


You can add an external tool in the "run/Debug configurations" of pycharm.

Pycharm will then run mypy first, you will see a new tab in the run window, if it is successful then it can run your python script (or in my example below it will run my django unit tests).

There is also a trick to use $PyInterpretorDirectory$/mypy so that pycharm will pickup mypy from the right location.

enter image description here

like image 44
Lingster Avatar answered Nov 11 '22 21:11

Lingster


Could be an import issue. Check mypy configurations for pycharm (assuming mypy plugin already installed) Argument --follow-imports normal makes the difference mypy configurations in pycharm

like image 38
drt Avatar answered Nov 11 '22 20:11

drt