I am trying to run mypy as a "Before Launch" tool in the Run Configuration as a Template.
I have the following settings (Program: is the path to the mypy executible).
When I run my script I expect the macro to insert the filename of the script as so:
mypy.exe myScript.py
however it is only running the mypy.exe part (in the console I get an error telling me to supply the target script to the function). I have also tried deleting the working directory field as well, to no avail:
(Win10 / Python3.6 / Miniconda)
I am seeing similar behavior with version:
PyCharm 2018.2.5 (Professional Edition) Build #PY-182.5107.22, built on November 13, 2018
External Tools
It seems that the macro
$FilePath$
is not being injected as an argument into themypy
executable. The only one I have tried which does get injected is$PyInterpreterDirectory
.File Watchers
Another workaround to this is adding
mypy
to file watchers. This will allow you to displaymypy
analysis of the current file, each time you save the file.File > Settings > Tools > File Watchers : From here add the
mypy
executable and the argument.TL;DR:
External Tools
$FilePath$
macro fails to inject arguments intomypy
executable. File Watchers$FilePath$
macro succeeds.Reference for File Watchers : https://www.alexkorablev.com/mypy-python-27.html
it is for Python2.7 but the idea is the same for configuring file watchers.
Hope this helps.
I have this code at the end of the module (probably not the best way, but when you have a small module and want to test things, it does the trick):