Skip to content

Commit

Permalink
Add Mypy issue tracker to README (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
luabud authored Jan 24, 2024
1 parent 9404a04 commit 85a7af3
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Visual Studio Code extension with support for the Mypy type checker. This extension ships with `mypy=1.8.0`.

> **Note**: The minimum version of Mypy this extension supports is `1.0.0`.
> **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](https://github.com/python/mypy/issues) as this extension is just a wrapper around Mypy.
This extension supports all [actively supported versions](https://devguide.python.org/#status-of-python-branches) of the Python language (i.e., Python >= 3.8).

Expand All @@ -12,12 +12,12 @@ 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](#settings) for more details on how to customize the extension.

- **Integrated type checking**: Once this extension is installed in Visual Studio Code, Mypy will be automatically executed when you open a Python file, reporting any errors or warnings in the "Problems" window.
- **Customizable Mypy version**: By default, this extension uses the version of Mypy that is shipped with the extension. However, you can configure it to use a different binary installed in your environment through the `mypy-type-checker.importStrategy` setting, or set it to a custom Mypy executable through the `mypy-type-checker.path` settings.
- **Workspace-wide type checking**: By default, this extension will only report errors and warnings for files open in the editor. However, you can configure it to report errors and warnings for the entire workspace through the `mypy-type-checker.reportingScope` setting.
- **Mono repo support**: If you are working with a mono repo, you can configure the extension offer type checking for Python files in subfolders of the workspace root folder by setting the `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.
- **Customizable linting rules**: You can customize the severity of specific Mypy error codes through the `mypy-type-checker.severity` setting.
- **Mypy Daemon support**: This extension supports the Mypy daemon (`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`.
- **Integrated type checking**: Once this extension is installed in Visual Studio Code, Mypy will be automatically executed when you open a Python file, reporting any errors or warnings in the "Problems" window.
- **Customizable Mypy version**: By default, this extension uses the version of Mypy that is shipped with the extension. However, you can configure it to use a different binary installed in your environment through the `mypy-type-checker.importStrategy` setting, or set it to a custom Mypy executable through the `mypy-type-checker.path` settings.
- **Workspace-wide type checking**: By default, this extension will only report errors and warnings for files open in the editor. However, you can configure it to report errors and warnings for the entire workspace through the `mypy-type-checker.reportingScope` setting.
- **Mono repo support**: If you are working with a mono repo, you can configure the extension offer type checking for Python files in subfolders of the workspace root folder by setting the `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.
- **Customizable linting rules**: You can customize the severity of specific Mypy error codes through the `mypy-type-checker.severity` setting.
- **Mypy Daemon support**: This extension supports the Mypy daemon (`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`.

### Disabling Mypy

Expand All @@ -44,6 +44,12 @@ There are several settings you can configure to customize the behavior of this e
<td>Arguments passed to Mypy to enable type checking on Python files. Each argument should be provided as a separate string in the array. <br> Example: <br><code>"mypy-type-checker.args" = ["--config-file=&lt;file&gt;"]</code>
</td>
</tr>
<tr>
<td>mypy-type-checker.cwd</td>
<td><code>${workspaceFolder}</code></td>
<td>Sets the current working directory used to lint Python files with Mypy. By default, it uses the root directory of the workspace <code>${workspaceFolder}</code>. You can set it to <code>${fileDirname}</code> to use the parent folder of the file being linted as the working directory for Mypy.
</td>
</tr>
<tr>
<td>mypy-type-checker.severity</td>
<td><code>{ "error": "Error", "note": "Information" }</code></td>
Expand Down Expand Up @@ -94,10 +100,10 @@ There are several settings you can configure to customize the behavior of this e

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}`
- `${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.

Expand All @@ -119,11 +125,11 @@ To open the logs, click on the language status icon (`{}`) on the bottom right o

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](https://github.com/microsoft/vscode-mypy/issues).

- 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.
- 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:

- Set the `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; or
- Install Mypy in the selected environment.
- Set the `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; or
- Install Mypy in the selected environment.

- If 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`.
- If 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`.

0 comments on commit 85a7af3

Please sign in to comment.