A Visual Studio Code extension with support for the Mypy type checker. This extension ships with mypy=1.11.2
.
Note: The minimum version of Mypy this extension supports is
1.0.0
. If you have any issues with Mypy, please report it to this issue tracker as this extension is just a wrapper around Mypy.
This extension supports all actively supported versions of the Python language (i.e., Python >= 3.8).
For more information on Mypy, see https://www.mypy-lang.org/
The Mypy extension provides a series of features to help your productivity while working with Python code in Visual Studio Code. Check out the Settings section for more details on how to customize the extension.
mypy-type-checker.importStrategy
setting, or set it to a custom Mypy executable through the mypy-type-checker.path
settings.mypy-type-checker.reportingScope
setting.mypy-type-checker.cwd
setting to ${fileDirname}
. You can also set it to ignore/skip type checking for certain files or folder paths by specifying a glob pattern to the mypy-type-checker.ignorePatterns
setting.mypy-type-checker.severity
setting.dmypy
) for faster type checking when the reporting scope is set to the entire workspace. To enable it, set the mypy-type-checker.preferDaemon
setting to true
.You can skip type checking with Mypy for specific files or directories by setting the mypy-type-checker.ignorePatterns
setting.
If you wish to disable Mypy for your entire workspace or globally, you can disable this extension in Visual Studio Code.
There are several settings you can configure to customize the behavior of this extension.
The following variables are supported for substitution in the mypy-type-checker.args
, mypy-type-checker.cwd
, mypy-type-checker.path
, mypy-type-checker.interpreter
and mypy-type-checker.ignorePatterns
settings:
${workspaceFolder}
${workspaceFolder:FolderName}
${userHome}
${env:EnvVarName}
The mypy-type-checker.path
setting also supports the ${interpreter}
variable as one of the entries of the array. This variable is subtituted based on the value of the mypy-type-checker.interpreter
setting.
Command | Description |
---|---|
Mypy: Restart Server | Force re-start the linter server. |
From the Command Palette (View > Command Palette ...), run the Developer: Set Log Level... command. Select Mypy Type Checker from the Extension logs group. Then select the log level you want to set.
Alternatively, you can set the mypy-type-checker.trace.server
setting to verbose
to get more detailed logs from the Mypy server. This can be helpful when filing bug reports.
To open the logs, click on the language status icon ({}
) on the bottom right of the Status bar, next to the Python language mode. Locate the Mypy Type Checker entry and select Open logs.
In this section, you will find some common issues you might encounter and how to resolve them. If you are experiencing any issues that are not covered here, please file an issue.
If the mypy-type-checker.importStrategy
setting is set to fromEnvironment
but Mypy is not found in the selected environment, this extension will fallback to using the Mypy binary that is shipped with the extension. However, if there are dependencies installed in the environment, those dependencies will be used along with the shipped Mypy binary. This can lead to problems if the dependencies are not compatible with the shipped Mypy binary.
To resolve this issue, you can:
mypy-type-checker.importStrategy
setting to useBundled
and the mypy-type-checker.path
setting to point to the custom binary of Mypy you want to use; orIf you have the reporting scope set to workspace
and notice a slowdown in type checking, you can try enabling the Mypy daemon (dmypy
) by setting the mypy-type-checker.preferDaemon
setting to true
.